Lumiera  0.pre.03
»edit your freedom«
timeline-zoom-scale.cpp
Go to the documentation of this file.
1 /*
2  TimelineZoomScale - widget to control timeline zoom scale
3 
4  Copyright (C) Lumiera.org
5  2011, Michael R. Fisher <mfisher31@gmail.com>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
33 //#include "stage/widget/timeline-widget.hpp" /////////////////////////////////////////////////////////////TODO old GTK-2 UI is defunct (3/23)
35 
36 using namespace Gtk;
37 
38 namespace stage {
39 namespace widget {
40 
41 class TimelineWidget;
42 
43 namespace timeline {
44 
69  TimelineZoomScale::TimelineZoomScale()
70  : HBox()
71  , adjustment(Gtk::Adjustment::create(0.5, 0.0, 1.0, 0.000001))
72  , slider()
73  , zoomIn(Stock::ZOOM_IN)
74  , zoomOut(Stock::ZOOM_OUT)
75  , button_step_size(0.03)
76  {
77  /* Setup the Slider Control */
78  slider.set_adjustment (adjustment);
79  slider.set_size_request (123,10);
80  slider.set_digits (6);
81 
82  /* Inverted because smaller values "zoom in" */
83  slider.set_inverted (true);
84 
85  slider.set_draw_value (false);
86 
87  /* Make our connections */
88  zoomIn.signal_clicked().
89  connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom_in_clicked));
90  zoomOut.signal_clicked().
91  connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom_out_clicked));
92  adjustment->signal_value_changed().
93  connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom));
94 
95  /* Add Our Widgets and show them */
96  pack_start (zoomOut,PACK_SHRINK);
97  pack_start (slider,PACK_SHRINK);
98  pack_start (zoomIn,PACK_SHRINK);
99 
100  show_all();
101  }
102 
103 
104  void
105  TimelineZoomScale::wireTimelineState (shared_ptr<TimelineState> currentState
106 // TimelineWidget::TimelineStateChangeSignal stateChangeSignal ////////////TODO defunct
107  )
108  {
109  on_timeline_state_changed (currentState);
110 // stateChangeSignal.connect (
111 // sigc::mem_fun(this, &TimelineZoomScale::on_timeline_state_changed));
112  }
113 
114 
115  void
117  {
118  REQUIRE (newState);
119  timelineState = newState;
120 
121 // adjustment->set_value (getViewWindow().get_smoothed_time_scale());
122  }
123 
124 
125  void
127  {
128  double newValue = adjustment->get_value() - button_step_size;
129  adjustment->set_value(newValue);
130  }
131 
132 
133  void
135  {
136  double newValue = adjustment->get_value() + button_step_size;
137  adjustment->set_value(newValue);
138  }
139 
140 
141  void
143  {
144  zoomSignal.emit (adjustment->get_value());
145  }
146 
147 
148  sigc::signal<void, double>
149  TimelineZoomScale::signal_zoom()
150  {
151  return zoomSignal;
152  }
153 
154 
157  {
158  REQUIRE (timelineState, "lifecycle error");
159  return timelineState->getViewWindow();
160  }
161 
162 
163 }}}// namespace stage::widget::timeline
void on_timeline_state_changed(shared_ptr< TimelineState > newState)
Update the slider position when the timeline state is changed.
void on_zoom_in_clicked()
Event handler for when the zoomIn Button is clicked.
void on_zoom_out_clicked()
Event handler for when the zoomIn Button is clicked.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
TimelineViewWindow & getViewWindow()
access current timeline state
Widget to control timeline zoom scale.
void on_zoom()
Event handler for when the adjustment value is changed.