Added TimelineZoomScale widget

This commit is contained in:
Michael R. Fisher 2011-10-06 12:38:10 -05:00 committed by Ichthyostega
parent c79b28fe7c
commit e0463da204
7 changed files with 43 additions and 22 deletions

View file

@ -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()
{

View file

@ -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 <boost/scoped_ptr.hpp>
@ -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;

View file

@ -129,13 +129,13 @@ TimelineWidget::set_state(shared_ptr<timeline::TimelineState> 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

View file

@ -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.

View file

@ -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));

View file

@ -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.

View file

@ -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)