Lumiera  0.pre.03
»edit your freedom«
body-canvas-widget.hpp
Go to the documentation of this file.
1 /*
2  BODY-CANVAS-WIDGET.hpp - custom drawing canvas to display the timeline body
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 
72 #ifndef STAGE_TIMELINE_BODY_CANVAS_WIDGET_H
73 #define STAGE_TIMELINE_BODY_CANVAS_WIDGET_H
74 
75 #include "stage/gtk-base.hpp"
79 
80 #include <functional>
81 
82 
83 
84 namespace stage {
85 namespace timeline {
86 
88 
89  using PAdjustment = Glib::RefPtr<Gtk::Adjustment>;
90  using CairoC = Cairo::RefPtr<Cairo::Context> const&;
91 
92  class DisplayManager;
93  class TrackBody;
94  class TimelineCanvas;
95 
96 
98  : public Gtk::Layout
99  {
100  using _Renderer = std::function<void(CairoC)>;
101 
102  _Renderer renderGrounding_;
103  _Renderer renderOverlay_;
104 
105  public:
106  TimelineCanvas (_Renderer groundingFun, _Renderer overlayFun);
107  virtual ~TimelineCanvas() { }
108 
109  private:
110  virtual bool on_draw (CairoC) override;
111 
112  void openCanvas (CairoC);
113  void closeCanvas (CairoC);
114 
115  void drawGrounding (CairoC);
116  void drawOverlays (CairoC);
117  };
118 
119 
140  : public Gtk::Box
141  , public model::CanvasHook<Gtk::Widget>
142  , public LayoutElement
143  {
144  DisplayManager& layout_;
145  TrackProfile profile_;
146  TrackBody* rootBody_;
147 
148  Gtk::ScrolledWindow contentArea_;
149  Gtk::ScrolledWindow rulerArea_;
150  TimelineCanvas rulerCanvas_;
151  TimelineCanvas mainCanvas_;
152 
153  public:
155  ~BodyCanvasWidget();
156 
158  void installForkRoot (TrackBody& rootTrackBody);
159  void forceRedraw();
160  void disable();
161 
163  auto get_vadjustment() { return contentArea_.get_vadjustment(); }
164  auto get_hadjustment() { return contentArea_.get_hadjustment(); }
165 
166 
167  protected: /* ==== Interface: CanvasHook ===== */
168 
169  void hook (Gtk::Widget&, int xPos=0, int yPos=0) override;
170  void move (Gtk::Widget&, int xPos, int yPos) override;
171  void remove (Gtk::Widget&) override;
172 
173  model::DisplayMetric& getMetric() const override;
174 
175  protected: /* ==== Interface: LayoutElement ===== */
176 
177  void establishLayout (DisplayEvaluation&) override;
178  void completeLayout (DisplayEvaluation&) override;
179 
180  private:/* ===== Internals ===== */
181 
183  using ProfileGetter = std::function<TrackProfile&()>;
184  ProfileGetter getProfile;
185 
186  TimelineCanvas& getCanvas(int yPos);
187  void slotStructureChange() noexcept;
188  void maybeRebuildLayout();
189  void adjustCanvasSize(int canvasWidth, int totalHeight, int rulerHeight);
190  };
191 
192 
193 }}// namespace stage::timeline
194 #endif /*STAGE_TIMELINE_BODY_CANVAS_WIDGET_H*/
void closeCanvas(CairoC)
Finish and close the virtual drawing canvas established by openCanvas().
std::function< TrackProfile &()> ProfileGetter
a way to get and possibly (re)compute the current TrackProfile
Mix-in interface to allow for concrete CanvasHooked widgets to adapt themselves to the metric current...
Definition: canvas-hook.hpp:82
void openCanvas(CairoC)
Prepare the drawing canvas to work within our virtual canvas coordinate system.
Interface to represent _"some presentation layout entity",_ with the ability to place widgets (manage...
A collaboration to establish a globally coherent timeline display layout.
Visitor and state holder for a collaborative layout adjustment pass.
Specialised (abstracted) presentation context with positioning by coordinates.
Description of the structure and arrangement of tracks for display in the UI.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
void drawGrounding(CairoC)
Establish and render the structure of (possibly nested) tracks and overview rulers.
Helper to organise and draw the space allocated for a fork of sub-tracks.
Definition: track-body.hpp:95
Presentation of the timeline workspace by custom drawing on a canvas.
virtual bool on_draw(CairoC) override
Custom drawing of the timeline content area.
Abstraction to build the layout for the track spaces within timeline display.
basic constant internal time value.
Definition: timevalue.hpp:142
A set of basic GTK includes for the UI.
Interface for coordination of the overall timeline display.