Get rid of all references to the bootstrap script since it was removed
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_waypointmodel.cpp
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 **
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/spinbutton.h>
34 #include <ETL/stringf>
35 #include "widget_value.h"
36 #include "app.h"
37 #include <gtkmm/menu.h>
38 #include <gtkmm/optionmenu.h>
39 #include "widget_time.h"
40 #include "widget_waypointmodel.h"
41 #include "general.h"
42
43 #endif
44
45 using namespace synfig;
46 using namespace std;
47 using namespace etl;
48 using 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
58 Widget_WaypointModel::Widget_WaypointModel():
59         Gtk::Table(4,3,false),
60         adj_tension(0.0,-20,20,0.1,1),
61         adj_continuity(0.0,-20,20,0.1,1),
62         adj_bias(0.0,-20,20,0.1,1),
63         adj_temporal_tension(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 class Gtk::Menu());
72         before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
73         before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
74         before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
75         before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
76         before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
77
78         after_options=manage(new class Gtk::Menu());
79         after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
80         after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
81         after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
82         after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
83         after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
84
85         before=manage(new class Gtk::OptionMenu());
86         before->show();
87         before->set_menu(*before_options);
88
89         after=manage(new class Gtk::OptionMenu());
90         after->show();
91         after->set_menu(*after_options);
92
93         spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
94         spin_tension->show();
95         spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
96         spin_continuity->show();
97         spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
98         spin_bias->show();
99         spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
100         spin_temporal_tension->show();
101
102         checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
103         checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
104         checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
105         checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
106         checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
107         checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
108
109         adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
110         adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
111         adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
112         adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
113
114         before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
115         after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
116
117         attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
118         attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
119         attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
120         attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
121
122         attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
123         attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
124         attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
125         attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
126         attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
127         attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
128         attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
129         attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
130
131         show_all();
132         hide();
133         updating=false;
134         on_change();
135 }
136
137 void
138 Widget_WaypointModel::on_change()
139 {
140         if(updating)
141                 return;
142
143         waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
144         waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
145
146         waypoint_model.set_tension(adj_tension.get_value());
147         waypoint_model.set_continuity(adj_continuity.get_value());
148         waypoint_model.set_bias(adj_bias.get_value());
149         waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
150
151         waypoint_model.set_before_flag(checkbutton_before.get_active());
152         waypoint_model.set_after_flag(checkbutton_after.get_active());
153         waypoint_model.set_tension_flag(checkbutton_tension.get_active());
154         waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
155         waypoint_model.set_bias_flag(checkbutton_bias.get_active());
156         waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
157
158         before->set_sensitive(checkbutton_before.get_active());
159         after->set_sensitive(checkbutton_after.get_active());
160         spin_tension->set_sensitive(checkbutton_tension.get_active());
161         spin_continuity->set_sensitive(checkbutton_continuity.get_active());
162         spin_bias->set_sensitive(checkbutton_bias.get_active());
163         spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
164 }
165
166 void
167 Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
168 {
169         waypoint_model=x;
170         updating=true;
171
172         before->set_history((int)waypoint_model.get_before());
173         after->set_history((int)waypoint_model.get_after());
174
175         adj_tension.set_value(waypoint_model.get_tension());
176         adj_continuity.set_value(waypoint_model.get_continuity());
177         adj_bias.set_value(waypoint_model.get_bias());
178         adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
179
180         checkbutton_before.set_active(waypoint_model.get_before_flag());
181         checkbutton_after.set_active(waypoint_model.get_after_flag());
182         checkbutton_tension.set_active(waypoint_model.get_tension_flag());
183         checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
184         checkbutton_bias.set_active(waypoint_model.get_bias_flag());
185         checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());
186
187         updating=false;
188
189         on_change();
190 }