Lumiera  0.pre.03
»edit your freedom«
timeline-controller.cpp
Go to the documentation of this file.
1 /*
2  TimelineController - coordinate operation of timeline display
3 
4  Copyright (C) Lumiera.org
5  2016, 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 
41 #include "stage/gtk-base.hpp"
42 #include "include/ui-protocol.hpp"
47 
48 //#include "stage/workspace/workspace-window.hpp"
49 //#include "stage/ui-bus.hpp"
50 //#include "lib/format-string.hpp"
51 //#include "lib/format-cout.hpp"
52 
53 //#include "lib/util.hpp"
54 //#include <algorithm>
55 //#include <cstdlib>
56 
57 
58 
59 //using util::_Fmt;
62 using std::make_unique;
63 //using std::shared_ptr;
64 //using std::weak_ptr;
65 //using util::contains;
66 //using Gtk::Widget;
67 //using sigc::mem_fun;
68 //using sigc::ptr_fun;
69 //using std::cout;
70 //using std::endl;
71 
72 
73 namespace stage {
74 namespace timeline {
75 
76 //const int TimelineWidget::TrackPadding = 1;
77 //const int TimelineWidget::HeaderWidth = 150;
78 //const int TimelineWidget::HeaderIndentWidth = 10;
79  class TrackHeadWidget;
80  class TrackBody;
81 
82 
83 
84 
85  TimelineController::TimelineController (ID identity, ID trackID, ctrl::BusTerm& nexus, TimelineLayout& layoutManager)
86  : Controller{identity, nexus}
87  , name_{identity.getSym()} // fallback initialise name from human-readable ID symbol
88  , markers_{}
89  , fork_{new TrackPresenter{trackID, nexus, layoutManager}}
90  {
91  layoutManager.setupStructure (*fork_);
92  }
93 
94 
95  TimelineController::~TimelineController()
96  {
97  }
98 
99 
141  void
143  {
144  using PMarker = unique_ptr<MarkerWidget>;
145  auto rootForkID = fork_->getID();
146 
147  buffer.emplace(
149  .attach (collection(markers_)
150  .isApplicableIf ([&](GenNode const& spec) -> bool
151  { // »Selector« : require object-like sub scope
152  return spec.data.isNested();
153  })
154  .constructFrom ([&](GenNode const& spec) -> PMarker
155  { // »Constructor« : what to do when the diff mentions a new entity
156  return make_unique<MarkerWidget>(spec.idi, this->uiBus_);
157  })
158  .buildChildMutator ([&](PMarker& target, GenNode::ID const&, TreeMutator::Handle buff) -> bool
159  { // »Mutator« : how to apply the diff recursively to a nested scope
160  target->buildMutator (buff); // : delegate to child for building a nested TreeMutator
161  return true;
162  }))
163  .mutateAttrib(rootForkID, [&](TreeMutator::Handle buff)
164  { // »Attribute Mutator« : how to enter the track-fork-object field as nested scope
165  REQUIRE (fork_);
166  fork_->buildMutator(buff);
167  })
168  .change(ATTR_name, [&](string val)
169  { // »Attribute Setter« : how to assign a new value to the name field (object member)
170  name_ = val;
171  }));
172  }
173 
174 
175 
176 }}// namespace stage::timeline
Hard wired key constants and basic definitions for communication with the GUI.
Widget to show a marker at various places.
connection point at the UI-Bus.
Definition: bus-term.hpp:105
bool isNested() const
determine if payload constitutes a nested scope ("object")
Definition: gen-node.hpp:768
Top-level anchor point for the timeline display (widgets).
Presentation control element to model and manage a track within the timeline UI.
TimelineController(ID identity, ID trackID, ctrl::BusTerm &nexus, TimelineLayout &)
Controller to supervise operation of timeline display in the UI.
A View-Model entity to represent a timeline track in the UI.
static Builder< TreeMutator > build()
DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrapp...
SUB & emplace(SUB &&implementation)
move-construct an instance of a subclass into the opaque buffer
A core service of the timeline UI to ensure consistent display and layout of all components within th...
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
Definition: record.hpp:113
virtual void buildMutator(lib::diff::TreeMutator::Handle) override
set up a binding to respond to mutation messages via UiBus
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
auto collection(COLL &coll)
Entry point to a nested DSL for setup and configuration of a collection binding.
A set of basic GTK includes for the UI.
generic data element node within a tree
Definition: gen-node.hpp:231
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...