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"
48 using namespace synfig;
51 using namespace studio;
53 /* === M A C R O S ========================================================= */
55 /* === G L O B A L S ======================================================= */
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
61 Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
62 Gtk::Alignment(0, 0, 1, 1),
63 waypoint(synfig::ValueBase(),0),
64 adj_tension(0.0,-20,20,0.1,1),
65 adj_continuity(0.0,-20,20,0.1,1),
66 adj_bias(0.0,-20,20,0.1,1),
67 adj_temporal_tension(0.0,-20,20,0.1,1)
69 value_widget=manage(new Widget_ValueBase());
70 value_widget->set_canvas(canvas);
73 value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
76 time_widget=manage(new Widget_Time());
77 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
78 //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
79 //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
82 before_options=manage(new class Gtk::Menu());
83 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
84 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
85 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
86 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
87 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
89 after_options=manage(new class Gtk::Menu());
90 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
91 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
92 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
93 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
94 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
96 before=manage(new class Gtk::OptionMenu());
98 before->set_menu(*before_options);
100 after=manage(new class Gtk::OptionMenu());
102 after->set_menu(*after_options);
104 spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
105 spin_tension->show();
106 spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
107 spin_continuity->show();
108 spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
110 spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
111 spin_temporal_tension->show();
113 set_padding(12, 12, 12, 12);
115 Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
118 Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
119 waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
120 ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
121 widgetBox->pack_start(*waypointFrame, false, false, 0);
123 Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
124 waypointPadding->set_padding(6, 0, 24, 0);
125 waypointFrame->add(*waypointPadding);
127 Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
128 waypointTable->set_row_spacings(6);
129 waypointTable->set_col_spacings(12);
130 waypointPadding->add(*waypointTable);
132 Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
133 waypointValueLabel->set_alignment(0, 0.5);
134 waypointValueLabel->set_mnemonic_widget(*value_widget);
135 waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
136 waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
138 Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
139 waypointTimeLabel->set_alignment(0, 0.5);
140 waypointTimeLabel->set_mnemonic_widget(*time_widget);
141 waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
142 waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
144 Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
145 interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
146 ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
147 widgetBox->pack_start(*interpolationFrame, false, false, 0);
149 Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
150 interpolationPadding->set_padding(6, 0, 24, 0);
151 interpolationFrame->add(*interpolationPadding);
153 Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
154 interpolationTable->set_row_spacings(6);
155 interpolationTable->set_col_spacings(12);
156 interpolationPadding->add(*interpolationTable);
158 Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
159 interpolationInLabel->set_alignment(0, 0.5);
160 interpolationInLabel->set_mnemonic_widget(*before);
161 interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
162 interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
164 Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
165 interpolationOutLabel->set_alignment(0, 0.5);
166 interpolationOutLabel->set_mnemonic_widget(*after);
167 interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
168 interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
170 Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
171 tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
172 ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
173 widgetBox->pack_start(*tcbFrame, false, false, 0);
175 Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
176 tcbPadding->set_padding(6, 0, 24, 0);
177 tcbFrame->add(*tcbPadding);
179 Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
180 tcbTable->set_row_spacings(6);
181 tcbTable->set_col_spacings(12);
182 tcbPadding->add(*tcbTable);
184 Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
185 tensionLabel->set_alignment(0, 0.5);
186 tensionLabel->set_mnemonic_widget(*spin_tension);
187 spin_tension->set_alignment(1);
188 tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
189 tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
191 Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
192 continuityLabel->set_alignment(0, 0.5);
193 continuityLabel->set_mnemonic_widget(*spin_continuity);
194 spin_continuity->set_alignment(1);
195 tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
196 tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
198 Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
199 biasLabel->set_alignment(0, 0.5);
200 biasLabel->set_mnemonic_widget(*spin_bias);
201 spin_bias->set_alignment(1);
202 tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
203 tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
205 Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
206 temporalTensionLabel->set_alignment(0, 0.5);
207 temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
208 spin_temporal_tension->set_alignment(1);
209 tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
210 tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
214 //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
219 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
224 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
225 value_widget->set_canvas(canvas);
229 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
231 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
235 #warning This really needs to be fixed to support value node waypoints!
236 if(waypoint.is_static())
238 value_widget->set_value(waypoint.get_value());
239 value_widget->show();
240 value_node_label->hide();
244 value_widget->hide();
245 value_node_label->show();
248 time_widget->set_value(waypoint.get_time());
250 before->set_history((int)waypoint.get_before());
251 after->set_history((int)waypoint.get_after());
253 adj_tension.set_value(waypoint.get_tension());
254 adj_continuity.set_value(waypoint.get_continuity());
255 adj_bias.set_value(waypoint.get_bias());
256 adj_temporal_tension.set_value(waypoint.get_temporal_tension());
259 const synfig::Waypoint &
260 Widget_Waypoint::get_waypoint()const
263 waypoint.set_time(time_widget->get_value());
264 waypoint.set_value(value_widget->get_value());
267 waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
268 waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
270 waypoint.set_tension(adj_tension.get_value());
271 waypoint.set_continuity(adj_continuity.get_value());
272 waypoint.set_bias(adj_bias.get_value());
273 waypoint.set_temporal_tension(adj_temporal_tension.get_value());