1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_waypoint.cpp
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include <gtkmm/label.h>
34 #include <gtkmm/frame.h>
35 #include <gtkmm/alignment.h>
36 #include "dialog_waypoint.h"
38 #include <gtkmm/spinbutton.h>
39 #include <gtkmm/combo.h>
40 #include <ETL/stringf>
41 #include "widget_value.h"
43 #include <gtkmm/menu.h>
44 #include <gtkmm/optionmenu.h>
45 #include "widget_time.h"
46 #include "widget_waypoint.h"
51 using namespace synfig
;
54 using namespace studio
;
56 /* === M A C R O S ========================================================= */
58 /* === G L O B A L S ======================================================= */
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
64 Widget_Waypoint::Widget_Waypoint(etl::handle
<synfig::Canvas
> canvas
):
65 Gtk::Alignment(0, 0, 1, 1),
66 waypoint(synfig::ValueBase(),0),
67 adj_tension(0.0,-20,20,0.1,1),
68 adj_continuity(0.0,-20,20,0.1,1),
69 adj_bias(0.0,-20,20,0.1,1),
70 adj_temporal_tension(0.0,-20,20,0.1,1)
72 value_widget
=manage(new Widget_ValueBase());
73 value_widget
->set_canvas(canvas
);
76 value_node_label
=manage(new Gtk::Label(_("(Non-static value)")));
79 time_widget
=manage(new Widget_Time());
80 time_widget
->set_fps(canvas
->rend_desc().get_frame_rate());
81 //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
82 //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
85 before_options
=manage(new class Gtk::Menu());
86 before_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
87 before_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
88 before_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
89 before_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
90 // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
92 after_options
=manage(new class Gtk::Menu());
93 after_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
94 after_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
95 after_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
96 after_options
->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
97 // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
99 before
=manage(new class Gtk::OptionMenu());
101 before
->set_menu(*before_options
);
103 after
=manage(new class Gtk::OptionMenu());
105 after
->set_menu(*after_options
);
107 spin_tension
=manage(new class Gtk::SpinButton(adj_tension
,0.1,3));
108 spin_tension
->show();
109 spin_continuity
=manage(new class Gtk::SpinButton(adj_continuity
,0.1,3));
110 spin_continuity
->show();
111 spin_bias
=manage(new class Gtk::SpinButton(adj_bias
,0.1,3));
113 spin_temporal_tension
=manage(new class Gtk::SpinButton(adj_temporal_tension
,0.1,3));
114 spin_temporal_tension
->show();
116 set_padding(12, 12, 12, 12);
118 Gtk::VBox
*widgetBox
= manage(new Gtk::VBox(false, 12));
121 Gtk::Frame
*waypointFrame
= manage(new Gtk::Frame(_("Waypoint")));
122 waypointFrame
->set_shadow_type(Gtk::SHADOW_NONE
);
123 ((Gtk::Label
*) waypointFrame
->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
124 widgetBox
->pack_start(*waypointFrame
, false, false, 0);
126 Gtk::Alignment
*waypointPadding
= manage(new Gtk::Alignment(0, 0, 1, 1));
127 waypointPadding
->set_padding(6, 0, 24, 0);
128 waypointFrame
->add(*waypointPadding
);
130 Gtk::Table
*waypointTable
= manage(new Gtk::Table(2, 2, false));
131 waypointTable
->set_row_spacings(6);
132 waypointTable
->set_col_spacings(12);
133 waypointPadding
->add(*waypointTable
);
135 Gtk::Label
*waypointValueLabel
= manage(new Gtk::Label(_("_Value"), true));
136 waypointValueLabel
->set_alignment(0, 0.5);
137 waypointValueLabel
->set_mnemonic_widget(*value_widget
);
138 waypointTable
->attach(*waypointValueLabel
, 0, 1, 0, 1, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
139 waypointTable
->attach(*value_widget
, 1, 2, 0, 1, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
140 waypointTable
->attach(*value_node_label
, 1, 2, 0, 1, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
142 Gtk::Label
*waypointTimeLabel
= manage(new Gtk::Label(_("_Time"), true));
143 waypointTimeLabel
->set_alignment(0, 0.5);
144 waypointTimeLabel
->set_mnemonic_widget(*time_widget
);
145 waypointTable
->attach(*waypointTimeLabel
, 0, 1, 1, 2, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
146 waypointTable
->attach(*time_widget
, 1, 2, 1, 2, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
148 Gtk::Frame
*interpolationFrame
= manage(new Gtk::Frame(_("Interpolation")));
149 interpolationFrame
->set_shadow_type(Gtk::SHADOW_NONE
);
150 ((Gtk::Label
*) interpolationFrame
->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
151 widgetBox
->pack_start(*interpolationFrame
, false, false, 0);
153 Gtk::Alignment
*interpolationPadding
= manage(new Gtk::Alignment(0, 0, 1, 1));
154 interpolationPadding
->set_padding(6, 0, 24, 0);
155 interpolationFrame
->add(*interpolationPadding
);
157 Gtk::Table
*interpolationTable
= manage(new Gtk::Table(2, 2, false));
158 interpolationTable
->set_row_spacings(6);
159 interpolationTable
->set_col_spacings(12);
160 interpolationPadding
->add(*interpolationTable
);
162 Gtk::Label
*interpolationInLabel
= manage(new Gtk::Label(_("_In Interpolation"), true));
163 interpolationInLabel
->set_alignment(0, 0.5);
164 interpolationInLabel
->set_mnemonic_widget(*before
);
165 interpolationTable
->attach(*interpolationInLabel
, 0, 1, 0, 1, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
166 interpolationTable
->attach(*before
, 1, 2, 0, 1, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
168 Gtk::Label
*interpolationOutLabel
= manage(new Gtk::Label(_("_Out Interpolation"), true));
169 interpolationOutLabel
->set_alignment(0, 0.5);
170 interpolationOutLabel
->set_mnemonic_widget(*after
);
171 interpolationTable
->attach(*interpolationOutLabel
, 0, 1, 1, 2, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
172 interpolationTable
->attach(*after
, 1, 2, 1, 2, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
174 Gtk::Frame
*tcbFrame
= manage(new Gtk::Frame(_("TCB Parameters")));
175 tcbFrame
->set_shadow_type(Gtk::SHADOW_NONE
);
176 ((Gtk::Label
*) tcbFrame
->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
177 widgetBox
->pack_start(*tcbFrame
, false, false, 0);
179 Gtk::Alignment
*tcbPadding
= manage(new Gtk::Alignment(0, 0, 1, 1));
180 tcbPadding
->set_padding(6, 0, 24, 0);
181 tcbFrame
->add(*tcbPadding
);
183 Gtk::Table
*tcbTable
= manage(new Gtk::Table(4, 2, false));
184 tcbTable
->set_row_spacings(6);
185 tcbTable
->set_col_spacings(12);
186 tcbPadding
->add(*tcbTable
);
188 Gtk::Label
*tensionLabel
= manage(new Gtk::Label(_("T_ension"), true));
189 tensionLabel
->set_alignment(0, 0.5);
190 tensionLabel
->set_mnemonic_widget(*spin_tension
);
191 spin_tension
->set_alignment(1);
192 tcbTable
->attach(*tensionLabel
, 0, 1, 0, 1, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
193 tcbTable
->attach(*spin_tension
, 1, 2, 0, 1, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
195 Gtk::Label
*continuityLabel
= manage(new Gtk::Label(_("_Continuity"), true));
196 continuityLabel
->set_alignment(0, 0.5);
197 continuityLabel
->set_mnemonic_widget(*spin_continuity
);
198 spin_continuity
->set_alignment(1);
199 tcbTable
->attach(*continuityLabel
, 0, 1, 1, 2, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
200 tcbTable
->attach(*spin_continuity
, 1, 2, 1, 2, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
202 Gtk::Label
*biasLabel
= manage(new Gtk::Label(_("_Bias"), true));
203 biasLabel
->set_alignment(0, 0.5);
204 biasLabel
->set_mnemonic_widget(*spin_bias
);
205 spin_bias
->set_alignment(1);
206 tcbTable
->attach(*biasLabel
, 0, 1, 2, 3, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
207 tcbTable
->attach(*spin_bias
, 1, 2, 2, 3, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
209 Gtk::Label
*temporalTensionLabel
= manage(new Gtk::Label(_("Te_mporal Tension"), true));
210 temporalTensionLabel
->set_alignment(0, 0.5);
211 temporalTensionLabel
->set_mnemonic_widget(*spin_temporal_tension
);
212 spin_temporal_tension
->set_alignment(1);
213 tcbTable
->attach(*temporalTensionLabel
, 0, 1, 3, 4, Gtk::SHRINK
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
214 tcbTable
->attach(*spin_temporal_tension
, 1, 2, 3, 4, Gtk::EXPAND
| Gtk::FILL
, Gtk::EXPAND
| Gtk::FILL
, 0, 0);
218 //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
223 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x
)
228 time_widget
->set_fps(canvas
->rend_desc().get_frame_rate());
229 value_widget
->set_canvas(canvas
);
233 Widget_Waypoint::set_waypoint(synfig::Waypoint
&x
)
235 time_widget
->set_fps(canvas
->rend_desc().get_frame_rate());
239 //! \todo This really needs to be fixed to support value node waypoints!
240 if(waypoint
.is_static())
242 value_widget
->set_value(waypoint
.get_value());
243 value_widget
->show();
244 value_node_label
->hide();
248 value_widget
->hide();
249 value_node_label
->show();
252 time_widget
->set_value(waypoint
.get_time());
254 before
->set_history((int)waypoint
.get_before());
255 after
->set_history((int)waypoint
.get_after());
257 adj_tension
.set_value(waypoint
.get_tension());
258 adj_continuity
.set_value(waypoint
.get_continuity());
259 adj_bias
.set_value(waypoint
.get_bias());
260 adj_temporal_tension
.set_value(waypoint
.get_temporal_tension());
263 const synfig::Waypoint
&
264 Widget_Waypoint::get_waypoint()const
267 waypoint
.set_time(time_widget
->get_value());
268 if(waypoint
.is_static())
269 waypoint
.set_value(value_widget
->get_value());
272 waypoint
.set_before((synfig::Waypoint::Interpolation
)before
->get_history());
273 waypoint
.set_after((synfig::Waypoint::Interpolation
)after
->get_history());
275 waypoint
.set_tension(adj_tension
.get_value());
276 waypoint
.set_continuity(adj_continuity
.get_value());
277 waypoint
.set_bias(adj_bias
.get_value());
278 waypoint
.set_temporal_tension(adj_temporal_tension
.get_value());