Fixed a bug with body redrawing and added some documentation

This commit is contained in:
Joel Holdsworth 2008-09-02 22:39:53 +01:00
parent b0b436cb92
commit 708aea87bd
6 changed files with 49 additions and 25 deletions

View file

@ -110,7 +110,8 @@ TimelineWidget::set_time_offset(gavl_time_t time_offset)
timeOffset = time_offset;
horizontalAdjustment.set_value(time_offset);
ruler->update_view();
viewChangedSignal.emit();
}
int64_t
@ -129,7 +130,7 @@ TimelineWidget::set_time_scale(int64_t time_scale)
const int view_width = body->get_allocation().get_width();
horizontalAdjustment.set_page_size(timeScale * view_width);
ruler->update_view();
viewChangedSignal.emit();
}
void
@ -261,6 +262,12 @@ TimelineWidget::set_tool(ToolType tool_type)
body->set_tool(tool_type);
}
sigc::signal<void>
TimelineWidget::view_changed_signal() const
{
return viewChangedSignal;
}
sigc::signal<void, gavl_time_t>
TimelineWidget::mouse_hover_signal() const
{
@ -271,7 +278,7 @@ void
TimelineWidget::on_scroll()
{
timeOffset = horizontalAdjustment.get_value();
ruler->update_view();
viewChangedSignal.emit();
}
void

View file

@ -157,6 +157,8 @@ public:
public:
/* ===== Signals ===== */
sigc::signal<void> view_changed_signal() const;
sigc::signal<void, gavl_time_t> mouse_hover_signal() const;
/* ===== Events ===== */
@ -208,10 +210,17 @@ protected:
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
// Signals
sigc::signal<void> viewChangedSignal;
sigc::signal<void, gavl_time_t> mouseHoverSignal;
/* ===== Constants ===== */
public:
/**
* The maximum scale for timeline display.
* @remarks At MaxScale, every pixel on the timeline is equivalent
* to 30000000 gavl_time_t increments.
*/
static const int64_t MaxScale;
protected:

View file

@ -55,10 +55,8 @@ TimelineBody::TimelineBody(lumiera::gui::widgets::TimelineWidget
REQUIRE(timelineWidget != NULL);
// Connect up some events
timelineWidget->horizontalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineBody::on_scroll) );
timelineWidget->verticalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineBody::on_scroll) );
timelineWidget->view_changed_signal().connect(sigc::mem_fun(
this, &TimelineBody::on_update_view) );
// Install style properties
register_styles();
@ -109,6 +107,12 @@ TimelineBody::set_tool(timeline::ToolType tool_type)
tool->apply_cursor();
}
void
TimelineBody::on_update_view()
{
queue_draw();
}
void
TimelineBody::on_realize()
{
@ -217,12 +221,6 @@ TimelineBody::on_expose_event(GdkEventExpose* event)
return true;
}
void
TimelineBody::on_scroll()
{
queue_draw();
}
bool
TimelineBody::on_scroll_event (GdkEventScroll* event)

View file

@ -52,6 +52,9 @@ public:
*/
TimelineBody(lumiera::gui::widgets::TimelineWidget *timeline_widget);
/**
* Destructor
*/
~TimelineBody();
/**
@ -68,6 +71,11 @@ public:
/* ===== Events ===== */
protected:
/**
* An event handler for when the view window of the timeline changes.
*/
void on_update_view();
/**
* An event handler for when the widget is realized.
*/
@ -77,8 +85,6 @@ protected:
* An event handler for when the window must be redrawn.
*/
bool on_expose_event(GdkEventExpose* event);
void on_scroll();
bool on_scroll_event(GdkEventScroll* event);

View file

@ -63,6 +63,10 @@ TimelineRuler::TimelineRuler(
{
REQUIRE(timelineWidget != NULL);
// Connect event handlers
timelineWidget->view_changed_signal().connect(sigc::mem_fun(
this, &TimelineRuler::on_update_view) );
// Install style properties
register_styles();
}
@ -75,7 +79,7 @@ TimelineRuler::set_mouse_chevron_offset(int offset)
}
void
TimelineRuler::update_view()
TimelineRuler::on_update_view()
{
rulerImage.clear();
queue_draw();
@ -222,8 +226,8 @@ TimelineRuler::draw_ruler(Cairo::RefPtr<Cairo::Context> cr,
REQUIRE(ruler_rect.get_height() > 0);
REQUIRE(timelineWidget != NULL);
const gavl_time_t left_offset = timelineWidget->timeOffset;
const int64_t time_scale = timelineWidget->timeScale;
const gavl_time_t left_offset = timelineWidget->get_time_offset();
const int64_t time_scale = timelineWidget->get_time_scale();
// Preparation steps
const int height = ruler_rect.get_height();

View file

@ -59,14 +59,14 @@ public:
*/
void set_mouse_chevron_offset(int offset);
/**
* Causes the ruler to be redrawn from scratch. The cached ruler
* backdrop is destroyed and redrawn.
*/
void update_view();
/* ===== Events ===== */
protected:
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.
*/
void on_update_view();
/**
* An event handler for when the widget is realized.