From c79b28fe7cb678b99da0b3ce81d2ca118054687e Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Thu, 6 Oct 2011 11:58:31 -0500 Subject: [PATCH 01/13] Replacing zoomIn and zoomOut buttons in the TimelinePanel with a new TimelineZoomScale widget --- .../widgets/timeline/timeline-zoom-scale.cpp | 115 ++++++++++++++++++ .../widgets/timeline/timeline-zoom-scale.hpp | 99 +++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 src/gui/widgets/timeline/timeline-zoom-scale.cpp create mode 100644 src/gui/widgets/timeline/timeline-zoom-scale.hpp diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp new file mode 100644 index 000000000..c019d83ed --- /dev/null +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -0,0 +1,115 @@ +/* + timeline-zoom-scale.cpp - Implementation of the zoom scale widget + + Copyright (C) Lumiera.org + 2011, Michael R. Fisher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + +#include "gui/widgets/timeline/timeline-zoom-scale.hpp" +#include "gui/widgets/timeline-widget.hpp" + +using namespace Gtk; + +namespace gui { +namespace widgets { + +class TimelineWidget; + +namespace timeline { + +TimelineZoomScale::TimelineZoomScale() + : HBox() + , adjustment(0.5, 0.0, 1.0, 0.000001) + , slider() + , zoomIn(Stock::ZOOM_IN) + , zoomOut(Stock::ZOOM_OUT) + , smoothing_factor(9.0) + , button_step_size(0.03) +{ + /* Setup the Slider Control */ + slider.set_adjustment(adjustment); + slider.set_size_request(123,10); + slider.set_digits(6); + slider.set_inverted(true); + slider.set_draw_value(false); + + /* Make our connections */ + zoomIn.signal_clicked(). + connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom_in_clicked)); + + zoomOut.signal_clicked(). + connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom_out_clicked)); + + adjustment.signal_value_changed(). + connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom)); + + /* Add Our Widgets and show them */ + pack_start(zoomOut,PACK_SHRINK); + pack_start(slider,PACK_SHRINK); + pack_start(zoomIn,PACK_SHRINK); + + show_all(); +} + +void +TimelineZoomScale::on_zoom_in_clicked() +{ + double newValue = adjustment.get_value() - button_step_size; + adjustment.set_value(newValue); +} + +void +TimelineZoomScale::on_zoom_out_clicked() +{ + double newValue = adjustment.get_value() + button_step_size; + adjustment.set_value(newValue); +} + +void +TimelineZoomScale::on_zoom() +{ + zoomSignal.emit(calculate_zoom_scale()) ; +} + +sigc::signal +TimelineZoomScale::signal_zoom() +{ + return zoomSignal; +} + +int64_t +TimelineZoomScale::calculate_zoom_scale() +{ + int64_t zoom_scale = 0; + + double smoothed = pow(adjustment.get_value(), smoothing_factor); + zoom_scale = (int64_t)( smoothed * (double)TimelineWidget::MaxScale); + + /* Prevent Zooming in To Close and Far */ + if(zoom_scale < 1) + zoom_scale = 1; + + if(zoom_scale > TimelineWidget::MaxScale) + zoom_scale = TimelineWidget::MaxScale; + + return zoom_scale; +} + +} // namespace gui +} // namespace widgets +} // namespace timeline diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.hpp b/src/gui/widgets/timeline/timeline-zoom-scale.hpp new file mode 100644 index 000000000..ebeaaffca --- /dev/null +++ b/src/gui/widgets/timeline/timeline-zoom-scale.hpp @@ -0,0 +1,99 @@ +/* + timeline-zoom-scale.hpp - Declaration of the zoom scale widget + + Copyright (C) Lumiera.org + 2011, Michael R. Fisher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +/** @file timeline-zoom-scale.hpp + ** This file contains the definition of the zoom scale widget + */ + +#ifndef TIMELINE_ZOOM_SCALE_HPP +#define TIMELINE_ZOOM_SCALE_HPP + +#include "gui/gtk-lumiera.hpp" +#include "gui/widgets/mini-button.hpp" + +using namespace Gtk; +using namespace gui::widgets; + +namespace gui { +namespace widgets { +namespace timeline { + +class TimelineZoomScale : public Gtk::HBox +{ +public: + /** + * Constructor + */ + TimelineZoomScale(); + + /** + * Accessor method to the zoomSignal + * @return the zoomSignal + */ + sigc::signal signal_zoom(); + +private: + /* Event Handlers */ + + /** + * Event handler for when the zoomIn Button + * is clicked + */ + void on_zoom_in_clicked(); + + /** + * Event handler for when the zoomIn Button + * is clicked + */ + void on_zoom_out_clicked(); + + /** + * Event handler for when the adjustment + * value is changed + */ + void on_zoom(); + + /** + * Calculate a Zoom Scale value based on + * the adjustment's current value + * @return The Zoom Scale value + */ + int64_t calculate_zoom_scale(); + + /* Widgets */ + Gtk::Adjustment adjustment; + Gtk::HScale slider; + MiniButton zoomIn; + MiniButton zoomOut; + +protected: + /* Signals */ + sigc::signal zoomSignal; + + const double smoothing_factor; + const double button_step_size; +}; + +} // namespace gui +} // namespace widgets +} // namespace timeline + +#endif /* TIMELINE_ZOOM_SCALE_HPP */ From e0463da20450ec97e4ee65bca64a09f0783faa33 Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Thu, 6 Oct 2011 12:38:10 -0500 Subject: [PATCH 02/13] Added TimelineZoomScale widget --- src/gui/panels/timeline-panel.cpp | 16 +++++++++++--- src/gui/panels/timeline-panel.hpp | 4 ++++ src/gui/widgets/timeline-widget.cpp | 10 ++++----- src/gui/widgets/timeline-widget.hpp | 2 +- .../widgets/timeline/timeline-view-window.cpp | 22 +++++++++---------- .../widgets/timeline/timeline-view-window.hpp | 2 +- .../widgets/timeline/timeline-zoom-scale.cpp | 9 ++++++++ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index 07dce7b1d..a9c967403 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -60,6 +60,7 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, , iBeamTool(Gtk::StockID("tool_i_beam")) , zoomIn(Stock::ZOOM_IN) , zoomOut(Stock::ZOOM_OUT) + , zoomScale() , updatingToolbar(false) , currentTool(timeline::Arrow) { @@ -101,9 +102,10 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, toolbar.append(separator2); - toolbar.append(zoomIn, mem_fun(this, &TimelinePanel::on_zoom_in)); - toolbar.append(zoomOut, mem_fun(this, &TimelinePanel::on_zoom_out)); - + toolbar.append(zoomScale); + zoomScale.signal_zoom(). + connect(mem_fun(this,&TimelinePanel::on_zoom)); + toolbar.show_all(); panelBar.pack_start(toolbar, PACK_SHRINK); @@ -183,6 +185,14 @@ TimelinePanel::on_ibeam_tool() set_tool(timeline::IBeam); } +void +TimelinePanel::on_zoom(int64_t zoom_scale) +{ + REQUIRE(timelineWidget); + timelineWidget->zoom_view(zoom_scale); + update_zoom_buttons(); +} + void TimelinePanel::on_zoom_in() { diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index b65469bc9..aac000277 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -32,6 +32,8 @@ #include "gui/panels/panel.hpp" #include "gui/widgets/timecode-widget.hpp" #include "gui/widgets/timeline-widget.hpp" +#include "gui/widgets/timeline/timeline-zoom-scale.hpp" + #include "lib/time/timevalue.hpp" #include @@ -87,6 +89,7 @@ private: void on_arrow_tool(); void on_ibeam_tool(); + void on_zoom(int64_t zoom_size); void on_zoom_in(); void on_zoom_out(); @@ -191,6 +194,7 @@ private: MiniButton zoomIn; MiniButton zoomOut; + gui::widgets::timeline::TimelineZoomScale zoomScale; Gtk::SeparatorToolItem separator2; diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index a00882b7e..cd1459cd8 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -129,13 +129,13 @@ TimelineWidget::set_state(shared_ptr new_state) } void -TimelineWidget::zoom_view(int zoom_size) +TimelineWidget::zoom_view(int64_t zoom_scale) { if(state) - { - const int view_width = body->get_allocation().get_width(); - state->get_view_window().zoom_view(view_width / 2, zoom_size); - } + { + const int view_width = body->get_allocation().get_width(); + state->get_view_window().zoom_view(view_width / 2, zoom_scale); + } } ToolType diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index ca213c15b..b8371534b 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -98,7 +98,7 @@ public: * @param zoom_size The number of steps to zoom by. The scale factor * is 1.25^(-zoom_size). */ - void zoom_view(int zoom_size); + void zoom_view(int64_t zoom_scale); /** * Gets the type of the tool currently active. diff --git a/src/gui/widgets/timeline/timeline-view-window.cpp b/src/gui/widgets/timeline/timeline-view-window.cpp index d9b86597b..004022235 100644 --- a/src/gui/widgets/timeline/timeline-view-window.cpp +++ b/src/gui/widgets/timeline/timeline-view-window.cpp @@ -31,8 +31,6 @@ namespace gui { namespace widgets { namespace timeline { - - TimelineViewWindow::TimelineViewWindow (Offset offset, int64_t scale) : timeOffset(offset) , timeScale(scale) @@ -66,21 +64,21 @@ TimelineViewWindow::set_time_scale(int64_t scale) } void -TimelineViewWindow::zoom_view(int point, int zoom_size) -{ - int64_t new_time_scale = (double)timeScale * pow(1.25, -zoom_size); - +TimelineViewWindow::zoom_view(int point, int64_t zoom_scale) +{ + int64_t new_time_scale = zoom_scale; + // Limit zooming in too close if(new_time_scale < 1) new_time_scale = 1; - - // Nudge zoom problems caused by integer rounding + + /* Not sure if this is still needed. MRF + * // Nudge zoom problems caused by integer rounding if(new_time_scale == timeScale && zoom_size < 0) new_time_scale++; - - // Limit zooming out too far - if(new_time_scale > TimelineWidget::MaxScale) - new_time_scale = TimelineWidget::MaxScale; + */ + // Limit to Min and Max scale code moved to timeline-zoom-scale.cpp + // The view must be shifted so that the zoom is centred on the cursor TimeVar newStartPoint = get_time_offset(); newStartPoint += TimeValue(point * (timeScale - new_time_scale)); diff --git a/src/gui/widgets/timeline/timeline-view-window.hpp b/src/gui/widgets/timeline/timeline-view-window.hpp index 4f1733af8..3bf67ac89 100644 --- a/src/gui/widgets/timeline/timeline-view-window.hpp +++ b/src/gui/widgets/timeline/timeline-view-window.hpp @@ -101,7 +101,7 @@ public: * @param zoom_size The number of steps to zoom by. The scale factor * is 1.25^(-zoom_size). */ - void zoom_view(int point, int zoom_size); + void zoom_view(int point, int64_t zoom_size); /** * Scrolls the view horizontally as a proportion of the view area. diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp index c019d83ed..901df2d7f 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.cpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -32,6 +32,15 @@ class TimelineWidget; namespace timeline { +/** + * TODO: The initial adjustment value needs to + * match what the TimelineViewWindow's actual timeScale + * Value is. TimelineViewWindow::get_time_scale() is + * currently a public method, but will soon be private. + * Maybe TimelineViewWindow can have a zoom_adjustment + * that gets passed to this widget's Constructor? + */ + TimelineZoomScale::TimelineZoomScale() : HBox() , adjustment(0.5, 0.0, 1.0, 0.000001) From caace00dd5cd18d764d4575ce0316cbcda8ed0dc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 7 Oct 2011 03:49:51 +0200 Subject: [PATCH 03/13] Review the new TimelineZoomScale widget code --- src/gui/panels/timeline-panel.cpp | 1 + src/gui/widgets/timeline/timeline-body.cpp | 2 +- .../widgets/timeline/timeline-view-window.cpp | 18 ++++-------------- .../widgets/timeline/timeline-view-window.hpp | 6 +++--- .../widgets/timeline/timeline-zoom-scale.cpp | 17 ++++++++++++++++- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index a9c967403..39c4f5b26 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -124,6 +124,7 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, zoomIn .set_tooltip_text(_("Zoom in")); zoomOut .set_tooltip_text(_("Zoom out")); + zoomScale .set_tooltip_text(_("Adjust timeline zoom scale")); // Setup the timeline widget shared_ptr sequence ///////////////////////////////TICKET #796 diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index 7f78d0929..b0818653a 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -264,7 +264,7 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event) { TimelineViewWindow &window = view_window(); - /////////////////////////////TICKET# 795 : don't reach in from outside and manipulate internals of the timeline view! + /////////////////////////////TICKET #795 : don't reach in from outside and manipulate internals of the timeline view! ///////////////////////////// : either encapsulate this entirely here, or leave it to the timeline view! const int64_t scale = window.get_time_scale(); window.set_time_offset(beginShiftTimeOffset diff --git a/src/gui/widgets/timeline/timeline-view-window.cpp b/src/gui/widgets/timeline/timeline-view-window.cpp index 004022235..84379b17c 100644 --- a/src/gui/widgets/timeline/timeline-view-window.cpp +++ b/src/gui/widgets/timeline/timeline-view-window.cpp @@ -38,20 +38,20 @@ TimelineViewWindow::TimelineViewWindow (Offset offset, int64_t scale) } Offset -TimelineViewWindow::get_time_offset() const /////////////////////TODO: this function shouldn't be accessible from outside +TimelineViewWindow::get_time_offset() const /////////////////////TICKET #795: this function shouldn't be accessible from outside { return Offset (timeOffset); } void -TimelineViewWindow::set_time_offset(TimeValue const& offset) /////////TODO: this function shouldn't be accessible from outside +TimelineViewWindow::set_time_offset(TimeValue const& offset) /////////TICKET #795: this function shouldn't be accessible from outside { timeOffset = offset; changedSignal.emit(); } int64_t -TimelineViewWindow::get_time_scale() const /////////////////////TODO: this function shouldn't be accessible from outside +TimelineViewWindow::get_time_scale() const /////////////////////TICKET #795: this function shouldn't be accessible from outside { return timeScale; } @@ -64,21 +64,11 @@ TimelineViewWindow::set_time_scale(int64_t scale) } void -TimelineViewWindow::zoom_view(int point, int64_t zoom_scale) +TimelineViewWindow::zoom_view(int point, int64_t new_time_scale) { - int64_t new_time_scale = zoom_scale; - // Limit zooming in too close if(new_time_scale < 1) new_time_scale = 1; - /* Not sure if this is still needed. MRF - * // Nudge zoom problems caused by integer rounding - if(new_time_scale == timeScale && zoom_size < 0) - new_time_scale++; - */ - - // Limit to Min and Max scale code moved to timeline-zoom-scale.cpp - // The view must be shifted so that the zoom is centred on the cursor TimeVar newStartPoint = get_time_offset(); newStartPoint += TimeValue(point * (timeScale - new_time_scale)); diff --git a/src/gui/widgets/timeline/timeline-view-window.hpp b/src/gui/widgets/timeline/timeline-view-window.hpp index 3bf67ac89..496085555 100644 --- a/src/gui/widgets/timeline/timeline-view-window.hpp +++ b/src/gui/widgets/timeline/timeline-view-window.hpp @@ -98,10 +98,10 @@ public: /** * Zooms the view in or out as by a number of steps while keeping a * given point on the timeline still. - * @param zoom_size The number of steps to zoom by. The scale factor - * is 1.25^(-zoom_size). + * @param new_time_scale The number of steps to zoom by. The scale factor + * is 1.25^(-new_time_scale). */ - void zoom_view(int point, int64_t zoom_size); + void zoom_view(int point, int64_t new_time_scale); /** * Scrolls the view horizontally as a proportion of the view area. diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp index 901df2d7f..9129a5ce5 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.cpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -33,12 +33,27 @@ class TimelineWidget; namespace timeline { /** - * TODO: The initial adjustment value needs to + * @todo The initial adjustment value needs to * match what the TimelineViewWindow's actual timeScale * Value is. TimelineViewWindow::get_time_scale() is * currently a public method, but will soon be private. * Maybe TimelineViewWindow can have a zoom_adjustment * that gets passed to this widget's Constructor? + * + * @todo actually there is a more involved problem. + * The TimelineWidget maintains a TimelineState, which in turn + * owns the TimelineViewWindow. Now, the problem is: when we + * switch to another Sequence (View), then this TimelineState + * gets switched too, causing also a entirely different TimelineViewWindow + * to become effective. Thus + * - how can we managed to be notified from that switch? + * - problem is: TimelineZoomScale widget is owned by the TimelinePannel. + * Likewise, TimelineWidget is owned by the TimelinePannel. But the + * state handling/switching logic is embedded within TimelineWidget + * - and finally: how can we translate the actual scale (in time units), + * as maintained within TimelineViewWindow, back into the adjustment + * used here (which uses a relative scale 0...1.0 ) + * */ TimelineZoomScale::TimelineZoomScale() From d9f64c94bf5353033db6bf588ebe23550941b10b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 9 Oct 2011 14:52:58 +0200 Subject: [PATCH 04/13] simple demo using a pointer and a struct --- src/tool/try.cpp | 67 +++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/tool/try.cpp b/src/tool/try.cpp index bdfca7100..9e68a90a5 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -19,52 +19,55 @@ // 1/11 - exploring numeric limits // 1/11 - integer floor and wrap operation(s) // 1/11 - how to fetch the path of the own executable -- at least under Linux? - - -#include +// 10/11 - simple demo using a pointer and a struct #include -#include -extern "C" { -#include -} -#include "lib/error.hpp" -#include "lib/symbol.hpp" - - -using std::string; using std::cout; -using std::endl; -using lib::Literal; -using lib::STRING_MAX_RELEVANT; -namespace error = lumiera::error; -Literal GET_PATH_TO_EXECUTABLE ("/proc/self/exe"); -string -catchMyself () -{ - string buff(STRING_MAX_RELEVANT+1, '\0' ); - ssize_t chars_read = readlink (GET_PATH_TO_EXECUTABLE, &buff[0], STRING_MAX_RELEVANT); - - if (0 > chars_read || chars_read == ssize_t(STRING_MAX_RELEVANT)) - throw error::Fatal ("unable to discover path of running executable"); - - buff.resize(chars_read); - return buff; -} +/** + * custom datastructure + * holding a constant char array with "hey" + */ +struct MyStruct + { + char data_[3]; + const int length_; + + MyStruct() + : length_(3) + { + const char *tmp = "hey"; + for (int i=0; ilength_; ++i) + cout << myPointer->data_[i]; + + cout << "\n"; + } + int main (int, char**) //(int argc, char* argv[]) { + printMyStruct (&theStruct); - NOBUG_INIT; - - cout << "\n\nwho am I? :" << catchMyself(); cout << "\n.gulp.\n"; return 0; From 357bfaa674443e5cdd957b1521cdb11c2d2d1075 Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Sun, 9 Oct 2011 12:48:47 -0500 Subject: [PATCH 05/13] Added pointer to TimelineViewWindow in TimelineZoomScroll --- src/gui/panels/timeline-panel.cpp | 13 +++++++++++-- src/gui/widgets/timeline/timeline-zoom-scale.cpp | 5 +++++ src/gui/widgets/timeline/timeline-zoom-scale.hpp | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index 39c4f5b26..8979db727 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -23,6 +23,7 @@ #include "gui/gtk-lumiera.hpp" #include "gui/panels/timeline-panel.hpp" +#include "gui/widgets/timeline/timeline-zoom-scale.hpp" #include "gui/workspace/workspace-window.hpp" #include "gui/model/project.hpp" @@ -34,6 +35,7 @@ using namespace Gtk; using namespace sigc; using namespace gui::widgets; +using namespace gui::widgets::timeline; using namespace gui::model; using boost::shared_ptr; ///////////////////////////////TICKET #796 @@ -131,7 +133,15 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, = *get_project().get_sequences().begin(); timelineWidget.reset(new TimelineWidget(load_state(sequence))); pack_start(*timelineWidget, PACK_EXPAND_WIDGET); - + + // TimelineWidget is now initialized, lets set it in the zoomScale + // and wire it with the timeline state changed signal + zoomScale.set_view_window(timelineWidget->get_state()->get_view_window()); + /* This doesn't work + timelineWidget->signal_state_changed(). + connect(sigc::mem_fun(zoomScale, &TimelineZoomScale::on_timeline_state_changed)); + */ + // Set the initial UI state update_sequence_chooser(); update_tool_buttons(); @@ -139,7 +149,6 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, show_time (Time::ZERO); } - const char* TimelinePanel::get_title() { diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp index 9129a5ce5..d71220f7c 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.cpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -116,6 +116,11 @@ TimelineZoomScale::signal_zoom() return zoomSignal; } +void +TimelineZoomScale::set_view_window(TimelineViewWindow &view_window) +{ + timelineViewWindow =& view_window; +} int64_t TimelineZoomScale::calculate_zoom_scale() { diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.hpp b/src/gui/widgets/timeline/timeline-zoom-scale.hpp index ebeaaffca..512bea9d8 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.hpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.hpp @@ -28,6 +28,7 @@ #include "gui/gtk-lumiera.hpp" #include "gui/widgets/mini-button.hpp" +#include "gui/widgets/timeline/timeline-view-window.hpp" using namespace Gtk; using namespace gui::widgets; @@ -50,6 +51,8 @@ public: */ sigc::signal signal_zoom(); + void set_view_window(TimelineViewWindow &view_window); + private: /* Event Handlers */ @@ -90,6 +93,8 @@ protected: const double smoothing_factor; const double button_step_size; + + TimelineViewWindow *timelineViewWindow; }; } // namespace gui From 5905fdf0cb467d6c86773c0f3b2afa0c0a54b138 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 10 Oct 2011 00:08:50 +0200 Subject: [PATCH 06/13] change definition of TimelineStateChangeSignal the timeline-state-change signal now delivers the new TimelineState object immediately, instead of requiring the listeners to pick it up --- src/gui/panels/timeline-panel.cpp | 6 ++--- src/gui/widgets/timeline-widget.cpp | 4 ++-- src/gui/widgets/timeline-widget.hpp | 13 +++++----- src/gui/widgets/timeline/timeline-body.cpp | 15 +++++++++--- src/gui/widgets/timeline/timeline-body.hpp | 10 +++++--- src/gui/widgets/timeline/timeline-ruler.cpp | 24 ++++++++++++------- src/gui/widgets/timeline/timeline-ruler.hpp | 19 +++++++++++---- .../widgets/timeline/timeline-zoom-scale.cpp | 13 ++++++++++ .../widgets/timeline/timeline-zoom-scale.hpp | 9 +++++++ 9 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index 8979db727..b92554341 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -137,10 +137,8 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, // TimelineWidget is now initialized, lets set it in the zoomScale // and wire it with the timeline state changed signal zoomScale.set_view_window(timelineWidget->get_state()->get_view_window()); - /* This doesn't work - timelineWidget->signal_state_changed(). - connect(sigc::mem_fun(zoomScale, &TimelineZoomScale::on_timeline_state_changed)); - */ + zoomScale.wireTimelineState (timelineWidget->state_changed_signal()); + // Set the initial UI state update_sequence_chooser(); diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index cd1459cd8..038af15b5 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -125,7 +125,7 @@ TimelineWidget::set_state(shared_ptr new_state) update_tracks(); // Send the state changed signal - stateChangedSignal.emit(); + stateChangedSignal.emit (state); } void @@ -178,7 +178,7 @@ TimelineWidget::hovering_track_changed_signal() const return hoveringTrackChangedSignal; } -sigc::signal +TimelineWidget::TimelineStateChangeSignal TimelineWidget::state_changed_signal() const { return stateChangedSignal; diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index b8371534b..b3f801f9a 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -115,14 +115,16 @@ public: public: /* ===== Signals ===== */ + typedef sigc::signal > TimelineStateChangeSignal; + typedef sigc::signal > HoveringTrackChangedSignal; + sigc::signal mouse_hover_signal() const; sigc::signal playback_period_drag_released_signal() const; - sigc::signal > - hovering_track_changed_signal() const; + HoveringTrackChangedSignal hovering_track_changed_signal() const; - sigc::signal state_changed_signal() const; + TimelineStateChangeSignal state_changed_signal() const; /* ===== Events ===== */ protected: @@ -275,9 +277,8 @@ protected: // Signals sigc::signal mouseHoverSignal; sigc::signal playbackPeriodDragReleasedSignal; - sigc::signal > - hoveringTrackChangedSignal; - sigc::signal stateChangedSignal; + HoveringTrackChangedSignal hoveringTrackChangedSignal; + TimelineStateChangeSignal stateChangedSignal; bool update_tracks_frozen; diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index b0818653a..74fed06f7 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -39,6 +39,8 @@ using namespace lumiera; using gui::util::CairoUtil; +using boost::shared_ptr; ////////////////////TICKET #796 + namespace gui { namespace widgets { namespace timeline { @@ -61,7 +63,7 @@ TimelineBody::TimelineBody (TimelineWidget &timelineWidget) register_styles(); // Reset the state - on_state_changed(); + propagateStateChange(); } TimelineBody::~TimelineBody() @@ -294,9 +296,16 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event) } void -TimelineBody::on_state_changed() +TimelineBody::on_state_changed (shared_ptr newState) { - if(timelineWidget.get_state()) + REQUIRE (newState); + timelineState = newState; +} + +void +TimelineBody::propagateStateChange() +{ + if (timelineState) { // Connect up some events view_window().changed_signal().connect( diff --git a/src/gui/widgets/timeline/timeline-body.hpp b/src/gui/widgets/timeline/timeline-body.hpp index 74b057738..f2441da9f 100644 --- a/src/gui/widgets/timeline/timeline-body.hpp +++ b/src/gui/widgets/timeline/timeline-body.hpp @@ -125,10 +125,9 @@ protected: bool on_motion_notify_event(GdkEventMotion *event); /** - * The event handler for when the TimelineWidget's state object is - * replaced. + * The event handler for when the TimelineWidget's state is switched. */ - void on_state_changed(); + void on_state_changed (boost::shared_ptr newState); /* ===== Internals ===== */ private: @@ -161,6 +160,9 @@ private: void set_vertical_offset(int offset); + /** adjust to the new timeline state */ + void propagateStateChange(); + /** * A helper function to get the view window * @remarks This function must not be called unless the TimlineWidget @@ -202,6 +204,8 @@ private: Cairo::RefPtr playbackPointColour; gui::widgets::TimelineWidget &timelineWidget; + boost::shared_ptr timelineState; ////////////////////TICKET #796 : should use std::tr1::shared_ptr + friend class Tool; friend class ArrowTool; diff --git a/src/gui/widgets/timeline/timeline-ruler.cpp b/src/gui/widgets/timeline/timeline-ruler.cpp index afc395710..650c37912 100644 --- a/src/gui/widgets/timeline/timeline-ruler.cpp +++ b/src/gui/widgets/timeline/timeline-ruler.cpp @@ -219,19 +219,27 @@ TimelineRuler::on_size_allocate(Gtk::Allocation& allocation) } void -TimelineRuler::on_state_changed() +TimelineRuler::on_state_changed (shared_ptr newState) { - if(timelineWidget.get_state()) - { - // Connect up some events - view_window().changed_signal().connect( - sigc::mem_fun(this, &TimelineRuler::on_update_view) ); - } - + REQUIRE (newState); + timelineState = newState; + + propagateStateChange(); +} + +void +TimelineRuler::propagateStateChange() +{ + // Connect up some events + view_window().changed_signal().connect( + sigc::mem_fun(this, &TimelineRuler::on_update_view) ); + // Redraw on_update_view(); } + + void TimelineRuler::set_leading_x(const int x) { diff --git a/src/gui/widgets/timeline/timeline-ruler.hpp b/src/gui/widgets/timeline/timeline-ruler.hpp index a7c9b0533..1c2cfbb74 100644 --- a/src/gui/widgets/timeline/timeline-ruler.hpp +++ b/src/gui/widgets/timeline/timeline-ruler.hpp @@ -29,6 +29,7 @@ #include "gui/gtk-lumiera.hpp" #include "lib/time/timevalue.hpp" +#include "gui/widgets/timeline/timeline-state.hpp" namespace gui { namespace widgets { @@ -108,10 +109,9 @@ private: void on_size_allocate(Gtk::Allocation& allocation); /** - * The event handler for when the TimelineWidget's state object is - * replaced. + * The event handler for when the TimelineWidget's state is switched. */ - void on_state_changed(); + void on_state_changed (boost::shared_ptr newState); ////////////////////TICKET #796 : should use std::tr1::shared_ptr private: /* ===== Internal Methods ===== */ @@ -161,7 +161,13 @@ private: */ void draw_playback_point(Cairo::RefPtr cr, const Gdk::Rectangle ruler_rect); - + + /** + * After notification of a timeline state switch + * do any local adjustments to adapt to the new state + */ + void propagateStateChange(); + /** * Given the current zoom, this function calculates the preiod * between major graduations on the ruler scale. @@ -233,6 +239,11 @@ private: */ gui::widgets::TimelineWidget &timelineWidget; + /** + * the currently active timeline state object + */ + boost::shared_ptr timelineState; ////////////////////TICKET #796 : should use std::tr1::shared_ptr + /** * The caches image of the ruler, over which the chevrons etc. will * be drawn. diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp index d71220f7c..7cb6c171f 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.cpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -90,6 +90,19 @@ TimelineZoomScale::TimelineZoomScale() show_all(); } +void +TimelineZoomScale::wireTimelineState (TimelineWidget::TimelineStateChangeSignal stateChangeSignal) +{ + stateChangeSignal.connect (sigc::mem_fun(this, &TimelineZoomScale::on_timeline_state_changed)); +} + +void +TimelineZoomScale::on_timeline_state_changed (boost::shared_ptr newState) +{ + REQUIRE (newState); + UNIMPLEMENTED ("react on the timeline state change"); +} + void TimelineZoomScale::on_zoom_in_clicked() { diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.hpp b/src/gui/widgets/timeline/timeline-zoom-scale.hpp index 512bea9d8..1514e8b77 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.hpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.hpp @@ -28,8 +28,11 @@ #include "gui/gtk-lumiera.hpp" #include "gui/widgets/mini-button.hpp" +#include "gui/widgets/timeline-widget.hpp" #include "gui/widgets/timeline/timeline-view-window.hpp" +#include + using namespace Gtk; using namespace gui::widgets; @@ -52,9 +55,15 @@ public: sigc::signal signal_zoom(); void set_view_window(TimelineViewWindow &view_window); + void wireTimelineState (TimelineWidget::TimelineStateChangeSignal); private: /* Event Handlers */ + + /** + * + */ + void on_timeline_state_changed (boost::shared_ptr newState); ////////////////////TICKET #796 : should use std::tr1::shared_ptr /** * Event handler for when the zoomIn Button From 5fe1debd5beeefb8dfc671bdea9596cf49daec02 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 10 Oct 2011 01:07:10 +0200 Subject: [PATCH 07/13] ZoomScale: rely on the state change signal for the view window --- src/gui/panels/timeline-panel.cpp | 12 ++++++------ src/gui/panels/timeline-panel.hpp | 2 +- .../widgets/timeline/timeline-zoom-scale.cpp | 17 ++++++++++++----- .../widgets/timeline/timeline-zoom-scale.hpp | 12 ++++++++---- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index b92554341..970aa21d4 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -112,7 +112,7 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, panelBar.pack_start(toolbar, PACK_SHRINK); // Setup tooltips - sequenceChooser .set_tooltip_text(_("Change sequence")); + sequenceChooser .set_tooltip_text(_("Change sequence")); previousButton .set_tooltip_text(_("To beginning")); rewindButton .set_tooltip_text(_("Rewind")); @@ -129,15 +129,15 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager, zoomScale .set_tooltip_text(_("Adjust timeline zoom scale")); // Setup the timeline widget - shared_ptr sequence ///////////////////////////////TICKET #796 + shared_ptr sequence ///////////////////////////////TICKET #796 : should use std::tr1::shared_ptr instead of boost = *get_project().get_sequences().begin(); timelineWidget.reset(new TimelineWidget(load_state(sequence))); pack_start(*timelineWidget, PACK_EXPAND_WIDGET); - // TimelineWidget is now initialized, lets set it in the zoomScale - // and wire it with the timeline state changed signal - zoomScale.set_view_window(timelineWidget->get_state()->get_view_window()); - zoomScale.wireTimelineState (timelineWidget->state_changed_signal()); + // since TimelineWidget is now initialised, + // wire the zoom slider to react on timeline state changes + zoomScale.wireTimelineState (timelineWidget->get_state(), + timelineWidget->state_changed_signal()); // Set the initial UI state diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index aac000277..8b165dd79 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -174,7 +174,7 @@ private: boost::scoped_ptr timelineWidget; std::map< boost::weak_ptr, - boost::shared_ptr > ///////////////////////////////TICKET #796 + boost::shared_ptr > ///////////////////////////////TICKET #796 : should use std::tr1::shared_ptr timelineStates; // Toolbar Widgets diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.cpp b/src/gui/widgets/timeline/timeline-zoom-scale.cpp index 7cb6c171f..8d084b525 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.cpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.cpp @@ -91,8 +91,10 @@ TimelineZoomScale::TimelineZoomScale() } void -TimelineZoomScale::wireTimelineState (TimelineWidget::TimelineStateChangeSignal stateChangeSignal) +TimelineZoomScale::wireTimelineState (boost::shared_ptr currentState, + TimelineWidget::TimelineStateChangeSignal stateChangeSignal) { + on_timeline_state_changed (currentState); stateChangeSignal.connect (sigc::mem_fun(this, &TimelineZoomScale::on_timeline_state_changed)); } @@ -100,7 +102,9 @@ void TimelineZoomScale::on_timeline_state_changed (boost::shared_ptr newState) { REQUIRE (newState); - UNIMPLEMENTED ("react on the timeline state change"); + timelineState = newState; + + UNIMPLEMENTED ("react on the timeline state change"); ///////////////////////////TODO } void @@ -129,11 +133,14 @@ TimelineZoomScale::signal_zoom() return zoomSignal; } -void -TimelineZoomScale::set_view_window(TimelineViewWindow &view_window) +TimelineViewWindow& +TimelineZoomScale::getViewWindow() { - timelineViewWindow =& view_window; + REQUIRE (timelineState, "lifecycle error"); + return timelineState->get_view_window(); } + + int64_t TimelineZoomScale::calculate_zoom_scale() { diff --git a/src/gui/widgets/timeline/timeline-zoom-scale.hpp b/src/gui/widgets/timeline/timeline-zoom-scale.hpp index 1514e8b77..9bf5dde9f 100644 --- a/src/gui/widgets/timeline/timeline-zoom-scale.hpp +++ b/src/gui/widgets/timeline/timeline-zoom-scale.hpp @@ -29,6 +29,7 @@ #include "gui/gtk-lumiera.hpp" #include "gui/widgets/mini-button.hpp" #include "gui/widgets/timeline-widget.hpp" +#include "gui/widgets/timeline/timeline-state.hpp" #include "gui/widgets/timeline/timeline-view-window.hpp" #include @@ -54,8 +55,8 @@ public: */ sigc::signal signal_zoom(); - void set_view_window(TimelineViewWindow &view_window); - void wireTimelineState (TimelineWidget::TimelineStateChangeSignal); + void wireTimelineState (boost::shared_ptr currentState, + TimelineWidget::TimelineStateChangeSignal); private: /* Event Handlers */ @@ -83,6 +84,9 @@ private: */ void on_zoom(); + /** access current timeline state */ + TimelineViewWindow& getViewWindow(); + /** * Calculate a Zoom Scale value based on * the adjustment's current value @@ -96,14 +100,14 @@ private: MiniButton zoomIn; MiniButton zoomOut; -protected: +private: /* Signals */ sigc::signal zoomSignal; const double smoothing_factor; const double button_step_size; - TimelineViewWindow *timelineViewWindow; + boost::shared_ptr timelineState; }; } // namespace gui From fb28592082dc8917e19af7f025a3fd734e15f15b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 10 Oct 2011 01:42:03 +0200 Subject: [PATCH 08/13] more cleanup: use the propagated timelineState directly --- src/gui/widgets/timeline/timeline-body.cpp | 54 ++++++++--------- src/gui/widgets/timeline/timeline-body.hpp | 20 +++--- src/gui/widgets/timeline/timeline-ruler.cpp | 67 ++++++++++----------- src/gui/widgets/timeline/timeline-ruler.hpp | 4 +- 4 files changed, 65 insertions(+), 80 deletions(-) diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index 74fed06f7..3bee2110f 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -71,6 +71,13 @@ TimelineBody::~TimelineBody() WARN_IF(!tool, gui, "An invalid tool pointer is unexpected here"); } +TimelineViewWindow& +TimelineBody::viewWindow() const +{ + REQUIRE(timelineState); + return timelineState->get_view_window(); +} + TimelineWidget& TimelineBody::getTimelineWidget () const { @@ -149,7 +156,7 @@ TimelineBody::on_expose_event(GdkEventExpose* event) // Makes sure the widget styles have been loaded read_styles(); - if(timelineWidget.get_state()) + if (timelineState) { // Prepare to render via cairo const Allocation allocation = get_allocation(); @@ -171,9 +178,9 @@ TimelineBody::on_scroll_event (GdkEventScroll* event) { REQUIRE(event != NULL); - if(timelineWidget.get_state()) + if (timelineState) { - TimelineViewWindow &window = view_window(); + TimelineViewWindow &window = viewWindow(); const Allocation allocation = get_allocation(); if(event->state & GDK_CONTROL_MASK) @@ -257,17 +264,16 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event) { REQUIRE(event != NULL); - if(timelineWidget.get_state()) + if (timelineState) { // Handle a middle-mouse drag if one is occuring switch(dragType) { case Shift: { - TimelineViewWindow &window = view_window(); - /////////////////////////////TICKET #795 : don't reach in from outside and manipulate internals of the timeline view! ///////////////////////////// : either encapsulate this entirely here, or leave it to the timeline view! + TimelineViewWindow &window = viewWindow(); const int64_t scale = window.get_time_scale(); window.set_time_offset(beginShiftTimeOffset + TimeValue(scale * (mouseDownX - event->x))); @@ -308,7 +314,7 @@ TimelineBody::propagateStateChange() if (timelineState) { // Connect up some events - view_window().changed_signal().connect( + viewWindow().changed_signal().connect( sigc::mem_fun(this, &TimelineBody::on_update_view) ); } @@ -382,7 +388,7 @@ TimelineBody::draw_track(Cairo::RefPtr cr, // Render the track cr->save(); - TimelineViewWindow &window = view_window(); + TimelineViewWindow &window = viewWindow(); timeline_track->draw_track(cr, &window); cr->restore(); } @@ -395,12 +401,11 @@ TimelineBody::draw_selection(Cairo::RefPtr cr) // Prepare const Allocation allocation = get_allocation(); - shared_ptr state = timelineWidget.get_state(); - REQUIRE(state); + REQUIRE(timelineState); - TimelineViewWindow const& window = state->get_view_window(); - const int start_x = window.time_to_x(state->getSelectionStart()); - const int end_x = window.time_to_x(state->getSelectionEnd()); + TimelineViewWindow const& window = timelineState->get_view_window(); + const int start_x = window.time_to_x(timelineState->getSelectionStart()); + const int end_x = window.time_to_x(timelineState->getSelectionEnd()); // Draw the cover if(end_x > 0 && start_x < allocation.get_width()) @@ -436,16 +441,13 @@ TimelineBody::draw_playback_point(Cairo::RefPtr cr) { REQUIRE(cr); - // Prepare - - shared_ptr state = timelineWidget.get_state(); - if(state) + if (timelineState) { - if (!state->isPlaying()) return; + if (!timelineState->isPlaying()) return; const Allocation allocation = get_allocation(); - Time point = state->getPlaybackPoint(); - const int x = view_window().time_to_x(point); + Time point = timelineState->getPlaybackPoint(); + const int x = viewWindow().time_to_x(point); // Set source cr->set_source(playbackPointColour); @@ -464,10 +466,10 @@ TimelineBody::draw_playback_point(Cairo::RefPtr cr) void TimelineBody::begin_shift_drag() { - if(timelineWidget.get_state()) + if (timelineState) { dragType = Shift; - beginShiftTimeOffset = view_window().get_time_offset(); + beginShiftTimeOffset = viewWindow().get_time_offset(); beginShiftVerticalOffset = get_vertical_offset(); } } @@ -484,14 +486,6 @@ TimelineBody::set_vertical_offset(int offset) timelineWidget.verticalAdjustment.set_value(offset); } -TimelineViewWindow& -TimelineBody::view_window() const -{ - shared_ptr state = timelineWidget.get_state(); - REQUIRE(state); - return state->get_view_window(); -} - void TimelineBody::register_styles() const { diff --git a/src/gui/widgets/timeline/timeline-body.hpp b/src/gui/widgets/timeline/timeline-body.hpp index f2441da9f..aaf90cb2e 100644 --- a/src/gui/widgets/timeline/timeline-body.hpp +++ b/src/gui/widgets/timeline/timeline-body.hpp @@ -68,10 +68,7 @@ public: */ TimelineBody(gui::widgets::TimelineWidget &timeline_widget); - /** - * Destructor - */ - ~TimelineBody(); + virtual ~TimelineBody(); TimelineWidget& getTimelineWidget () const; @@ -131,6 +128,12 @@ protected: /* ===== Internals ===== */ private: + /** + * Access the current timeline view window + * @warning must not be called unless the TimlineWidget + * has a valid state. + */ + TimelineViewWindow& viewWindow() const; /** * Draws the timeline tracks. @@ -162,14 +165,7 @@ private: /** adjust to the new timeline state */ void propagateStateChange(); - - /** - * A helper function to get the view window - * @remarks This function must not be called unless the TimlineWidget - * has a valid state. - */ - TimelineViewWindow& view_window() const; - + /** * Registers all the styles that this class will respond to. */ diff --git a/src/gui/widgets/timeline/timeline-ruler.cpp b/src/gui/widgets/timeline/timeline-ruler.cpp index 650c37912..03a866482 100644 --- a/src/gui/widgets/timeline/timeline-ruler.cpp +++ b/src/gui/widgets/timeline/timeline-ruler.cpp @@ -75,6 +75,14 @@ TimelineRuler::TimelineRuler (TimelineWidget &timeline_widget) register_styles(); } +TimelineViewWindow& +TimelineRuler::viewWindow() const +{ + REQUIRE(timelineState); + return timelineState->get_view_window(); +} + + void TimelineRuler::set_mouse_chevron_offset(int offset) { @@ -114,7 +122,7 @@ TimelineRuler::on_expose_event(GdkEventExpose* event) if(!window) return false; - if(timelineWidget.get_state()) + if (timelineState) { // Prepare to render via cairo const Allocation allocation = get_allocation(); @@ -160,11 +168,11 @@ TimelineRuler::on_button_press_event(GdkEventButton* event) { REQUIRE(event != NULL); - if(timelineWidget.get_state()) + if (timelineState) { if(event->button == 1) { - pinnedDragTime = view_window().x_to_time(event->x); + pinnedDragTime = viewWindow().x_to_time(event->x); isDragging = true; } } @@ -231,7 +239,7 @@ void TimelineRuler::propagateStateChange() { // Connect up some events - view_window().changed_signal().connect( + viewWindow().changed_signal().connect( sigc::mem_fun(this, &TimelineRuler::on_update_view) ); // Redraw @@ -243,18 +251,16 @@ TimelineRuler::propagateStateChange() void TimelineRuler::set_leading_x(const int x) { - shared_ptr state = timelineWidget.get_state(); - - if(state) + if (timelineState) { - TimeVar newStartPoint (view_window().x_to_time(x)); + TimeVar newStartPoint (viewWindow().x_to_time(x)); Offset selectionLength (pinnedDragTime, newStartPoint); if (newStartPoint > pinnedDragTime) newStartPoint=pinnedDragTime; // use the smaller one as selection start - state->setPlaybackPeriod (Mutation::changeTime(newStartPoint) ); - state->setPlaybackPeriod (Mutation::changeDuration(selectionLength)); + timelineState->setPlaybackPeriod (Mutation::changeTime(newStartPoint) ); + timelineState->setPlaybackPeriod (Mutation::changeDuration(selectionLength)); //////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all at once ////////////////////TODO : code duplication with timeline-ibeam-tool 205 } @@ -268,7 +274,7 @@ TimelineRuler::draw_ruler(Cairo::RefPtr cr, REQUIRE(ruler_rect.get_width() > 0); REQUIRE(ruler_rect.get_height() > 0); - const TimelineViewWindow &window = view_window(); + const TimelineViewWindow &window = viewWindow(); const gavl_time_t left_offset = _raw(window.get_time_offset()); const int64_t time_scale = window.get_time_scale(); @@ -369,16 +375,15 @@ TimelineRuler::draw_selection(Cairo::RefPtr cr, REQUIRE(cr); REQUIRE(ruler_rect.get_width() > 0); REQUIRE(ruler_rect.get_height() > 0); + REQUIRE(timelineState); - shared_ptr state = timelineWidget.get_state(); - REQUIRE(state); - const TimelineViewWindow &window = state->get_view_window(); + const TimelineViewWindow &window = timelineState->get_view_window(); Glib::RefPtr