SourceForge: quivi/quivi: changeset 49:7fa1f80e702b
Modified: dragging always drags the image; it is now possible to add another action to left click
authorConrado Porto Lopes Gouvea
Sun Jan 03 18:43:52 2010 -0200 (2 months ago)
changeset 497fa1f80e702b
parent 48 753292d725f1
child 50 df740c7584f0
Modified: dragging always drags the image; it is now possible to add another action to left click
changelog.txt
quivilib/control/canvas.py
quivilib/gui/options.py
     1.1 --- a/changelog.txt	Sun Jan 03 18:09:56 2010 -0200
     1.2 +++ b/changelog.txt	Sun Jan 03 18:43:52 2010 -0200
     1.3 @@ -5,6 +5,8 @@
     1.4  - Fixed (#21): UnicodeDecodeError when opening the program if the username has
     1.5    non-ascii characters (probably; unable to reproduce & test)
     1.6  - Modified: added double buffering in order to correctly display transparent GIF's
     1.7 +- Modified (#3): dragging always drags the image; it is now possible to add another
     1.8 +  action to left click
     1.9  - Added: es_MX and de_DE translations
    1.10  
    1.11  
     2.1 --- a/quivilib/control/canvas.py	Sun Jan 03 18:09:56 2010 -0200
     2.2 +++ b/quivilib/control/canvas.py	Sun Jan 03 18:43:52 2010 -0200
     2.3 @@ -37,7 +37,10 @@
     2.4          Publisher().subscribe(self.on_canvas_scrolled, '%s.scrolled' % self.name)
     2.5          Publisher().subscribe(self.on_canvas_mouse_event, '%s.mouse.event' % self.name)
     2.6          Publisher().subscribe(self.on_canvas_mouse_motion, '%s.mouse.motion' % self.name)
     2.7 +        #Indicates that the user is moving the image
     2.8          self._moving_image = False
     2.9 +        #Indicates that the user has moved the image significantly 
    2.10 +        self._moved_image = False
    2.11          self._old_mouse_pos = (-1, -1)
    2.12          self._default_cursor = wx.CursorFromImage(images.cursor_hand.GetImage())
    2.13          self._moving_cursor = wx.CursorFromImage(images.cursor_drag.GetImage())
    2.14 @@ -76,15 +79,14 @@
    2.15              cmd_ide = self.settings.getint('Mouse', '%sClickCmd' % button_name)
    2.16              #TODO: (2,2) Refactor: change to constant. This is a dummy command ID
    2.17              # for "drag image". See settings.py
    2.18 -            if cmd_ide == 20000:
    2.19 -                if event == 0:
    2.20 -                    Publisher().sendMessage('%s.cursor.changed' % self.name, self._moving_cursor)
    2.21 -                    self._moving_image = True
    2.22 -                elif event == 1:
    2.23 -                    Publisher().sendMessage('%s.cursor.changed' % self.name, self._default_cursor)
    2.24 -                    self._moving_image = False
    2.25 -            elif event == 0:
    2.26 +            if event == 0 and button == 0:
    2.27 +                Publisher().sendMessage('%s.cursor.changed' % self.name, self._moving_cursor)
    2.28 +                self._moving_image = True
    2.29 +            if event == 1 and (not self._moved_image or button != 0):
    2.30                  Publisher().sendMessage('command.execute', cmd_ide)
    2.31 +            if event == 1 and button == 0:
    2.32 +                Publisher().sendMessage('%s.cursor.changed' % self.name, self._default_cursor)
    2.33 +                self._moving_image = False
    2.34          else:
    2.35              #Not the main canvas (e.g. wallpaper dialog canvas)
    2.36              if button == 0 and event == 0:
    2.37 @@ -93,6 +95,7 @@
    2.38              elif button == 0 and event == 1:
    2.39                  Publisher().sendMessage('%s.cursor.changed' % self.name, self._default_cursor)
    2.40                  self._moving_image = False
    2.41 +        self._moved_image = False
    2.42                  
    2.43          
    2.44      def on_canvas_mouse_motion(self, message):
    2.45 @@ -101,6 +104,7 @@
    2.46          canvas = self.canvas
    2.47          if old_x != -1 and self._moving_image:
    2.48              dx, dy = x - old_x, y - old_y
    2.49 +            self._moved_image = True
    2.50              scale_x = canvas.width / float(self.view.width)
    2.51              scale_y = canvas.height / float(self.view.height)
    2.52              scale_x = 1 if scale_x < 1 else scale_x
     3.1 --- a/quivilib/gui/options.py	Sun Jan 03 18:09:56 2010 -0200
     3.2 +++ b/quivilib/gui/options.py	Sun Jan 03 18:43:52 2010 -0200
     3.3 @@ -89,11 +89,6 @@
     3.4          self.SetSize((400, 400))
     3.5          self.fit_cbo.SetSelection(-1)
     3.6          # end wxGlade
     3.7 -        #TODO: (2,2) Refactor: change to constant. This is a dummy command ID
     3.8 -        # for "drag image". See settings.py
     3.9 -        self.mouse_left_cbo.Append(_('Drag image'), 20000)
    3.10 -        self.mouse_middle_cbo.Append(_('Drag image'), 20000)
    3.11 -        self.mouse_right_cbo.Append(_('Drag image'), 20000)
    3.12          
    3.13          for category in self.categories:
    3.14              for cmd in category.commands: