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
10 ** Copyright (c) 2008 Paul Wise
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include <gtkmm/label.h>
35 #include <gtkmm/frame.h>
36 #include <gtkmm/alignment.h>
37 #include "dialog_waypoint.h"
39 #include <gtkmm/spinbutton.h>
40 #include <gtkmm/combo.h>
41 #include <ETL/stringf>
42 #include "widget_value.h"
44 #include <gtkmm/menu.h>
45 #include <gtkmm/optionmenu.h>
46 #include "widget_time.h"
47 #include "widget_waypoint.h"
52 using namespace synfig;
55 using namespace studio;
57 /* === M A C R O S ========================================================= */
59 /* === G L O B A L S ======================================================= */
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
65 Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
66 Gtk::Alignment(0, 0, 1, 1),
67 waypoint(synfig::ValueBase(),0),
68 adj_tension(0.0,-20,20,0.1,1),
69 adj_continuity(0.0,-20,20,0.1,1),
70 adj_bias(0.0,-20,20,0.1,1),
71 adj_temporal_tension(0.0,-20,20,0.1,1)
73 value_widget=manage(new Widget_ValueBase());
74 value_widget->set_canvas(canvas);
77 value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
80 time_widget=manage(new Widget_Time());
81 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
82 //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
83 //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
86 before_options=manage(new class Gtk::Menu());
87 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
88 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
89 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
90 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
91 // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
93 after_options=manage(new class Gtk::Menu());
94 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
95 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
96 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
97 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
98 // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
100 before=manage(new class Gtk::OptionMenu());
102 before->set_menu(*before_options);
104 after=manage(new class Gtk::OptionMenu());
106 after->set_menu(*after_options);
108 spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
109 spin_tension->show();
110 spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
111 spin_continuity->show();
112 spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
114 spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
115 spin_temporal_tension->show();
117 set_padding(12, 12, 12, 12);
119 Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
122 Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
123 waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
124 ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
125 widgetBox->pack_start(*waypointFrame, false, false, 0);
127 Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
128 waypointPadding->set_padding(6, 0, 24, 0);
129 waypointFrame->add(*waypointPadding);
131 Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
132 waypointTable->set_row_spacings(6);
133 waypointTable->set_col_spacings(12);
134 waypointPadding->add(*waypointTable);
136 Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
137 waypointValueLabel->set_alignment(0, 0.5);
138 waypointValueLabel->set_mnemonic_widget(*value_widget);
139 waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
140 waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
141 waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
143 Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
144 waypointTimeLabel->set_alignment(0, 0.5);
145 waypointTimeLabel->set_mnemonic_widget(*time_widget);
146 waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
147 waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
149 Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
150 interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
151 ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
152 widgetBox->pack_start(*interpolationFrame, false, false, 0);
154 Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
155 interpolationPadding->set_padding(6, 0, 24, 0);
156 interpolationFrame->add(*interpolationPadding);
158 Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
159 interpolationTable->set_row_spacings(6);
160 interpolationTable->set_col_spacings(12);
161 interpolationPadding->add(*interpolationTable);
163 Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
164 interpolationInLabel->set_alignment(0, 0.5);
165 interpolationInLabel->set_mnemonic_widget(*before);
166 interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
167 interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
169 Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
170 interpolationOutLabel->set_alignment(0, 0.5);
171 interpolationOutLabel->set_mnemonic_widget(*after);
172 interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
173 interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
175 Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
176 tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
177 ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
178 widgetBox->pack_start(*tcbFrame, false, false, 0);
180 Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
181 tcbPadding->set_padding(6, 0, 24, 0);
182 tcbFrame->add(*tcbPadding);
184 Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
185 tcbTable->set_row_spacings(6);
186 tcbTable->set_col_spacings(12);
187 tcbPadding->add(*tcbTable);
189 Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
190 tensionLabel->set_alignment(0, 0.5);
191 tensionLabel->set_mnemonic_widget(*spin_tension);
192 spin_tension->set_alignment(1);
193 tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
194 tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
196 Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
197 continuityLabel->set_alignment(0, 0.5);
198 continuityLabel->set_mnemonic_widget(*spin_continuity);
199 spin_continuity->set_alignment(1);
200 tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
201 tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
203 Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
204 biasLabel->set_alignment(0, 0.5);
205 biasLabel->set_mnemonic_widget(*spin_bias);
206 spin_bias->set_alignment(1);
207 tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
208 tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
210 Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
211 temporalTensionLabel->set_alignment(0, 0.5);
212 temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
213 spin_temporal_tension->set_alignment(1);
214 tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
215 tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
219 //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
224 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
229 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
230 value_widget->set_canvas(canvas);
234 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
236 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
240 //! \todo This really needs to be fixed to support value node waypoints!
241 if(waypoint.is_static())
243 value_widget->set_value(waypoint.get_value());
244 value_widget->show();
245 value_node_label->hide();
249 value_widget->hide();
250 value_node_label->show();
253 time_widget->set_value(waypoint.get_time());
255 before->set_history((int)waypoint.get_before());
256 after->set_history((int)waypoint.get_after());
258 adj_tension.set_value(waypoint.get_tension());
259 adj_continuity.set_value(waypoint.get_continuity());
260 adj_bias.set_value(waypoint.get_bias());
261 adj_temporal_tension.set_value(waypoint.get_temporal_tension());
264 const synfig::Waypoint &
265 Widget_Waypoint::get_waypoint()const
268 waypoint.set_time(time_widget->get_value());
269 if(waypoint.is_static())
270 waypoint.set_value(value_widget->get_value());
273 waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
274 waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
276 waypoint.set_tension(adj_tension.get_value());
277 waypoint.set_continuity(adj_continuity.get_value());
278 waypoint.set_bias(adj_bias.get_value());
279 waypoint.set_temporal_tension(adj_temporal_tension.get_value());