Get rid of all references to the bootstrap script since it was removed
[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 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include <gtkmm/label.h>
33 #include <gtkmm/frame.h>
34 #include <gtkmm/alignment.h>
35 #include "dialog_waypoint.h"
36 #include <gtk/gtk.h>
37 #include <gtkmm/spinbutton.h>
38 #include <gtkmm/combo.h>
39 #include <ETL/stringf>
40 #include "widget_value.h"
41 #include "app.h"
42 #include <gtkmm/menu.h>
43 #include <gtkmm/optionmenu.h>
44 #include "widget_time.h"
45 #include "widget_waypoint.h"
46 #include "general.h"
47
48 #endif
49
50 using namespace synfig;
51 using namespace std;
52 using namespace etl;
53 using namespace studio;
54
55 /* === M A C R O S ========================================================= */
56
57 /* === G L O B A L S ======================================================= */
58
59 /* === P R O C E D U R E S ================================================= */
60
61 /* === M E T H O D S ======================================================= */
62
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)
70 {
71         value_widget=manage(new Widget_ValueBase());
72         value_widget->set_canvas(canvas);
73         value_widget->show();
74
75         value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
76
77
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);
82         //spinbutton->show();
83
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"));
90
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"));
97
98         before=manage(new class Gtk::OptionMenu());
99         before->show();
100         before->set_menu(*before_options);
101
102         after=manage(new class Gtk::OptionMenu());
103         after->show();
104         after->set_menu(*after_options);
105
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));
111         spin_bias->show();
112         spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
113         spin_temporal_tension->show();
114
115         set_padding(12, 12, 12, 12);
116
117         Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
118         add(*widgetBox);
119
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);
124
125         Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
126         waypointPadding->set_padding(6, 0, 24, 0);
127         waypointFrame->add(*waypointPadding);
128
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);
133
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
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);
145
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);
150
151         Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
152         interpolationPadding->set_padding(6, 0, 24, 0);
153         interpolationFrame->add(*interpolationPadding);
154
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);
159
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);
165
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);
171
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);
176
177         Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
178         tcbPadding->set_padding(6, 0, 24, 0);
179         tcbFrame->add(*tcbPadding);
180
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);
185
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);
192
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);
199
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);
206
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);
213
214         show_all();
215         hide();
216         //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
217         set_canvas(canvas);
218 }
219
220 void
221 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
222 {
223         canvas=x;
224         assert(canvas);
225
226         time_widget->set_fps(canvas->rend_desc().get_frame_rate());
227         value_widget->set_canvas(canvas);
228 }
229
230 void
231 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
232 {
233         time_widget->set_fps(canvas->rend_desc().get_frame_rate());
234
235         waypoint=x;
236
237 #warning This really needs to be fixed to support value node waypoints!
238         if(waypoint.is_static())
239         {
240                 value_widget->set_value(waypoint.get_value());
241                 value_widget->show();
242                 value_node_label->hide();
243         }
244         else
245         {
246                 value_widget->hide();
247                 value_node_label->show();
248         }
249
250         time_widget->set_value(waypoint.get_time());
251
252         before->set_history((int)waypoint.get_before());
253         after->set_history((int)waypoint.get_after());
254
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());
259
260 }
261 const synfig::Waypoint &
262 Widget_Waypoint::get_waypoint()const
263 {
264 #warning This too!
265         waypoint.set_time(time_widget->get_value());
266         waypoint.set_value(value_widget->get_value());
267         //int i;
268
269         waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
270         waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
271
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());
276         return waypoint;
277 }