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

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

First release to xenial

File size: 9.7 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file widget_waypointmodel.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 Paul Wise
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/spinbutton.h>
35#include <ETL/stringf>
36#include "widgets/widget_value.h"
37#include "app.h"
38#include <gtkmm/menu.h>
39#include "widgets/widget_time.h"
40#include "widgets/widget_waypointmodel.h"
41#include "general.h"
42
43#endif
44
45using namespace synfig;
46using namespace std;
47using namespace etl;
48using namespace studio;
49
50/* === M A C R O S ========================================================= */
51
52/* === G L O B A L S ======================================================= */
53
54/* === P R O C E D U R E S ================================================= */
55
56/* === M E T H O D S ======================================================= */
57
58Widget_WaypointModel::Widget_WaypointModel():
59        Gtk::Grid(),
60        adj_tension(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
61        adj_continuity(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
62        adj_bias(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
63        adj_temporal_tension(Gtk::Adjustment::create(0.0,-20,20,0.1,1)),
64        checkbutton_after(_("Out:")),
65        checkbutton_before(_("In:")),
66        checkbutton_tension(_("Tension:")),
67        checkbutton_continuity(_("Continuity:")),
68        checkbutton_bias(_("Bias:")),
69        checkbutton_temporal_tension(_("Temporal Tension:"))
70{
71        before_options=manage(new Widget_Enum());
72        before_options->show();
73        before_options->set_param_desc(
74                ParamDesc("interpolation")
75                        .set_hint("enum")
76                        .add_enum_value(INTERPOLATION_CLAMPED,"clamped",_("Clamped"))
77                        .add_enum_value(INTERPOLATION_TCB,"auto",_("TCB"))
78                        .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("Constant"))
79                        .add_enum_value(INTERPOLATION_HALT,"ease",_("Ease In/Out"))
80                        .add_enum_value(INTERPOLATION_LINEAR,"linear",_("Linear"))
81        );
82        before_options->set_icon(0, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_clamped"),Gtk::ICON_SIZE_MENU));
83        before_options->set_icon(1, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_tcb"),Gtk::ICON_SIZE_MENU));
84        before_options->set_icon(2, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_const"),Gtk::ICON_SIZE_MENU));
85        before_options->set_icon(3, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_ease"),Gtk::ICON_SIZE_MENU));
86        before_options->set_icon(4, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_linear"),Gtk::ICON_SIZE_MENU));
87        before_options->set_active(0);
88
89        after_options=manage(new Widget_Enum());
90        after_options->show();
91        after_options->set_param_desc(
92                ParamDesc("interpolation")
93                        .set_hint("enum")
94                        .add_enum_value(INTERPOLATION_CLAMPED,"clamped",_("Clamped"))
95                        .add_enum_value(INTERPOLATION_TCB,"auto",_("TCB"))
96                        .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("Constant"))
97                        .add_enum_value(INTERPOLATION_HALT,"ease",_("Ease In/Out"))
98                        .add_enum_value(INTERPOLATION_LINEAR,"linear",_("Linear"))
99        );
100        after_options->set_icon(0, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_clamped"),Gtk::ICON_SIZE_MENU));
101        after_options->set_icon(1, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_tcb"),Gtk::ICON_SIZE_MENU));
102        after_options->set_icon(2, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_const"),Gtk::ICON_SIZE_MENU));
103        after_options->set_icon(3, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_ease"),Gtk::ICON_SIZE_MENU));
104        after_options->set_icon(4, Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-interpolation_type_linear"),Gtk::ICON_SIZE_MENU));
105        after_options->set_active(0);
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        checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
117        checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
118        checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
119        checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
120        checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
121        checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
122
123        adj_tension->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
124        adj_continuity->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
125        adj_bias->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
126        adj_temporal_tension->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
127
128        before_options->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
129        after_options->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
130
131        set_row_spacing(6);
132        set_column_spacing(12);
133        set_border_width(18);
134
135        // interpolation in
136        attach(checkbutton_before, 0, 0, 1, 1);
137        attach(*before_options, 1, 0, 1,1);
138        before_options->set_hexpand(true);
139        // interpolation out
140        attach(checkbutton_after, 2, 0, 1, 1);
141        attach(*after_options, 3, 0, 1, 1);
142        after_options->set_hexpand(true);
143
144        // tcb options - tension
145        attach(checkbutton_tension, 0, 1, 1, 1);
146        attach(*spin_tension, 1, 1, 1, 1);
147        spin_tension->set_hexpand(true);
148        // tcb options - continuity
149        attach(checkbutton_continuity, 2, 1, 1, 1);
150        attach(*spin_continuity, 3, 1, 1, 1);
151        spin_continuity->set_hexpand(true);
152        // tcb options - bias
153        attach(checkbutton_bias, 0, 2, 1, 1);
154        attach(*spin_bias, 1, 2, 1, 1);
155        spin_bias->set_hexpand(true);
156        // tcb options - temporal tension
157        attach(checkbutton_temporal_tension, 2, 2, 1, 1);
158        attach(*spin_temporal_tension, 3, 2, 1, 1);
159        spin_temporal_tension->set_hexpand(true);
160
161        show_all();
162        hide();
163        updating=false;
164        on_change();
165}
166
167void
168Widget_WaypointModel::on_change()
169{
170        if(updating)
171                return;
172
173        waypoint_model.set_before((Waypoint::Interpolation)before_options->get_value());
174        waypoint_model.set_after((Waypoint::Interpolation)after_options->get_value());
175
176        waypoint_model.set_tension(adj_tension->get_value());
177        waypoint_model.set_continuity(adj_continuity->get_value());
178        waypoint_model.set_bias(adj_bias->get_value());
179        waypoint_model.set_temporal_tension(adj_temporal_tension->get_value());
180
181        waypoint_model.set_before_flag(checkbutton_before.get_active());
182        waypoint_model.set_after_flag(checkbutton_after.get_active());
183        waypoint_model.set_tension_flag(checkbutton_tension.get_active());
184        waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
185        waypoint_model.set_bias_flag(checkbutton_bias.get_active());
186        waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
187
188        before_options->set_sensitive(checkbutton_before.get_active());
189        after_options->set_sensitive(checkbutton_after.get_active());
190        spin_tension->set_sensitive(checkbutton_tension.get_active());
191        spin_continuity->set_sensitive(checkbutton_continuity.get_active());
192        spin_bias->set_sensitive(checkbutton_bias.get_active());
193        spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
194}
195
196
197void
198Widget_WaypointModel::set_waypoint_model (const synfig::Waypoint::Model &x)
199{
200    updating=true;
201    before_options->set_value((int)x.get_before());
202    after_options->set_value((int)x.get_after());
203
204    adj_tension->set_value(x.get_tension());
205    adj_continuity->set_value(x.get_continuity());
206    adj_bias->set_value(x.get_bias());
207    adj_temporal_tension->set_value(x.get_temporal_tension());
208
209    checkbutton_before.set_active(x.get_before_flag());
210    checkbutton_after.set_active(x.get_after_flag());
211    checkbutton_tension.set_active(x.get_tension_flag());
212    checkbutton_continuity.set_active(x.get_continuity_flag());
213    checkbutton_bias.set_active(x.get_bias_flag());
214    checkbutton_temporal_tension.set_active(x.get_temporal_tension_flag());
215    updating=false;
216    on_change();
217}
218
219
220void
221Widget_WaypointModel::reset_waypoint_model()
222{
223    updating=true;
224    waypoint_model.reset();
225
226    before_options->set_value(0);
227    before_options->set_active(0);
228    after_options->set_value(0);
229    after_options->set_active(0);
230
231    adj_tension->set_value(0);
232    adj_continuity->set_value(0);
233    adj_bias->set_value(0);
234    adj_temporal_tension->set_value(0);
235
236    checkbutton_before.set_active(false);
237    checkbutton_after.set_active(false);
238    checkbutton_tension.set_active(false);
239    checkbutton_continuity.set_active(false);
240    checkbutton_bias.set_active(false);
241    checkbutton_temporal_tension.set_active(false);
242    updating=false;
243    on_change();
244}
Note: See TracBrowser for help on using the repository browser.