Lumiera  0.pre.03
»edit your freedom«
interaction-director.cpp
Go to the documentation of this file.
1 /*
2  interactionDirector - Global UI Manager
3 
4  Copyright (C) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
29 #include "stage/gtk-base.hpp"
30 #include "stage/ui-bus.hpp"
31 #include "stage/ctrl/bus-term.hpp"
41 #include "stage/dialog/render.hpp"
43 #include "stage/ctrl/ui-state.hpp"
46 //#include "stage/timeline/timeline-widget.hpp"
47 //#include "stage/timeline/timeline-controller.hpp" /////////////////TODO still required?
48 #include "include/ui-protocol.hpp"
50 #include "steam/asset/sequence.hpp"
52 #include "steam/cmd.hpp"
53 #include "vault/real-clock.hpp"
55 #include "lib/format-string.hpp"
56 #include "lib/format-obj.hpp"
57 //#include "stage/ui-bus.hpp"
58 //#include "lib/util.hpp"
59 
60 //#include <memory>
61 //#include <list>
62 
63 //using util::isnil;
64 using util::_Fmt;
65 //using std::list;
66 //using std::shared_ptr;
67 using lib::idi::EntryID;
68 using lib::hash::LuidH;
69 using lib::diff::Rec;
72 using LERR_(DIFF_STRUCTURE);
73 using std::make_unique;
74 using util::toString;
75 
76 
77 namespace stage {
78 namespace interact {
79 
80  namespace session = steam::mobject::session;
81  namespace cmd = steam::cmd;
82 
83  using ctrl::GlobalCtx;
84  using ctrl::UiState;
85  using setting::AssetController;
86  using timeline::TimelineController;
87 
88 
89  // emit dtors of children here...
90  InteractionDirector::~InteractionDirector()
91  { }
92 
93 
102  : model::Controller(session::Root::getID(), globals.uiBus_.getAccessPoint())
103  , globalCtx_(globals)
104  , gestureState_{}
105  , viewLocator_{new ViewLocator}
106  , spotLocator_{new SpotLocator}
107  , navigator_{*spotLocator_, *viewLocator_} // Service exposed as Depend<LocationQuery>
108  , tracker_{new FocusTracker{*navigator_}}
109  , uiState_{new UiState{globals.uiBus_.getStateManager(), *tracker_}}
110  , assets_{new AssetController{session::Root::getAssetID(), this->uiBus_}}
111  , timelines_{}
112  {
113  Glib::signal_timeout()
114  .connect_once (sigc::mem_fun(*this, &InteractionDirector::populateContent_afterStart)
115  ,DELAY_AFTER_GUI_START_in_ms
116  ,Glib::PRIORITY_LOW); // after all initial drawing tasks
117  }
118 
119 
120  void
122  {
123  invoke (cmd::test_meta_activateContentDiff);
124  }
125 
126 
127  namespace { // Temporary Junk
128  inline void
129  unimplemented (const char* todo)
130  {
131  WARN (stage, "%s is not yet implemented. So sorry.", todo);
132  }
133  }
134 
135 
136 
137  void
138  InteractionDirector::buildMutator (TreeMutator::Handle buffer)
139  {
140  buffer.emplace(
141  TreeMutator::build()
142  .attach (collection(timelines_)
143  .isApplicableIf ([&](GenNode const& spec) -> bool
144  { // »Selector« : require object-like sub scope
145  return spec.data.isNested();
146  })
147  .constructFrom ([&](GenNode const& spec) -> TimelineGui
148  { // »Constructor« : what to do when the diff mentions a new entity
149  return injectTimeline (spec);
150  }))
151  .mutateAttrib(ATTR_fork, [&](TreeMutator::Handle buff)
152  { // »Attribute Mutator« : how enter an object field as nested scope
153  REQUIRE (assets_);
154  assets_->buildMutator(buff);
155  }));
156  }
157 
158 
167  void
169  {
170  unimplemented ("launch project setup UI");
171  }
172 
173 
180  void
182  {
183  string snapshotID{"snap-" + toString(vault::RealClock::now())};
184  invoke (cmd::session_saveSnapshot, snapshotID);
185  }
186 
187 
200  void
202  {
203  unimplemented ("launch project setup UI to create a fork of the project under new name");
204  }
205 
206 
216  void
218  {
219  dialog::PreferencesDialog dialog(getWorkspaceWindow());
220  dialog.run();
221 
222  unimplemented ("edit global configuration");
223  }
224 
225 
233  void
235  {
236  unimplemented ("open file");
237  }
238 
239 
248  void
250  {
251  dialog::Render dialog{getWorkspaceWindow()};
252  dialog.run();
253 
254  unimplemented ("start render");
255  }
256 
257 
268  void
270  {
271  LuidH anchor{*this};
272  LuidH newSeqID{EntryID<steam::asset::Sequence>().getHash()};
273  invoke (cmd::session_newSequence, anchor, newSeqID);
274  }
275 
276 
292  void
294  {
295  LuidH anchor{*this};
296  LuidH newTrackID{EntryID<steam::mobject::session::Fork>().getHash()};
297  invoke (cmd::sequence_newTrack, anchor, newTrackID);
298  }
299 
300 
302  InteractionDirector::getWorkspaceWindow()
303  {
304  return globalCtx_.windowLoc_.findActiveWindow();
305  }
306 
307 
308  namespace {
324  ID
326  {
327  if (not (spec.data.isNested()
328  and spec.data.get<Rec>().hasAttribute(string{ATTR_fork})
329  and TYPE_Fork == spec.data.get<Rec>().get(string{ATTR_fork}).data.recordType()
330  ) )
331  throw error::State (_Fmt{"When populating a new Timeline, a root track must be given immediately"
332  "nested into INS message. We got the following initialisation payload: %s"}
333  % spec
334  , LERR_(DIFF_STRUCTURE));
335 
336  return spec.data.get<Rec>().get(string{ATTR_fork}).idi;
337  }
338  }
339 
349  {
350  ID rootTrack = verifyDiffStructure_and_extract_RootTrack (spec);
351  TimelineGui anchorProxy{spec.idi, rootTrack};
352 
353  globalCtx_.windowLoc_
354  .locatePanel()
355  .find_or_create<panel::TimelinePanel>()
356  .addTimeline (
357  anchorProxy.buildTimelineWidget (this->uiBus_));
358 
359  globalCtx_.uiManager_.configureStyle (*anchorProxy);
360  return anchorProxy;
361  }
362 
363 
364 
365 
366 }}// namespace stage::interact
void saveSnapshot()
Save a snapshot of the current project&#39;s contents and the UI state.
Access or allocate a UI component view.
smart-Handle as anchor point for "the UI representation" of a timeline.
ID verifyDiffStructure_and_extract_RootTrack(GenNode const &spec)
The timeline is actually a front-end for a binding to some root track.
Helper to pick up typical focus/activity changes, for the purpose of keeping a coherent system of Wor...
TimelineGui injectTimeline(GenNode const &)
Hard wired key constants and basic definitions for communication with the GUI.
void newSequence()
Establish a pristine new sequence within the session.
Access and allocation of UI component views.
bool isNested() const
determine if payload constitutes a nested scope ("object")
Definition: gen-node.hpp:777
Navigating a centre of user activity globally.
Dockable panel to hold timeline widget(s).
Dependency context to hold all the global UI top-level entities.
Under construction: the top level UI controller.
void newTrack()
Establish a empty new track close to the current scope.
void newProject()
setup a new editing project, possibly close the current one.
Sub-Service of the InteractionDirector: Hold and maintain InteractionState.
Front-end for printf-style string template interpolation.
Top level controller for the asset management section in the UI.
typed symbolic and hash ID for asset-like position accounting.
Definition: entry-id.hpp:135
Store and manage persistent interface state.
Definition: ui-state.hpp:84
void buildMutator(lib::diff::TreeMutator::Handle) override
set up a binding to allow some top-level UI state to be treated as part of the session model ...
Common ID definitions for Steam-Layer commands.
Dialog to manage application preferences.
Organisational grouping device within the Session model ("Track" / "Media Bin").
A front-end for using printf-style formatting.
void forkProject()
Continue evolution of the currently active project under a new identity.
MObject within the session to represent "the session itself".
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
void populateContent_afterStart()
ask Session to push up structures for presentation
Attachment point to the UI-Bus.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Structural building block of the session: a sequence of clips.
Dialog to set up a renter process and define output name and format.
The top-level controller to connect model and user interaction state.
Establish and handle persistent interface state.
void editSetup()
Edit global configuration and setup.
Helper to track focus/activation changes to move the activity "Spot" automatically.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
Definition: format-obj.hpp:200
Control and navigate the global centre of activity.
void render()
Start a render process.
The main Lumiera workspace window.
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
Simple functions to represent objects, for debugging and diagnostics.
InteractionDirector(ctrl::GlobalCtx &)
Setup and initialise all representations of "global-ness".
Customisable intermediary to abstract generic tree mutation operations.
Evaluation of UI coordinates against a concrete window topology.
A dialog to choose render output format and name.
Definition: render.hpp:45
A global circle of top-level UI management facilities.
Definition: global-ctx.hpp:79
This file contains the definition of the main workspace window parent, which is the toplevel parent o...
auto collection(COLL &coll)
Entry point to a nested DSL for setup and configuration of a collection binding.
Front-end for simplified access to the current wall clock time.
object-like record of data.
Definition: record.hpp:150
User interface for asset management.
A set of basic GTK includes for the UI.
generic data element node within a tree
Definition: gen-node.hpp:231
void openFile()
Select and open a file to perform a suitable operation.
A dockable container to hold a notebook of timeline displays.
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...