Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tawindow.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2013-02-22 20:59:57 (GMT)
committer Walter Bender <walter.bender@gmail.com>2013-02-22 20:59:57 (GMT)
commit0d5407ff59f3540f48c081552a3324a952e42c5e (patch)
treef64bc10ba50c5e8c9433b40ba45a231d01391a01 /TurtleArt/tawindow.py
parent2ca3c1f4f674054da054548776e0ae27e90487b7 (diff)
update screen constants when rotating screen
Diffstat (limited to 'TurtleArt/tawindow.py')
-rw-r--r--TurtleArt/tawindow.py51
1 files changed, 34 insertions, 17 deletions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index ccaaec2..2342ab0 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -239,23 +239,7 @@ class TurtleArtWindow():
self.canvas.clearscreen(False)
- CONSTANTS['titlex'] = int(-(self.canvas.width * TITLEXY[0]) / \
- (self.coord_scale * 2))
- CONSTANTS['leftx'] = int(-(self.canvas.width * TITLEXY[0]) / \
- (self.coord_scale * 2))
- CONSTANTS['rightx'] = 0
- CONSTANTS['titley'] = int((self.canvas.height * TITLEXY[1]) / \
- (self.coord_scale * 2))
- CONSTANTS['topy'] = int((self.canvas.height * (TITLEXY[1] - 0.125)) / \
- (self.coord_scale * 2))
- CONSTANTS['bottomy'] = 0
- CONSTANTS['leftpos'] = int(-self.canvas.width / (self.coord_scale * 2))
- CONSTANTS['toppos'] = int(self.canvas.height / (self.coord_scale * 2))
- CONSTANTS['rightpos'] = int(self.canvas.width / (self.coord_scale * 2))
- CONSTANTS['bottompos'] = int(-self.canvas.height / \
- (self.coord_scale * 2))
- CONSTANTS['width'] = int(self.canvas.width / self.coord_scale)
- CONSTANTS['height'] = int(self.canvas.height / self.coord_scale)
+ self._configure_cb(None)
self._icon_paths = [os.path.join(self.path, 'icons')]
self.turtleart_plugins = []
@@ -402,6 +386,7 @@ class TurtleArtWindow():
self.window.connect("button-release-event", self._buttonrelease_cb)
self.window.connect("motion-notify-event", self._move_cb)
self.window.connect("key-press-event", self._keypress_cb)
+ gtk.gdk.screen_get_default().connect('size-changed', self._configure_cb)
target = [("text/plain", 0, 0)]
self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, target,
@@ -493,6 +478,38 @@ class TurtleArtWindow():
''' Check to see if project has any blocks in use '''
return len(self.just_blocks()) == 1
+ def _configure_cb(self, event):
+ ''' Screen size has changed '''
+ self.width = gtk.gdk.screen_width()
+ self.height = gtk.gdk.screen_height()
+ CONSTANTS['titlex'] = int(-(self.width * TITLEXY[0]) / \
+ (self.coord_scale * 2))
+ CONSTANTS['leftx'] = int(-(self.width * TITLEXY[0]) / \
+ (self.coord_scale * 2))
+ CONSTANTS['rightx'] = 0
+ CONSTANTS['titley'] = int((self.height * TITLEXY[1]) / \
+ (self.coord_scale * 2))
+ CONSTANTS['topy'] = int((self.height * (TITLEXY[1] - 0.125)) / \
+ (self.coord_scale * 2))
+ CONSTANTS['bottomy'] = 0
+ CONSTANTS['leftpos'] = int(-self.width / (self.coord_scale * 2))
+ CONSTANTS['toppos'] = int(self.height / (self.coord_scale * 2))
+ CONSTANTS['rightpos'] = int(self.width / (self.coord_scale * 2))
+ CONSTANTS['bottompos'] = int(-self.height / (self.coord_scale * 2))
+ CONSTANTS['width'] = int(self.width / self.coord_scale)
+ CONSTANTS['height'] = int(self.height / self.coord_scale)
+
+ if event is None:
+ return
+
+ # If there are any constant blocks on the canvas, relabel them
+ for blk in self.just_blocks():
+ if blk.name in ['leftpos', 'toppos', 'rightpos', 'bottompos',
+ 'width', 'height']:
+ blk.spr.set_label('%s = %d' % (block_names[blk.name][0],
+ CONSTANTS[blk.name]))
+ blk.resize()
+
def _expose_cb(self, win=None, event=None):
''' Repaint '''
self.do_expose_event(event)