Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TimelineRuler Class Reference

#include "gui/widget/timeline/timeline-ruler.hpp"

Description

A sub-widget of the TimelineWidget.

This class implements a ruler which is placed along the top edge of the timeline.

Definition at line 53 of file timeline-ruler.hpp.

Public Member Functions

 TimelineRuler (gui::widget::TimelineWidget &timeline_widget)
 
void set_mouse_chevron_offset (int offset)
 Sets offset of the mouse chevron. More...
 

Private Member Functions

gavl_time_t calculate_major_spacing () const
 Given the current zoom, this function calculates the preiod between major graduations on the ruler scale. More...
 
void draw_mouse_chevron (Cairo::RefPtr< Cairo::Context > cr, const Gdk::Rectangle ruler_rect)
 Overlays the mouse chevron. More...
 
void draw_playback_period (Cairo::RefPtr< Cairo::Context > cr, const Gdk::Rectangle ruler_rect)
 Overlays the currently selected playback period. More...
 
void draw_playback_point (Cairo::RefPtr< Cairo::Context > cr, const Gdk::Rectangle ruler_rect)
 Overlays the current playback point. More...
 
void draw_ruler (Cairo::RefPtr< Cairo::Context > cr, const Gdk::Rectangle ruler_rect)
 Draws the ruler graduations. More...
 
void draw_selection (Cairo::RefPtr< Cairo::Context > cr, const Gdk::Rectangle ruler_rect)
 Overlays the currently selected period. More...
 
bool on_button_press_event (GdkEventButton *event)
 The event handler for button press events. More...
 
bool on_button_release_event (GdkEventButton *event)
 The event handler for button release events. More...
 
bool on_expose_event (GdkEventExpose *event)
 An event handler for when the window must be redrawn. More...
 
bool on_motion_notify_event (GdkEventMotion *event)
 The event handler for mouse move events. More...
 
void on_realize ()
 An event handler for when the widget is realized. More...
 
void on_size_allocate (Gtk::Allocation &allocation)
 The handler for when the widget must take the size of a given area. More...
 
void on_size_request (Gtk::Requisition *requisition)
 The handler for when the widget must calculate it's new shape. More...
 
void on_state_changed (shared_ptr< TimelineState > newState)
 The event handler for when the TimelineWidget's state is switched. More...
 
void on_update_view ()
 An event handler for when the view window of the timeline changes. More...
 
void propagateStateChange ()
 After notification of a timeline state switch do any local adjustments to adapt to the new state. More...
 
void read_styles ()
 Reads styles from the present stylesheet. More...
 
void register_styles () const
 Registers all the styles that this class will respond to. More...
 
void set_leading_x (const int x)
 As the user drags, this function is called to update the position of the moving end of the playback period. More...
 
TimelineViewWindowviewWindow () const
 Access current timeline view window. More...
 

Private Attributes

int annotationHorzMargin
 
int annotationVertMargin
 
bool isDragging
 This value is set to true if the user is dragging with the left mouse button. More...
 
int majorTickHeight
 
int minDivisionWidth
 
int minorLongTickHeight
 
int minorShortTickHeight
 
int mouseChevronOffset
 The offset from the left of the control in pixels to draw the mouse chevron. More...
 
int mouseChevronSize
 
lib::time::TimeVar pinnedDragTime
 During a selection drag, one end of the selection is moving with the mouse, the other is pinned. More...
 
float playbackPeriodArrowAlpha
 
Cairo::RefPtr
< Cairo::SolidPattern > 
playbackPeriodArrowColour
 
int playbackPeriodArrowSize
 
int playbackPeriodArrowStemSize
 
float playbackPointAlpha
 
Cairo::RefPtr
< Cairo::SolidPattern > 
playbackPointColour
 
int playbackPointSize
 
Cairo::RefPtr
< Cairo::ImageSurface > 
rulerImage
 The caches image of the ruler, over which the chevrons etc. More...
 
int selectionChevronSize
 
shared_ptr< TimelineStatetimelineState
 the currently active timeline state object More...
 
gui::widget::TimelineWidgettimelineWidget
 The owner widget. More...
 

Constructor & Destructor Documentation

Definition at line 56 of file timeline-ruler.cpp.

References TimelineRuler::on_state_changed(), TimelineRuler::register_styles(), and TimelineWidget::state_changed_signal().

+ Here is the call graph for this function:

Member Function Documentation

void set_mouse_chevron_offset ( int  offset)

Sets offset of the mouse chevron.

Parameters
offsetdisplacement of the mouse chevron in pixels from the left edge of the widget. If offset is less than 0 or greater than the width, the chevron will not be visible.

Definition at line 94 of file timeline-ruler.cpp.

References TimelineRuler::mouseChevronOffset.

Referenced by TimelineWidget::on_motion_in_body_notify_event(), and TimelineRuler::on_motion_notify_event().

+ Here is the caller graph for this function:

void on_update_view ( )
private

An event handler for when the view window of the timeline changes.

Remarks
Causes the ruler to be redrawn from scratch. The cached ruler backdrop is destroyed and redrawn.

Definition at line 102 of file timeline-ruler.cpp.

References TimelineRuler::rulerImage.

Referenced by TimelineRuler::propagateStateChange().

+ Here is the caller graph for this function:

void on_realize ( )
private

An event handler for when the widget is realized.

Definition at line 110 of file timeline-ruler.cpp.

References TimelineRuler::read_styles().

+ Here is the call graph for this function:

bool on_expose_event ( GdkEventExpose *  event)
private

An event handler for when the window must be redrawn.

Definition at line 126 of file timeline-ruler.cpp.

References TimelineRuler::draw_mouse_chevron(), TimelineRuler::draw_playback_period(), TimelineRuler::draw_playback_point(), TimelineRuler::draw_ruler(), TimelineRuler::draw_selection(), ENSURE(), NULL, TimelineRuler::rulerImage, and TimelineRuler::timelineState.

+ Here is the call graph for this function:

bool on_button_press_event ( GdkEventButton *  event)
private

The event handler for button press events.

Definition at line 178 of file timeline-ruler.cpp.

References TimelineRuler::isDragging, NULL, TimelineRuler::pinnedDragTime, TimelineRuler::timelineState, TimelineRuler::viewWindow(), and TimelineViewWindow::x_to_time().

+ Here is the call graph for this function:

bool on_button_release_event ( GdkEventButton *  event)
private

The event handler for button release events.

Definition at line 196 of file timeline-ruler.cpp.

References TimelineRuler::isDragging, NULL, TimelineWidget::on_playback_period_drag_released(), and TimelineRuler::timelineWidget.

+ Here is the call graph for this function:

bool on_motion_notify_event ( GdkEventMotion *  event)
private

The event handler for mouse move events.

Definition at line 211 of file timeline-ruler.cpp.

References TimelineRuler::isDragging, NULL, TimelineRuler::set_leading_x(), and TimelineRuler::set_mouse_chevron_offset().

+ Here is the call graph for this function:

void on_size_request ( Gtk::Requisition *  requisition)
private

The handler for when the widget must calculate it's new shape.

Definition at line 225 of file timeline-ruler.cpp.

References NULL.

void on_size_allocate ( Gtk::Allocation &  allocation)
private

The handler for when the widget must take the size of a given area.

Definition at line 238 of file timeline-ruler.cpp.

References TimelineRuler::rulerImage.

void on_state_changed ( shared_ptr< TimelineState newState)
private

The event handler for when the TimelineWidget's state is switched.

Definition at line 246 of file timeline-ruler.cpp.

References TimelineRuler::propagateStateChange(), and TimelineRuler::timelineState.

Referenced by TimelineRuler::TimelineRuler().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void set_leading_x ( const int  x)
private

As the user drags, this function is called to update the position of the moving end of the playback period.

Definition at line 269 of file timeline-ruler.cpp.

References Mutation::changeDuration(), Mutation::changeTime(), TimelineRuler::pinnedDragTime, TimelineRuler::timelineState, and TimelineRuler::viewWindow().

Referenced by TimelineRuler::on_motion_notify_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_ruler ( Cairo::RefPtr< Cairo::Context >  cr,
const Gdk::Rectangle  ruler_rect 
)
private

Draws the ruler graduations.

Parameters
crCairo context to draw the ruler into.
ruler_rectThe area of the ruler widget.

Definition at line 288 of file timeline-ruler.cpp.

References TimelineRuler::annotationHorzMargin, TimelineRuler::annotationVertMargin, TimelineRuler::calculate_major_spacing(), lumiera_tmpbuf_print_time(), TimelineRuler::majorTickHeight, TimelineRuler::minorLongTickHeight, TimelineRuler::minorShortTickHeight, and TimelineRuler::viewWindow().

Referenced by TimelineRuler::on_expose_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_mouse_chevron ( Cairo::RefPtr< Cairo::Context >  cr,
const Gdk::Rectangle  ruler_rect 
)
private

Overlays the mouse chevron.

Parameters
crCairo context to draw the chevron into.
ruler_rectThe area of the ruler widget.

Definition at line 369 of file timeline-ruler.cpp.

References TimelineRuler::mouseChevronOffset, and TimelineRuler::mouseChevronSize.

Referenced by TimelineRuler::on_expose_event().

+ Here is the caller graph for this function:

void draw_selection ( Cairo::RefPtr< Cairo::Context >  cr,
const Gdk::Rectangle  ruler_rect 
)
private

Overlays the currently selected period.

Parameters
crThe Cairo context to draw the selection into.
ruler_rectThe area of the ruler widget.

Definition at line 394 of file timeline-ruler.cpp.

References TimelineRuler::selectionChevronSize, TimelineViewWindow::time_to_x(), and TimelineRuler::timelineState.

Referenced by TimelineRuler::on_expose_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_playback_period ( Cairo::RefPtr< Cairo::Context >  cr,
const Gdk::Rectangle  ruler_rect 
)
private

Overlays the currently selected playback period.

Parameters
crThe Cairo context to draw the period into.
ruler_rectThe area of the ruler widget.

Definition at line 431 of file timeline-ruler.cpp.

References TimelineRuler::playbackPeriodArrowAlpha, TimelineRuler::playbackPeriodArrowColour, TimelineRuler::playbackPeriodArrowSize, TimelineRuler::playbackPeriodArrowStemSize, TimelineViewWindow::time_to_x(), and TimelineRuler::timelineState.

Referenced by TimelineRuler::on_expose_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_playback_point ( Cairo::RefPtr< Cairo::Context >  cr,
const Gdk::Rectangle  ruler_rect 
)
private

Overlays the current playback point.

Parameters
crThe Cairo context to draw the period into.
ruler_rectThe area of the ruler widget.

Definition at line 498 of file timeline-ruler.cpp.

References TimelineRuler::playbackPeriodArrowAlpha, TimelineRuler::playbackPeriodArrowColour, TimelineRuler::playbackPointColour, TimelineRuler::playbackPointSize, TimelineViewWindow::time_to_x(), TimelineRuler::timelineState, and TimelineRuler::viewWindow().

Referenced by TimelineRuler::on_expose_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void propagateStateChange ( )
private

After notification of a timeline state switch do any local adjustments to adapt to the new state.

Definition at line 256 of file timeline-ruler.cpp.

References TimelineViewWindow::changed_signal(), TimelineRuler::on_update_view(), and TimelineRuler::viewWindow().

Referenced by TimelineRuler::on_state_changed().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

gavl_time_t calculate_major_spacing ( ) const
private

Given the current zoom, this function calculates the preiod between major graduations on the ruler scale.

Returns
The period as a gavl_time_t

Definition at line 527 of file timeline-ruler.cpp.

References TimelineViewWindow::get_time_scale(), TimelineRuler::minDivisionWidth, and TimelineRuler::viewWindow().

Referenced by TimelineRuler::draw_ruler().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TimelineViewWindow & viewWindow ( ) const
private

Access current timeline view window.

Definition at line 86 of file timeline-ruler.cpp.

References TimelineRuler::timelineState.

Referenced by TimelineRuler::calculate_major_spacing(), TimelineRuler::draw_playback_point(), TimelineRuler::draw_ruler(), TimelineRuler::on_button_press_event(), TimelineRuler::propagateStateChange(), and TimelineRuler::set_leading_x().

+ Here is the caller graph for this function:

void register_styles ( ) const
private

Registers all the styles that this class will respond to.

Definition at line 572 of file timeline-ruler.cpp.

Referenced by TimelineRuler::TimelineRuler().

+ Here is the caller graph for this function:

void read_styles ( )
private

Reads styles from the present stylesheet.

Definition at line 683 of file timeline-ruler.cpp.

References TimelineRuler::annotationHorzMargin, TimelineRuler::annotationVertMargin, TimelineRuler::majorTickHeight, TimelineRuler::minDivisionWidth, TimelineRuler::minorLongTickHeight, TimelineRuler::minorShortTickHeight, TimelineRuler::mouseChevronSize, TimelineRuler::playbackPeriodArrowAlpha, TimelineRuler::playbackPeriodArrowColour, TimelineRuler::playbackPeriodArrowSize, TimelineRuler::playbackPeriodArrowStemSize, TimelineRuler::playbackPointAlpha, TimelineRuler::playbackPointColour, TimelineRuler::playbackPointSize, StyleManager::readStyleColourProperty(), and TimelineRuler::selectionChevronSize.

Referenced by TimelineRuler::on_realize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool isDragging
private

This value is set to true if the user is dragging with the left mouse button.

Definition at line 199 of file timeline-ruler.hpp.

Referenced by TimelineRuler::on_button_press_event(), TimelineRuler::on_button_release_event(), and TimelineRuler::on_motion_notify_event().

lib::time::TimeVar pinnedDragTime
private

During a selection drag, one end of the selection is moving with the mouse, the other is pinned.

pinnedDragTime specifies the time of that point.

Definition at line 206 of file timeline-ruler.hpp.

Referenced by TimelineRuler::on_button_press_event(), and TimelineRuler::set_leading_x().

int mouseChevronOffset
private

The offset from the left of the control in pixels to draw the mouse chevron.

If offset is less than 0 or greater than the width, the chevron will not be visible.

Definition at line 214 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_mouse_chevron(), and TimelineRuler::set_mouse_chevron_offset().

int annotationHorzMargin
private

Definition at line 217 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_ruler(), and TimelineRuler::read_styles().

int annotationVertMargin
private

Definition at line 218 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_ruler(), and TimelineRuler::read_styles().

int majorTickHeight
private

Definition at line 219 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_ruler(), and TimelineRuler::read_styles().

int minorLongTickHeight
private

Definition at line 220 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_ruler(), and TimelineRuler::read_styles().

int minorShortTickHeight
private

Definition at line 221 of file timeline-ruler.hpp.

Referenced by TimelineRuler::draw_ruler(), and TimelineRuler::read_styles().

int minDivisionWidth
private
int mouseChevronSize
private
int selectionChevronSize
private
Cairo::RefPtr<Cairo::SolidPattern> playbackPointColour
private
float playbackPointAlpha
private

Definition at line 227 of file timeline-ruler.hpp.

Referenced by TimelineRuler::read_styles().

int playbackPointSize
private
Cairo::RefPtr<Cairo::SolidPattern> playbackPeriodArrowColour
private
float playbackPeriodArrowAlpha
private
int playbackPeriodArrowSize
private
int playbackPeriodArrowStemSize
private
gui::widget::TimelineWidget& timelineWidget
private

The owner widget.

Definition at line 238 of file timeline-ruler.hpp.

Referenced by TimelineRuler::on_button_release_event().

Cairo::RefPtr<Cairo::ImageSurface> rulerImage
private

The caches image of the ruler, over which the chevrons etc.

will be drawn.

Remarks
This backdrop is cached because it changes relatively infrequently in comparison to the overlays, thus improving performance somewhat.

Definition at line 252 of file timeline-ruler.hpp.

Referenced by TimelineRuler::on_expose_event(), TimelineRuler::on_size_allocate(), and TimelineRuler::on_update_view().

+ Inheritance diagram for TimelineRuler:
+ Collaboration diagram for TimelineRuler:

The documentation for this class was generated from the following files: