-
Notifications
You must be signed in to change notification settings - Fork 9
/
SpecialZoomingComponent.py
56 lines (48 loc) · 2.19 KB
/
SpecialZoomingComponent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# emacs-mode: -*- python-*-
# -*- coding: utf-8 -*-
import Live
from _Framework.SessionZoomingComponent import SessionZoomingComponent
from _Framework.ButtonElement import ButtonElement
class SpecialZoomingComponent(SessionZoomingComponent):
' Special ZoomingComponent that uses clip stop buttons for stop all when zoomed '
__module__ = __name__
def __init__(self, session):
SessionZoomingComponent.__init__(self, session)
def _scroll_up(self):
#if self._is_zoomed_out:
height = self._session.height()
track_offset = self._session.track_offset()
scene_offset = self._session.scene_offset()
if scene_offset > 0:
new_scene_offset = scene_offset
if scene_offset % height > 0:
new_scene_offset -= (scene_offset % height)
else:
new_scene_offset = max(0, scene_offset - height)
self._session.set_offsets(track_offset, new_scene_offset)
def _scroll_down(self):
#if self._is_zoomed_out:
height = self._session.height()
track_offset = self._session.track_offset()
scene_offset = self._session.scene_offset()
new_scene_offset = scene_offset + height - (scene_offset % height)
self._session.set_offsets(track_offset, new_scene_offset)
def _scroll_left(self):
#if self._is_zoomed_out:
width = self._session.width()
track_offset = self._session.track_offset()
scene_offset = self._session.scene_offset()
if track_offset > 0:
new_track_offset = track_offset
if track_offset % width > 0:
new_track_offset -= (track_offset % width)
else:
new_track_offset = max(0, track_offset - width)
self._session.set_offsets(new_track_offset, scene_offset)
def _scroll_right(self):
#if self._is_zoomed_out:
width = self._session.width()
track_offset = self._session.track_offset()
scene_offset = self._session.scene_offset()
new_track_offset = track_offset + width - (track_offset % width)
self._session.set_offsets(new_track_offset, scene_offset)