Skip to content

Commit

Permalink
Detect if we're in the bar, and do a little variable renaming to be s…
Browse files Browse the repository at this point in the history
…afe.
  • Loading branch information
rpavlik committed Apr 30, 2009
1 parent 69cc1c8 commit a5caf7e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion py/canvassedpile.py
Expand Up @@ -43,7 +43,7 @@ def remove(self, window):
def find_bounds(self):
xs = []
ys = []
for window in self.windows:
for window in self.mngd_windows:
xs.append(window.x)
ys.append(window.y)

Expand Down
6 changes: 4 additions & 2 deletions py/canvassedwindow.py
Expand Up @@ -9,7 +9,7 @@

# Internal imports
from managedwindow import ManagedWindow
from config import WIDTH, HEIGHT
from config import WIDTH, HEIGHT, is_in_bar

class CanvassedWindow(ManagedWindow, MTScatterImage):
"""Subclasses ManagedWindow and MTScatterImage to bring the abstract concept
Expand Down Expand Up @@ -41,5 +41,7 @@ def __init__(self, **kwargs):
#

def on_touch_up(self, touchlist, touchID, x, y):
print "hey, touch up: ",self.name, touchlist, touchID, x, y
if is_in_bar(x,y):
print "Yep, in the bar!"
#print "hey, touch up: ",self.name, touchlist, touchID, x, y

16 changes: 15 additions & 1 deletion py/config.py
@@ -1,4 +1,18 @@
"""Constants and other similar configuration."""

WIDTH = 1024
HEIGHT = 768
HEIGHT = 768
BARSIZE=200
BARLOC="top"

def is_in_bar(x, y):
if BARLOC=="top":
return (y>HEIGHT-BARSIZE and y<HEIGHT)
elif BARLOC=="bottom":
return (y>0 and y<BARSIZE)
elif BARLOC=="right":
return (x>WIDTH-BARSIZE and x<WIDTH)
elif BARLOC=="left":
return (x>0 and x<BARSIZE)
else:
raise Exception("invalid bar location specified in config")
Binary file modified py/wallpaper.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 36 additions & 17 deletions py/wallpaper.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions py/windowpile.py
Expand Up @@ -62,7 +62,7 @@ class WindowPile:
"""An collection of 0 or more ManagedWindows, manipulated as a group."""

def __init__(self, managedwindows=None):
self.windows = set()
self.mngd_windows = set()

if managedwindows != None:
# connect each of the given ManagedWindows to this pile.
Expand All @@ -82,7 +82,7 @@ def add(self, window):
raise AlreadyPiledError(self, window)

window.register_pile(self)
self.windows.add(window)
self.mngd_windows.add(window)

def reassign(self, window):
"""Reassign a window already assigned to another pile to this pile."""
Expand All @@ -103,11 +103,11 @@ def remove(self, window):
raise WindowNotManagedError(window)
if window.pile != self:
raise NotMyChildError(self, window)
if window not in self.windows:
if window not in self.mngd_windows:
raise NotMyChildError(self, window)

window.pile = None
self.windows.remove(window)
self.mngd_windows.remove(window)

def update_child_icon(self, window):
"""Callback called by child window upon noticing its icon changed."""
Expand Down

0 comments on commit a5caf7e

Please sign in to comment.