-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewControl.py
127 lines (114 loc) · 4.34 KB
/
ViewControl.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import Live
from . import MIDI
from . import settings
from .Logging import log
from .Control import Control
class ViewControl(Control):
# __module__ = __name__
__doc__ = "Device control section of SelectedTrackControl"
def __init__(self, c_instance, selected_track_controller):
Control.__init__(self, c_instance, selected_track_controller)
self.view = Live.Application.get_application().view
self.views = self.view.available_main_views()
def get_midi_bindings(self):
return (
(
"toggle_browser",
lambda value, mode, status: self.toggle_view(
value, mode, status, "Browser"
),
),
(
"toggle_session_arranger",
lambda value, mode, status: self.toggle_view(
value, mode, status, ["Session", "Arranger"]
),
),
(
"toggle_detail",
lambda value, mode, status: self.toggle_view(
value, mode, status, "Detail"
),
),
(
"toggle_detail_clip_device",
lambda value, mode, status: self.toggle_detail(
value, mode, status, ["Detail/Clip", "Detail/DeviceChain"]
),
),
(
"toggle_detail_clip",
lambda value, mode, status: self.toggle_detail(
value, mode, status, "Detail/Clip"
),
),
(
"toggle_detail_device",
lambda value, mode, status: self.toggle_detail(
value, mode, status, "Detail/DeviceChain"
),
),
)
def toggle_view(self, value, mode, status, view):
if status == MIDI.CC_STATUS and not value: # ignore 0 values from CC-pads
return
if status == MIDI.CC_STATUS and mode == MIDI.ABSOLUTE:
if type(view) == type([]):
index = len(view) * value / 128
self.view.show_view(view[index])
return
else:
if value < 64:
self.view.hide_view(view)
else:
self.view.show_view(view)
return
if type(view) == type([]):
for v in view:
if self.view.is_view_visible(v):
index = (view.index(v) + 1) % len(view)
self.view.show_view(view[index])
return
else:
if self.view.is_view_visible(view):
self.view.hide_view(view)
else:
self.view.show_view(view)
def toggle_detail(self, value, mode, status, view):
if status == MIDI.CC_STATUS and not value: # ignore 0 values from CC-pads
return
# if status == MIDI.CC_STATUS and mode == MIDI.ABSOLUTE:
# if type(view) == type([]):
# if not self.view.is_view_visible("Detail"):
# self.view.show_view("Detail")
# else:
# index = len(view) * value / 128
# self.view.show_view(view[index])
# return
# else:
# if value < 64:
# self.view.hide_view("Detail")
# else:
# self.view.show_view("Detail")
# self.view.show_view(view)
# return
if type(view) == type([]):
# toggle between multiple DetailViews => make sure Detail is visible
if not self.view.is_view_visible("Detail"):
self.view.show_view("Detail")
else:
# detail is visible => toggle between views
for v in view:
if self.view.is_view_visible(v):
index = (view.index(v) + 1) % len(view)
self.view.show_view(view[index])
return
else:
if self.view.is_view_visible("Detail"):
if self.view.is_view_visible(view):
self.view.hide_view("Detail")
else:
self.view.show_view(view)
else:
self.view.show_view("Detail")
self.view.show_view(view)