Lumiera  0.pre.03
»edit your freedom«
timeline-layout.cpp
Go to the documentation of this file.
1 /*
2  TimelineLayout - global timeline layout management and display control
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 
33 #include "stage/gtk-base.hpp"
36 
37 #include "common/advice.hpp"
38 #include "lib/time/timevalue.hpp"
39 
40 using lib::time::Time;
41 using lib::time::FSecs;
43 
44 
45 namespace stage {
46 namespace timeline {
47 
48 
49 
50 
51 
52  TimelineLayout::~TimelineLayout() { }
53 
54  TimelineLayout::TimelineLayout (Gtk::Paned& topLevelContainer)
55  : paneSplitPosition_{topLevelContainer.property_position()}
56  , bodyCanvas_{*this} // inject (as interface DisplayManager)
57  , headerPane_{bodyCanvas_.get_vadjustment()} // wire the patchbay (Gtk::Viewport) to follow the body vertical scroll movement
58  , displayEvaluation_{}
59  {
60  topLevelContainer.add1 (headerPane_);
61  topLevelContainer.add2 (bodyCanvas_);
63  zoomWindow_.attachChangeNotification (signalStructureChange_);
64  // make the ZoomWindow react on changes to the horizontal scrollbar pos
65  bodyCanvas_.get_hadjustment()->property_value().signal_changed().connect(
66  sigc::bind(sigc::mem_fun(*this, &TimelineLayout::syncZoomWindow)
67  ,bodyCanvas_.get_hadjustment()));
68  // make the ZoomWindow react on changes to the window geometry
69  bodyCanvas_.signal_size_allocate().connect(
70  sigc::mem_fun(*this, &TimelineLayout::sizeZoomWindow));
71  }
72 
73 
82  void
84  {
85  headerPane_.installForkRoot (head);
86  bodyCanvas_.installForkRoot (body);
87 
88  // detect changes of the track structure
89  body.signalStructureChange_ = signalStructureChange_;
90  signalStructureChange_(); // this _is_ such a change
91  }
92 
97  void
99  {
100  displayEvaluation_.attach (*this);
101  displayEvaluation_.attach (forkRoot);
102  displayEvaluation_.attach (bodyCanvas_);
103  }
104 
105  Gtk::WidgetPath
106  TimelineLayout::getBodyWidgetPath() const
107  {
108  return bodyCanvas_.get_path();
109  }
110 
111 
112 
113 
119  void
121  {
122  displayEvaluation_.perform();
123  }
124 
129  void
131  {
132  Time windowStart = zoomWindow_.visible().start();
133  int pxOffset = translateTimeToPixels (windowStart);
134  bodyCanvas_.get_hadjustment()->set_value(pxOffset);
135  }
136 
137  void
138  TimelineLayout::completeLayout (DisplayEvaluation&)
139  {
140  /* nothing to do for the collect-phase */
141  }
142 
152  void
154  {
155  double pos = hadj->get_value();
156  TimeValue windowStart = applyScreenDelta(zoomWindow_.overallSpan().start(), pos);
157  zoomWindow_.setVisibleStart (windowStart);
158  }
159 
165  void
166  TimelineLayout::sizeZoomWindow (Gtk::Allocation& alloc)
167  {
168  int contentWidthPx = alloc.get_width();
169  if (abs(contentWidthPx) != zoomWindow_.pxWidth())
170  zoomWindow_.calibrateExtension (contentWidthPx);
171  }
172 
173 
174 
175  /* ==== Interface: ViewHook ===== */
176 
177  void
178  TimelineLayout::hook (TrackHeadWidget& head)
179  {
180  headerPane_.installForkRoot (head);
181  }
182 
183  void
184  TimelineLayout::hook (TrackBody& body)
185  {
186  bodyCanvas_.installForkRoot (body);
187 
188  // detect changes of the track structure
189  body.signalStructureChange_ = signalStructureChange_;
190  signalStructureChange_(); // this _is_ such a change
191  }
192 
193 
194  void
195  TimelineLayout::remove (TrackHeadWidget&)
196  {
197  headerPane_.disable();
198  }
199 
200  void
201  TimelineLayout::remove (TrackBody&)
202  {
203  bodyCanvas_.disable();
204  }
205 
206 
207  void
208  TimelineLayout::rehook (TrackHeadWidget&) noexcept
209  {
210  NOTREACHED ("TimelineLayout: top-Level must not be re-ordered");
211  }
212 
213  void
214  TimelineLayout::rehook (TrackBody&) noexcept
215  {
216  NOTREACHED ("TimelineLayout: top-Level must not be re-ordered");
217  }
218 
219 
220 
221 }}// namespace stage::timeline
Header pane control area corresponding to a Track with nested child Tracks.
void establishLayout(DisplayEvaluation &) override
TimelineLayout also participates itself in the DisplayEvaluation, notably to set up the basic paramet...
void setupStructure(LayoutElement &)
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
void triggerDisplayEvaluation() override
Perform a complete recursive pass over all elements relevant for layout, reestablish size allocation ...
void sizeZoomWindow(Gtk::Allocation &)
Signal receiver (slot) to react on changes of the window screen space allocation. ...
A core service of the timeline UI to ensure consistent display and layout of all components within th...
Visitor and state holder for a collaborative layout adjustment pass.
Expecting Advice and giving Advice: a cross-cutting collaboration of loosely coupled participants...
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
void syncZoomWindow(PAdjustment)
Signal receiver (slot) to react on scrollbar changes.
void installRootTrack(TrackHeadWidget &, TrackBody &)
This function is invoked once for each new TimelineWidget, in order to build the starting point for t...
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:229
Helper to organise and draw the space allocated for a fork of sub-tracks.
Definition: track-body.hpp:95
This helper class serves to manage the layout and display of the horizontally extended space of a "tr...
A time interval anchored at a specific point in time.
Definition: timevalue.hpp:582
a family of time value like entities and their relationships.
basic constant internal time value.
Definition: timevalue.hpp:142
A set of basic GTK includes for the UI.