Extract translatable strings from some more files
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_waypoint.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file widget_waypoint.cpp
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2008 Chris Moore
10 **
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.
15 **
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.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === H E A D E R S ======================================================= */
25
26 #ifdef USING_PCH
27 #       include "pch.h"
28 #else
29 #ifdef HAVE_CONFIG_H
30 #       include <config.h>
31 #endif
32
33 #include <gtkmm/label.h>
34 #include <gtkmm/frame.h>
35 #include <gtkmm/alignment.h>
36 #include "dialog_waypoint.h"
37 #include <gtk/gtk.h>
38 #include <gtkmm/spinbutton.h>
39 #include <gtkmm/combo.h>
40 #include <ETL/stringf>
41 #include "widget_value.h"
42 #include "app.h"
43 #include <gtkmm/menu.h>
44 #include <gtkmm/optionmenu.h>
45 #include "widget_time.h"
46 #include "widget_waypoint.h"
47 #include "general.h"
48
49 #endif
50
51 using namespace synfig;
52 using namespace std;
53 using namespace etl;
54 using namespace studio;
55
56 /* === M A C R O S ========================================================= */
57
58 /* === G L O B A L S ======================================================= */
59
60 /* === P R O C E D U R E S ================================================= */
61
62 /* === M E T H O D S ======================================================= */
63
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)
71 {
72         value_widget=manage(new Widget_ValueBase());
73         value_widget->set_canvas(canvas);
74         value_widget->show();
75
76         value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
77
78
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);
83         //spinbutton->show();
84
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")));
91
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")));
98
99         before=manage(new class Gtk::OptionMenu());
100         before->show();
101         before->set_menu(*before_options);
102
103         after=manage(new class Gtk::OptionMenu());
104         after->show();
105         after->set_menu(*after_options);
106
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));
112         spin_bias->show();
113         spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
114         spin_temporal_tension->show();
115
116         set_padding(12, 12, 12, 12);
117
118         Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
119         add(*widgetBox);
120
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);
125
126         Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
127         waypointPadding->set_padding(6, 0, 24, 0);
128         waypointFrame->add(*waypointPadding);
129
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);
134
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);
141
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);
147
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);
152
153         Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
154         interpolationPadding->set_padding(6, 0, 24, 0);
155         interpolationFrame->add(*interpolationPadding);
156
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);
161
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);
167
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);
173
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);
178
179         Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
180         tcbPadding->set_padding(6, 0, 24, 0);
181         tcbFrame->add(*tcbPadding);
182
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);
187
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);
194
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);
201
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);
208
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);
215
216         show_all();
217         hide();
218         //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
219         set_canvas(canvas);
220 }
221
222 void
223 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
224 {
225         canvas=x;
226         assert(canvas);
227
228         time_widget->set_fps(canvas->rend_desc().get_frame_rate());
229         value_widget->set_canvas(canvas);
230 }
231
232 void
233 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
234 {
235         time_widget->set_fps(canvas->rend_desc().get_frame_rate());
236
237         waypoint=x;
238
239         //! \todo This really needs to be fixed to support value node waypoints!
240         if(waypoint.is_static())
241         {
242                 value_widget->set_value(waypoint.get_value());
243                 value_widget->show();
244                 value_node_label->hide();
245         }
246         else
247         {
248                 value_widget->hide();
249                 value_node_label->show();
250         }
251
252         time_widget->set_value(waypoint.get_time());
253
254         before->set_history((int)waypoint.get_before());
255         after->set_history((int)waypoint.get_after());
256
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());
261
262 }
263 const synfig::Waypoint &
264 Widget_Waypoint::get_waypoint()const
265 {
266         //! \todo This too!
267         waypoint.set_time(time_widget->get_value());
268         if(waypoint.is_static())
269                 waypoint.set_value(value_widget->get_value());
270         //int i;
271
272         waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
273         waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
274
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());
279         return waypoint;
280 }