Package Gnumed :: Package timelinelib :: Package view :: Module scrollbase
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.view.scrollbase

 1  # Copyright (C) 2009, 2010, 2011  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  from timelinelib.view.inputhandler import InputHandler 
20   
21   
22  # dragscroll timer interval in milliseconds 
23  DRAGSCROLL_TIMER_MSINTERVAL = 300 
24  # timeline. The scroll zone areas are found at the beginning and at the 
25  # end of the timeline. 
26  SCROLL_ZONE_WIDTH = 20 
27   
28   
29 -class ScrollViewInputHandler(InputHandler):
30
31 - def __init__(self, controller):
32 self.controller = controller 33 self.view = controller.view 34 self.timer_running = False
35
36 - def mouse_moved(self, x, y, alt_down=False):
37 self.last_x = x 38 if self.controller._in_scroll_zone(x) and not self.timer_running: 39 self.view.start_dragscroll_timer(milliseconds=DRAGSCROLL_TIMER_MSINTERVAL) 40 self.timer_running = True
41
42 - def left_mouse_up(self):
44
45 - def dragscroll_timer_fired(self):
46 if self.controller._in_scroll_zone(self.last_x): 47 if self.last_x < SCROLL_ZONE_WIDTH: 48 direction = 1 49 else: 50 direction = -1 51 self.controller._scroll_timeline_view(direction) 52 self.view_scrolled()
53
54 - def view_scrolled(self):
55 raise Exception("view_scrolled not implemented in subclass.")
56