Lumiera  0.pre.03
»edit your freedom«
body-canvas-widget.hpp File Reference

Go to the source code of this file.

Description

Widget to render the body of timeline display, by custom drawing into a canvas control.

The body part of the timeline display can not be sensibly implemented with automatic layout by the UI toolkit set. Rather, we need to control a precise temporal display grid, and we need to limit the actual widgets added for display, since a given timeline may easily hold several hundred up to thousands of elements. To ease such tasks, a canvas control — here implemented on top of Gtk::Layout, allows to combine custom drawing with the placement of embedded child widgets, where the latter's layout is again managed automatically by the toolkit set. This approach allows us to circumvent some of the perils of custom drawing, where we might forfeit several of the benefits of using a toolkit, unintentionally of course, and create an UI which feels foreign and brittle in comparison to standard software.

Layout management

To create a consistent timeline layout, the header pane and body need to react to the same scrolling adjustments, and use the same vertical size allocations for each embedded track. Such a consistent global layout needs to be built up in a display evaluation pass, carried out collaboratively between the building blocks of the timeline. To this end, the TrackPresenter and ClipPresenter elements act as (view) model entities, visited by the timeline::LayoutManager to establish coherent display parameters. From within this evaluation pass, the individual presenters communicate with their slave widgets, which are inserted into the display context of the track header pane or into this body widget respectively. As result, some new widgets may be injected, existing widgets might be removed or hidden, and other widgets may be relocated to different virtual canvas coordinates.

Coordinate systems

When drawing onto a canvas, we need to define the coordinate system. This task is complicated here, since — on implementation level — we end up with several Gtk::Layout elements (the actual canvas widget). This is necessary to accommodate for the display "mechanics": part of the timeline has to stay "pinned" on top, including the time overview ruler and possible further marker displays. Based on practical considerations we decide to handle this situation as follows

  • Each drawing canvas gets its own coordinate system; its extension is defined to match the size of the scrolling area, and coordinates are adjusted so to match drawing primitives and coordinates of attached sub-widgets
  • However, the timeline as a whole constitutes a global coordinate system on its own. It is the actual drawing codes's responsibility to translate into canvas coordinates.
  • To hide those complexities from the display management code, we introduce an abstraction model::ViewHook. This allows to place sub-widgets relative to each track locally. So effectively, from the view point of (sub)widget management, we thus get virtual canvas coordinates per (sub)track.

Definition in file body-canvas-widget.hpp.

Classes

class  BodyCanvasWidget
 Presentation of the timeline workspace by custom drawing on a canvas. More...
 
class  TimelineCanvas
 

Typedefs

using PAdjustment = Glib::RefPtr< Gtk::Adjustment >
 

Namespaces

 stage
 Lumiera GTK UI implementation root.
 
 stage::timeline
 The timeline display and editing operations.