Added a time indicator widget

This commit is contained in:
Joel Holdsworth 2008-08-16 22:06:46 +01:00
parent 574bb5a2fd
commit 4e5e298bbb
4 changed files with 44 additions and 0 deletions

View file

@ -23,6 +23,10 @@
#include "../gtk-lumiera.hpp"
#include "timeline-panel.hpp"
extern "C" {
#include "../../lib/time.h"
}
using namespace Gtk;
using namespace sigc;
using namespace lumiera::gui::widgets;
@ -39,8 +43,13 @@ TimelinePanel::TimelinePanel() :
iBeamTool(Gtk::StockID("tool_i_beam")),
zoomIn(Stock::ZOOM_IN),
zoomOut(Stock::ZOOM_OUT),
timeIndicator(),
updatingToolbar(false)
{
// Setup the widget
timelineWidget.mouse_hover_signal().connect(
mem_fun(this, &TimelinePanel::on_mouse_hover));
// Setup the toolbar
toolbar.append(arrowTool, mem_fun(this,
&TimelinePanel::on_arrow_tool));
@ -50,6 +59,12 @@ TimelinePanel::TimelinePanel() :
toolbar.append(zoomIn, mem_fun(this, &TimelinePanel::on_zoom_in));
toolbar.append(zoomOut, mem_fun(this, &TimelinePanel::on_zoom_out));
seperator2.set_expand(true);
toolbar.append(seperator2);
timeIndicatorButton.set_label_widget(timeIndicator);
toolbar.append(timeIndicatorButton);
toolbar.set_icon_size(IconSize(ICON_SIZE_LARGE_TOOLBAR));
toolbar.set_toolbar_style(TOOLBAR_ICONS);
@ -92,6 +107,12 @@ TimelinePanel::on_zoom_out()
update_zoom_buttons();
}
void
TimelinePanel::on_mouse_hover(gavl_time_t time)
{
timeIndicator.set_text(lumiera_tmpbuf_print_time(time));
}
void
TimelinePanel::update_tool_buttons()
{

View file

@ -55,6 +55,10 @@ private:
void on_zoom_in();
void on_zoom_out();
void on_time_pressed();
void on_mouse_hover(gavl_time_t time);
private:
void update_tool_buttons();
void update_zoom_buttons();
@ -65,6 +69,7 @@ private:
// Widgets
Gtk::Toolbar toolbar;
Gtk::HBox toolStrip;
TimelineWidget timelineWidget;
// Toolbar Widgets
@ -76,6 +81,11 @@ private:
Gtk::ToolButton zoomIn;
Gtk::ToolButton zoomOut;
Gtk::SeparatorToolItem seperator2;
Gtk::Label timeIndicator;
Gtk::ToolButton timeIndicatorButton;
// Internals
bool updatingToolbar;

View file

@ -215,6 +215,12 @@ TimelineWidget::set_tool(ToolType tool_type)
body->set_tool(tool_type);
}
sigc::signal<void, gavl_time_t>
TimelineWidget::mouse_hover_signal() const
{
return mouseHoverSignal;
}
void
TimelineWidget::on_scroll()
{
@ -309,6 +315,7 @@ TimelineWidget::on_motion_in_body_notify_event(GdkEventMotion *event)
{
REQUIRE(event != NULL);
ruler->set_mouse_chevron_offset(event->x);
mouseHoverSignal.emit(x_to_time(event->x));
return true;
}

View file

@ -132,6 +132,10 @@ public:
* Sets the type of the tool currently active.
*/
void set_tool(timeline::ToolType tool_type);
public:
/* ===== Signals ===== */
sigc::signal<void, gavl_time_t> mouse_hover_signal() const;
/* ===== Events ===== */
protected:
@ -179,6 +183,8 @@ protected:
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
sigc::signal<void, gavl_time_t> mouseHoverSignal;
/* ===== Constants ===== */
public: