Home | Trees | Indices | Help |
|
---|
|
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 import time 20 21 from timelinelib.view.inputhandler import InputHandler 22 23259427 self.controller = controller 28 self.start_time = start_time 29 self.last_clock_time = time.clock() 30 self.last_x = 0 31 self.last_x_distance = 0 32 self.speed_px_per_sec = 0 33 self.INERTIAL_SCROLLING_SPEED_THRESHOLD = 20034 3840 self.controller.change_input_handler_to_no_op() 41 if self.controller.config.use_inertial_scrolling: 42 if self.speed_px_per_sec > self.INERTIAL_SCROLLING_SPEED_THRESHOLD: 43 self._inertial_scrolling()4446 MAX_SPEED = 10000 47 self.last_x_distance = x - self.last_x 48 self.last_x = x 49 current_clock_time = time.clock() 50 elapsed_clock_time = current_clock_time - self.last_clock_time 51 if elapsed_clock_time == 0: 52 self.speed_px_per_sec = MAX_SPEED 53 else: 54 self.speed_px_per_sec = min(MAX_SPEED, abs(self.last_x_distance / 55 elapsed_clock_time)) 56 self.last_clock_time = current_clock_time5759 self.current_time = self.controller.get_time(x) 60 delta = (self.current_time - self.start_time) 61 self.controller._scroll_timeline(delta)6264 frame_time = self._calculate_frame_time() 65 value_factor = self._calculate_scroll_factor() 66 inertial_func = (0.20, 0.15, 0.10, 0.10, 0.10, 0.08, 0.06, 0.06, 0.05) 67 #inertial_func = (0.20, 0.15, 0.10, 0.10, 0.07, 0.05, 0.02, 0.05) 68 self.controller.use_fast_draw(True) 69 next_frame_time = time.clock() 70 for value in inertial_func: 71 self.controller._scroll_timeline_view(value * value_factor) 72 next_frame_time += frame_time 73 sleep_time = next_frame_time - time.clock() 74 if sleep_time >= 0: 75 time.sleep(sleep_time) 76 self.controller.use_fast_draw(False) 77 self.controller._redraw_timeline()7880 MAX_FRAME_RATE = 26.0 81 frames_per_second = (MAX_FRAME_RATE * self.speed_px_per_sec / 82 (100 + self.speed_px_per_sec)) 83 frame_time = 1.0 / frames_per_second 84 return frame_time85
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 3 03:56:39 2013 | http://epydoc.sourceforge.net |