From 0d5407ff59f3540f48c081552a3324a952e42c5e Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 22 Feb 2013 20:59:57 +0000 Subject: update screen constants when rotating screen --- 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) -- cgit v0.9.1