1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_waypointmodel.cpp
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include <gtkmm/label.h>
33 #include <gtkmm/spinbutton.h>
34 #include <ETL/stringf>
35 #include "widget_value.h"
37 #include <gtkmm/menu.h>
38 #include <gtkmm/optionmenu.h>
39 #include "widget_time.h"
40 #include "widget_waypointmodel.h"
43 using namespace synfig;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 Widget_WaypointModel::Widget_WaypointModel():
57 Gtk::Table(4,3,false),
58 adj_tension(0.0,-20,20,0.1,1),
59 adj_continuity(0.0,-20,20,0.1,1),
60 adj_bias(0.0,-20,20,0.1,1),
61 adj_temporal_tension(0.0,-20,20,0.1,1),
62 checkbutton_after(_("Out:")),
63 checkbutton_before(_("In:")),
64 checkbutton_tension(_("Tension:")),
65 checkbutton_continuity(_("Continuity:")),
66 checkbutton_bias(_("Bias:")),
67 checkbutton_temporal_tension(_("Temporal Tension:"))
69 before_options=manage(new class Gtk::Menu());
70 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
71 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
72 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
73 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
74 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
76 after_options=manage(new class Gtk::Menu());
77 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
78 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
79 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
80 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
81 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
83 before=manage(new class Gtk::OptionMenu());
85 before->set_menu(*before_options);
87 after=manage(new class Gtk::OptionMenu());
89 after->set_menu(*after_options);
91 spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
93 spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
94 spin_continuity->show();
95 spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
97 spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
98 spin_temporal_tension->show();
100 checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
101 checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
102 checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
103 checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
104 checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
105 checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
107 adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
108 adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
109 adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
110 adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
112 before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
113 after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
115 attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
116 attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
117 attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
118 attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
120 attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
121 attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
122 attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
123 attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
124 attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
125 attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
126 attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
127 attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
136 Widget_WaypointModel::on_change()
141 waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
142 waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
144 waypoint_model.set_tension(adj_tension.get_value());
145 waypoint_model.set_continuity(adj_continuity.get_value());
146 waypoint_model.set_bias(adj_bias.get_value());
147 waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
149 waypoint_model.set_before_flag(checkbutton_before.get_active());
150 waypoint_model.set_after_flag(checkbutton_after.get_active());
151 waypoint_model.set_tension_flag(checkbutton_tension.get_active());
152 waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
153 waypoint_model.set_bias_flag(checkbutton_bias.get_active());
154 waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
156 before->set_sensitive(checkbutton_before.get_active());
157 after->set_sensitive(checkbutton_after.get_active());
158 spin_tension->set_sensitive(checkbutton_tension.get_active());
159 spin_continuity->set_sensitive(checkbutton_continuity.get_active());
160 spin_bias->set_sensitive(checkbutton_bias.get_active());
161 spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
165 Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
170 before->set_history((int)waypoint_model.get_before());
171 after->set_history((int)waypoint_model.get_after());
173 adj_tension.set_value(waypoint_model.get_tension());
174 adj_continuity.set_value(waypoint_model.get_continuity());
175 adj_bias.set_value(waypoint_model.get_bias());
176 adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
178 checkbutton_before.set_active(waypoint_model.get_before_flag());
179 checkbutton_after.set_active(waypoint_model.get_after_flag());
180 checkbutton_tension.set_active(waypoint_model.get_tension_flag());
181 checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
182 checkbutton_bias.set_active(waypoint_model.get_bias_flag());
183 checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());