source: synfigstudio/trunk/fuentes/src/gui/widgets/widget_waypoint.cpp @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 12.1 KB
Line 
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**  Copyright (c) 2008 Paul Wise
11**
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.
16**
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.
21**      \endlegal
22*/
23/* ========================================================================= */
24
25/* === H E A D E R S ======================================================= */
26
27#ifdef USING_PCH
28#       include "pch.h"
29#else
30#ifdef HAVE_CONFIG_H
31#       include <config.h>
32#endif
33
34#include <gtkmm/label.h>
35#include <gtkmm/frame.h>
36#include <gtkmm/alignment.h>
37#include "dialogs/dialog_waypoint.h"
38#include <gtk/gtk.h>
39#include <gtkmm/spinbutton.h>
40#include <gtkmm/combobox.h>
41#include <ETL/stringf>
42#include "widgets/widget_value.h"
43#include "app.h"
44#include <gtkmm/menu.h>
45#include "widgets/widget_time.h"
46#include "widgets/widget_waypoint.h"
47#include "widgets/widget_enum.h"
48#include "general.h"
49//#include <synfig/interpolation.h>
50
51#endif
52
53using namespace synfig;
54using namespace std;
55using namespace etl;
56using namespace studio;
57
58/* === M A C R O S ========================================================= */
59
60/* === G L O B A L S ======================================================= */
61
62/* === P R O C E D U R E S ================================================= */
63
64/* === M E T H O D S ======================================================= */
65
66Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
67        Gtk::Alignment(0, 0, 1, 1),
68        waypoint(synfig::ValueBase(),0),
69        adj_tension(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
70        adj_continuity(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
71        adj_bias(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
72        adj_temporal_tension(Gtk::Adjustment::create(0.0,-20,20,0.1,1))
73{
74        value_widget=manage(new Widget_ValueBase());
75        value_widget->set_canvas(canvas);
76        value_widget->show();
77
78        value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
79
80
81        time_widget=manage(new Widget_Time());
82        time_widget->set_fps(canvas->rend_desc().get_frame_rate());
83
84        before_options=manage(new class Widget_Enum());
85        before_options->show();
86        before_options->set_param_desc(
87                ParamDesc("interpolation")
88                        .set_hint("enum")
89                        .add_enum_value(INTERPOLATION_CLAMPED,"clamped",_("Clamped"))
90                        .add_enum_value(INTERPOLATION_TCB,"auto",_("TCB"))
91                        .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("Constant"))
92                        .add_enum_value(INTERPOLATION_HALT,"ease",_("Ease In/Out"))
93                        .add_enum_value(INTERPOLATION_LINEAR,"linear",_("Linear"))
94        );
95        before_options->set_icon(0, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_clamped"),Gtk::ICON_SIZE_MENU));
96        before_options->set_icon(1, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_tcb"),Gtk::ICON_SIZE_MENU));
97        before_options->set_icon(2, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_const"),Gtk::ICON_SIZE_MENU));
98        before_options->set_icon(3, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_ease"),Gtk::ICON_SIZE_MENU));
99        before_options->set_icon(4, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_linear"),Gtk::ICON_SIZE_MENU));
100
101        after_options=manage(new class Widget_Enum());
102        after_options->show();
103        after_options->set_param_desc(
104                ParamDesc("interpolation")
105                        .set_hint("enum")
106                        .add_enum_value(INTERPOLATION_CLAMPED,"clamped",_("Clamped"))
107                        .add_enum_value(INTERPOLATION_TCB,"auto",_("TCB"))
108                        .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("Constant"))
109                        .add_enum_value(INTERPOLATION_HALT,"ease",_("Ease In/Out"))
110                        .add_enum_value(INTERPOLATION_LINEAR,"linear",_("Linear"))
111        );
112        after_options->set_icon(0, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_clamped"),Gtk::ICON_SIZE_MENU));
113        after_options->set_icon(1, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_tcb"),Gtk::ICON_SIZE_MENU));
114        after_options->set_icon(2, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_const"),Gtk::ICON_SIZE_MENU));
115        after_options->set_icon(3, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_ease"),Gtk::ICON_SIZE_MENU));
116        after_options->set_icon(4, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_linear"),Gtk::ICON_SIZE_MENU));
117
118        spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
119        spin_tension->show();
120        spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
121        spin_continuity->show();
122        spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
123        spin_bias->show();
124        spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
125        spin_temporal_tension->show();
126
127        set_padding(12, 12, 12, 12);
128
129        Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
130        add(*widgetBox);
131
132        Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
133        waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
134        ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
135        widgetBox->pack_start(*waypointFrame, false, false, 0);
136
137        Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
138        waypointPadding->set_padding(6, 0, 24, 0);
139        waypointFrame->add(*waypointPadding);
140
141        Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
142        waypointTable->set_row_spacings(6);
143        waypointTable->set_col_spacings(12);
144        waypointPadding->add(*waypointTable);
145
146        Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
147        waypointValueLabel->set_alignment(0, 0.5);
148        waypointValueLabel->set_mnemonic_widget(*value_widget);
149        waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
150        waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
151        waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
152
153        Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
154        waypointTimeLabel->set_alignment(0, 0.5);
155        waypointTimeLabel->set_mnemonic_widget(*time_widget);
156        waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
157        waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
158
159        Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
160        interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
161        ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
162        widgetBox->pack_start(*interpolationFrame, false, false, 0);
163
164        Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
165        interpolationPadding->set_padding(6, 0, 24, 0);
166        interpolationFrame->add(*interpolationPadding);
167
168        Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
169        interpolationTable->set_row_spacings(6);
170        interpolationTable->set_col_spacings(12);
171        interpolationPadding->add(*interpolationTable);
172
173        Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
174        interpolationInLabel->set_alignment(0, 0.5);
175        interpolationInLabel->set_mnemonic_widget(*before_options);
176        interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
177        interpolationTable->attach(*before_options, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
178
179        Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
180        interpolationOutLabel->set_alignment(0, 0.5);
181        interpolationOutLabel->set_mnemonic_widget(*after_options);
182        interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
183        interpolationTable->attach(*after_options, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
184
185        Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
186        tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
187        ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
188        widgetBox->pack_start(*tcbFrame, false, false, 0);
189
190        Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
191        tcbPadding->set_padding(6, 0, 24, 0);
192        tcbFrame->add(*tcbPadding);
193
194        Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
195        tcbTable->set_row_spacings(6);
196        tcbTable->set_col_spacings(12);
197        tcbPadding->add(*tcbTable);
198
199        Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
200        tensionLabel->set_alignment(0, 0.5);
201        tensionLabel->set_mnemonic_widget(*spin_tension);
202        spin_tension->set_alignment(1);
203        tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
204        tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
205
206        Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
207        continuityLabel->set_alignment(0, 0.5);
208        continuityLabel->set_mnemonic_widget(*spin_continuity);
209        spin_continuity->set_alignment(1);
210        tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
211        tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
212
213        Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
214        biasLabel->set_alignment(0, 0.5);
215        biasLabel->set_mnemonic_widget(*spin_bias);
216        spin_bias->set_alignment(1);
217        tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
218        tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
219
220        Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
221        temporalTensionLabel->set_alignment(0, 0.5);
222        temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
223        spin_temporal_tension->set_alignment(1);
224        tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
225        tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
226
227        show_all();
228        hide();
229        set_canvas(canvas);
230}
231
232void
233Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
234{
235        canvas=x;
236        assert(canvas);
237
238        time_widget->set_fps(canvas->rend_desc().get_frame_rate());
239        value_widget->set_canvas(canvas);
240}
241
242void
243Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
244{
245        time_widget->set_fps(canvas->rend_desc().get_frame_rate());
246
247        waypoint=x;
248
249        //! \todo This really needs to be fixed to support value node waypoints!
250        if(waypoint.is_static())
251        {
252                value_widget->set_value_desc(synfigapp::ValueDesc(etl::handle<ValueNode>(waypoint.get_parent_value_node().get())));
253                value_widget->set_value(waypoint.get_value());
254                value_widget->show();
255                value_node_label->hide();
256        }
257        else
258        {
259                value_widget->hide();
260                value_node_label->show();
261        }
262
263        time_widget->set_value(waypoint.get_time());
264
265        before_options->set_value((Waypoint::Interpolation)waypoint.get_before());
266        after_options->set_value((Waypoint::Interpolation)waypoint.get_after());
267
268        adj_tension->set_value(waypoint.get_tension());
269        adj_continuity->set_value(waypoint.get_continuity());
270        adj_bias->set_value(waypoint.get_bias());
271        adj_temporal_tension->set_value(waypoint.get_temporal_tension());
272
273}
274const synfig::Waypoint &
275Widget_Waypoint::get_waypoint()const
276{
277        //! \todo This too!
278        waypoint.set_time(time_widget->get_value());
279        if(waypoint.is_static())
280                waypoint.set_value(value_widget->get_value());
281
282        waypoint.set_before((Waypoint::Interpolation)before_options->get_value());
283        waypoint.set_after((Waypoint::Interpolation)after_options->get_value());
284
285        waypoint.set_tension(adj_tension->get_value());
286        waypoint.set_continuity(adj_continuity->get_value());
287        waypoint.set_bias(adj_bias->get_value());
288        waypoint.set_temporal_tension(adj_temporal_tension->get_value());
289        return waypoint;
290}
291
292
293
Note: See TracBrowser for help on using the repository browser.