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
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include <gtkmm/label.h>
33 #include <gtkmm/frame.h>
34 #include <gtkmm/alignment.h>
35 #include "dialog_waypoint.h"
37 #include <gtkmm/spinbutton.h>
38 #include <gtkmm/combo.h>
39 #include <ETL/stringf>
40 #include "widget_value.h"
42 #include <gtkmm/menu.h>
43 #include <gtkmm/optionmenu.h>
44 #include "widget_time.h"
45 #include "widget_waypoint.h"
50 using namespace synfig;
53 using namespace studio;
55 /* === M A C R O S ========================================================= */
57 /* === G L O B A L S ======================================================= */
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
64 Gtk::Alignment(0, 0, 1, 1),
65 waypoint(synfig::ValueBase(),0),
66 adj_tension(0.0,-20,20,0.1,1),
67 adj_continuity(0.0,-20,20,0.1,1),
68 adj_bias(0.0,-20,20,0.1,1),
69 adj_temporal_tension(0.0,-20,20,0.1,1)
71 value_widget=manage(new Widget_ValueBase());
72 value_widget->set_canvas(canvas);
75 value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
78 time_widget=manage(new Widget_Time());
79 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
80 //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
81 //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
84 before_options=manage(new class Gtk::Menu());
85 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
86 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
87 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
88 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
89 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
91 after_options=manage(new class Gtk::Menu());
92 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
93 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
94 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
95 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
96 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
98 before=manage(new class Gtk::OptionMenu());
100 before->set_menu(*before_options);
102 after=manage(new class Gtk::OptionMenu());
104 after->set_menu(*after_options);
106 spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
107 spin_tension->show();
108 spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
109 spin_continuity->show();
110 spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
112 spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
113 spin_temporal_tension->show();
115 set_padding(12, 12, 12, 12);
117 Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
120 Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
121 waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
122 ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
123 widgetBox->pack_start(*waypointFrame, false, false, 0);
125 Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
126 waypointPadding->set_padding(6, 0, 24, 0);
127 waypointFrame->add(*waypointPadding);
129 Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
130 waypointTable->set_row_spacings(6);
131 waypointTable->set_col_spacings(12);
132 waypointPadding->add(*waypointTable);
134 Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
135 waypointValueLabel->set_alignment(0, 0.5);
136 waypointValueLabel->set_mnemonic_widget(*value_widget);
137 waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
138 waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
139 waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
141 Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
142 waypointTimeLabel->set_alignment(0, 0.5);
143 waypointTimeLabel->set_mnemonic_widget(*time_widget);
144 waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
145 waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
147 Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
148 interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
149 ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
150 widgetBox->pack_start(*interpolationFrame, false, false, 0);
152 Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
153 interpolationPadding->set_padding(6, 0, 24, 0);
154 interpolationFrame->add(*interpolationPadding);
156 Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
157 interpolationTable->set_row_spacings(6);
158 interpolationTable->set_col_spacings(12);
159 interpolationPadding->add(*interpolationTable);
161 Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
162 interpolationInLabel->set_alignment(0, 0.5);
163 interpolationInLabel->set_mnemonic_widget(*before);
164 interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
165 interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
167 Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
168 interpolationOutLabel->set_alignment(0, 0.5);
169 interpolationOutLabel->set_mnemonic_widget(*after);
170 interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
171 interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
173 Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
174 tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
175 ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
176 widgetBox->pack_start(*tcbFrame, false, false, 0);
178 Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
179 tcbPadding->set_padding(6, 0, 24, 0);
180 tcbFrame->add(*tcbPadding);
182 Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
183 tcbTable->set_row_spacings(6);
184 tcbTable->set_col_spacings(12);
185 tcbPadding->add(*tcbTable);
187 Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
188 tensionLabel->set_alignment(0, 0.5);
189 tensionLabel->set_mnemonic_widget(*spin_tension);
190 spin_tension->set_alignment(1);
191 tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
192 tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
194 Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
195 continuityLabel->set_alignment(0, 0.5);
196 continuityLabel->set_mnemonic_widget(*spin_continuity);
197 spin_continuity->set_alignment(1);
198 tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
199 tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
201 Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
202 biasLabel->set_alignment(0, 0.5);
203 biasLabel->set_mnemonic_widget(*spin_bias);
204 spin_bias->set_alignment(1);
205 tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
206 tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
208 Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
209 temporalTensionLabel->set_alignment(0, 0.5);
210 temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
211 spin_temporal_tension->set_alignment(1);
212 tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
213 tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
217 //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
222 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
227 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
228 value_widget->set_canvas(canvas);
232 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
234 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
238 #warning This really needs to be fixed to support value node waypoints!
239 if(waypoint.is_static())
241 value_widget->set_value(waypoint.get_value());
242 value_widget->show();
243 value_node_label->hide();
247 value_widget->hide();
248 value_node_label->show();
251 time_widget->set_value(waypoint.get_time());
253 before->set_history((int)waypoint.get_before());
254 after->set_history((int)waypoint.get_after());
256 adj_tension.set_value(waypoint.get_tension());
257 adj_continuity.set_value(waypoint.get_continuity());
258 adj_bias.set_value(waypoint.get_bias());
259 adj_temporal_tension.set_value(waypoint.get_temporal_tension());
262 const synfig::Waypoint &
263 Widget_Waypoint::get_waypoint()const
266 waypoint.set_time(time_widget->get_value());
267 if(waypoint.is_static())
268 waypoint.set_value(value_widget->get_value());
271 waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
272 waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
274 waypoint.set_tension(adj_tension.get_value());
275 waypoint.set_continuity(adj_continuity.get_value());
276 waypoint.set_bias(adj_bias.get_value());
277 waypoint.set_temporal_tension(adj_temporal_tension.get_value());