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)
5  2016, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
63 #ifndef STAGE_TIMELINE_BODY_CANVAS_WIDGET_H
64 #define STAGE_TIMELINE_BODY_CANVAS_WIDGET_H
65 
66 #include "stage/gtk-base.hpp"
70 
71 #include <functional>
72 
73 
74 
75 namespace stage {
76 namespace timeline {
77 
79 
80  using PAdjustment = Glib::RefPtr<Gtk::Adjustment>;
81  using CairoC = Cairo::RefPtr<Cairo::Context> const&;
82 
83  class DisplayManager;
84  class TrackBody;
85  class TimelineCanvas;
86 
87 
89  : public Gtk::Layout
90  {
91  using _Renderer = std::function<void(CairoC)>;
92 
93  _Renderer renderGrounding_;
94  _Renderer renderOverlay_;
95 
96  public:
97  TimelineCanvas (_Renderer groundingFun, _Renderer overlayFun);
98  virtual ~TimelineCanvas() { }
99 
100  private:
101  virtual bool on_draw (CairoC) override;
102 
103  void openCanvas (CairoC);
104  void closeCanvas (CairoC);
105 
106  void drawGrounding (CairoC);
107  void drawOverlays (CairoC);
108  };
109 
110 
131  : public Gtk::Box
132  , public model::CanvasHook<Gtk::Widget>
133  , public LayoutElement
134  {
135  DisplayManager& layout_;
136  TrackProfile profile_;
137  TrackBody* rootBody_;
138 
139  Gtk::ScrolledWindow contentArea_;
140  Gtk::ScrolledWindow rulerArea_;
141  TimelineCanvas rulerCanvas_;
142  TimelineCanvas mainCanvas_;
143 
144  public:
146  ~BodyCanvasWidget();
147 
149  void installForkRoot (TrackBody& rootTrackBody);
150  void forceRedraw();
151  void disable();
152 
154  auto get_vadjustment() { return contentArea_.get_vadjustment(); }
155  auto get_hadjustment() { return contentArea_.get_hadjustment(); }
156 
157 
158  protected: /* ==== Interface: CanvasHook ===== */
159 
160  void hook (Gtk::Widget&, int xPos=0, int yPos=0) override;
161  void move (Gtk::Widget&, int xPos, int yPos) override;
162  void remove (Gtk::Widget&) override;
163 
164  model::DisplayMetric& getMetric() const override;
165 
166  protected: /* ==== Interface: LayoutElement ===== */
167 
168  void establishLayout (DisplayEvaluation&) override;
169  void completeLayout (DisplayEvaluation&) override;
170 
171  private:/* ===== Internals ===== */
172 
174  using ProfileGetter = std::function<TrackProfile&()>;
175  ProfileGetter getProfile;
176 
177  TimelineCanvas& getCanvas(int yPos);
178  void slotStructureChange() noexcept;
179  void maybeRebuildLayout();
180  void adjustCanvasSize(int canvasWidth, int totalHeight, int rulerHeight);
181  };
182 
183 
184 }}// namespace stage::timeline
185 #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:73
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:37
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:86
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:133
A set of basic GTK includes for the UI.
Interface for coordination of the overall timeline display.