|
4 | 4 | from xstudio.core import viewport_playhead_atom, quickview_media_atom |
5 | 5 | from xstudio.core import UuidActorVec, UuidActor, viewport_atom |
6 | 6 | from xstudio.core import get_global_playhead_events_atom, set_clipboard_atom |
| 7 | +from xstudio.core import active_viewport_atom, name_atom |
7 | 8 | from xstudio.api.session import Session, Container |
8 | 9 | from xstudio.api.session.playhead import Playhead |
9 | 10 | from xstudio.api.module import ModuleBase |
10 | 11 | from xstudio.api.auxiliary import ActorConnection |
11 | | - |
12 | | -class Viewport(ModuleBase): |
13 | | - """Viewport object, represents a viewport in the UI or offscreen.""" |
14 | | - |
15 | | - def __init__(self, connection, viewport_name): |
16 | | - """Create Viewport object. |
17 | | -
|
18 | | - Args: |
19 | | - connection(Connection): Connection object |
20 | | - viewport_name(str): Name of viewport |
21 | | -
|
22 | | - Kwargs: |
23 | | - uuid(Uuid): Uuid of remote actor. |
24 | | - """ |
25 | | - gphev = connection.request_receive( |
26 | | - connection.remote(), |
27 | | - get_global_playhead_events_atom())[0] |
28 | | - |
29 | | - remote = connection.request_receive( |
30 | | - gphev, |
31 | | - viewport_atom(), |
32 | | - viewport_name |
33 | | - )[0] |
34 | | - |
35 | | - ModuleBase.__init__( |
36 | | - self, |
37 | | - connection, |
38 | | - remote |
39 | | - ) |
40 | | - |
41 | | - @property |
42 | | - def playhead(self): |
43 | | - """Access the Playhead object supplying images to the viewport |
44 | | - """ |
45 | | - return Playhead(self.connection, self.connection.request_receive(self.remote, viewport_playhead_atom())[0]) |
46 | | - |
47 | | - @playhead.setter |
48 | | - def set_playhead(self, playhead): |
49 | | - """Set the playhead that is delivering frames to the viewport, i.e. |
50 | | - the active playhead. |
51 | | -
|
52 | | - Args: |
53 | | - playhead(Playhead): The playhead.""" |
54 | | - |
55 | | - self.connection.request_receive(self.remote, viewport_playhead_atom(), playhead.remote) |
56 | | - |
57 | | - def quickview(self, media_items, compare_mode="Off", position=(100,100), size=(1280,720)): |
58 | | - """Connect this playhead to the viewport. |
59 | | -
|
60 | | - Args: |
61 | | - media_items(list(Media)): A list of Media objects to be shown in quickview |
62 | | - windows |
63 | | - compare_mode(str): Remote actor object |
64 | | - position(tuple(int,int)): X/Y Position of new window (default=(100,100)) |
65 | | - size(tuple(int,int)): X/Y Size of new window (default=(1280,720)) |
66 | | -
|
67 | | - """ |
68 | | - |
69 | | - media_actors = UuidActorVec() |
70 | | - for m in media_items: |
71 | | - media_actors.push_back(UuidActor(m.uuid, m.remote)) |
72 | | - |
73 | | - self.connection.request_receive( |
74 | | - self.remote, |
75 | | - quickview_media_atom(), |
76 | | - media_actors, |
77 | | - compare_mode, |
78 | | - position[0], |
79 | | - position[1], |
80 | | - size[0], |
81 | | - size[1]) |
| 12 | +from xstudio.api.intrinsic import Viewport |
82 | 13 |
|
83 | 14 | class App(Container): |
84 | 15 | """App access. """ |
@@ -118,6 +49,40 @@ def viewport(self, name): |
118 | 49 | viewport(ModuleBase): Viewport module.""" |
119 | 50 | return Viewport(self.connection, name) |
120 | 51 |
|
| 52 | + def viewport_names(self): |
| 53 | + """Get a list of the names of viewport instances that exist in the |
| 54 | + application. The viewport name can be used to access the viewport |
| 55 | + via the 'viewport' method on this App object. |
| 56 | + |
| 57 | + Returns: |
| 58 | + list(str): A list of viewport names""" |
| 59 | + gphev = self.connection.request_receive( |
| 60 | + self.connection.remote(), |
| 61 | + get_global_playhead_events_atom())[0] |
| 62 | + |
| 63 | + viewports = self.connection.request_receive( |
| 64 | + gphev, |
| 65 | + viewport_atom() |
| 66 | + )[0] |
| 67 | + |
| 68 | + result = [] |
| 69 | + for vp in viewports: |
| 70 | + result.append( |
| 71 | + self.connection.request_receive( |
| 72 | + vp, |
| 73 | + name_atom() |
| 74 | + )[0] |
| 75 | + ) |
| 76 | + return result |
| 77 | + |
| 78 | + @property |
| 79 | + def active_viewport(self): |
| 80 | + """Access the current (active & visible) viewport in the xSTUDIO UI. |
| 81 | + |
| 82 | + Returns: |
| 83 | + viewport(Viewport): Viewport module.""" |
| 84 | + return Viewport(self.connection, active_viewport=True) |
| 85 | + |
121 | 86 | def set_viewport_playhead(self, viewport_name, playhead): |
122 | 87 | """Set's the named viewport to be driven by the given playhead |
123 | 88 | Args: |
|
0 commit comments