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);
140 Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
141 waypointTimeLabel->set_alignment(0, 0.5);
142 waypointTimeLabel->set_mnemonic_widget(*time_widget);
143 waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
144 waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
146 Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
147 interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
148 ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
149 widgetBox->pack_start(*interpolationFrame, false, false, 0);
151 Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
152 interpolationPadding->set_padding(6, 0, 24, 0);
153 interpolationFrame->add(*interpolationPadding);
155 Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
156 interpolationTable->set_row_spacings(6);
157 interpolationTable->set_col_spacings(12);
158 interpolationPadding->add(*interpolationTable);
160 Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
161 interpolationInLabel->set_alignment(0, 0.5);
162 interpolationInLabel->set_mnemonic_widget(*before);
163 interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
164 interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
166 Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
167 interpolationOutLabel->set_alignment(0, 0.5);
168 interpolationOutLabel->set_mnemonic_widget(*after);
169 interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
170 interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
172 Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
173 tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
174 ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
175 widgetBox->pack_start(*tcbFrame, false, false, 0);
177 Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
178 tcbPadding->set_padding(6, 0, 24, 0);
179 tcbFrame->add(*tcbPadding);
181 Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
182 tcbTable->set_row_spacings(6);
183 tcbTable->set_col_spacings(12);
184 tcbPadding->add(*tcbTable);
186 Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
187 tensionLabel->set_alignment(0, 0.5);
188 tensionLabel->set_mnemonic_widget(*spin_tension);
189 spin_tension->set_alignment(1);
190 tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
191 tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
193 Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
194 continuityLabel->set_alignment(0, 0.5);
195 continuityLabel->set_mnemonic_widget(*spin_continuity);
196 spin_continuity->set_alignment(1);
197 tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
198 tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
200 Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
201 biasLabel->set_alignment(0, 0.5);
202 biasLabel->set_mnemonic_widget(*spin_bias);
203 spin_bias->set_alignment(1);
204 tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
205 tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
207 Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
208 temporalTensionLabel->set_alignment(0, 0.5);
209 temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
210 spin_temporal_tension->set_alignment(1);
211 tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
212 tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
216 //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
221 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
226 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
227 value_widget->set_canvas(canvas);
231 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
233 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
237 #warning This really needs to be fixed to support value node waypoints!
238 if(waypoint.is_static())
240 value_widget->set_value(waypoint.get_value());
241 value_widget->show();
242 value_node_label->hide();
246 value_widget->hide();
247 value_node_label->show();
250 time_widget->set_value(waypoint.get_time());
252 before->set_history((int)waypoint.get_before());
253 after->set_history((int)waypoint.get_after());
255 adj_tension.set_value(waypoint.get_tension());
256 adj_continuity.set_value(waypoint.get_continuity());
257 adj_bias.set_value(waypoint.get_bias());
258 adj_temporal_tension.set_value(waypoint.get_temporal_tension());
261 const synfig::Waypoint &
262 Widget_Waypoint::get_waypoint()const
265 waypoint.set_time(time_widget->get_value());
266 waypoint.set_value(value_widget->get_value());
269 waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
270 waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
272 waypoint.set_tension(adj_tension.get_value());
273 waypoint.set_continuity(adj_continuity.get_value());
274 waypoint.set_bias(adj_bias.get_value());
275 waypoint.set_temporal_tension(adj_temporal_tension.get_value());