From 4e5e298bbb69dc41473c2e39e10cc6bf88574a02 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 16 Aug 2008 22:06:46 +0100 Subject: [PATCH] Added a time indicator widget --- src/gui/panels/timeline-panel.cpp | 21 +++++++++++++++++++++ src/gui/panels/timeline-panel.hpp | 10 ++++++++++ src/gui/widgets/timeline-widget.cpp | 7 +++++++ src/gui/widgets/timeline-widget.hpp | 6 ++++++ 4 files changed, 44 insertions(+) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index 00a3c3f0f..fb0bace5b 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -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() { diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index 37491c0d9..e2609bf20 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -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; diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index fd22ab3f9..e1931ab5b 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -215,6 +215,12 @@ TimelineWidget::set_tool(ToolType tool_type) body->set_tool(tool_type); } +sigc::signal +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; } diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index 76e4a16d7..aba15cc04 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -132,6 +132,10 @@ public: * Sets the type of the tool currently active. */ void set_tool(timeline::ToolType tool_type); + +public: + /* ===== Signals ===== */ + sigc::signal mouse_hover_signal() const; /* ===== Events ===== */ protected: @@ -179,6 +183,8 @@ protected: Gtk::Adjustment horizontalAdjustment, verticalAdjustment; Gtk::HScrollbar horizontalScroll; Gtk::VScrollbar verticalScroll; + + sigc::signal mouseHoverSignal; /* ===== Constants ===== */ public: