1 /* === S Y N F I G ========================================================= */
2 /*! \file dialog_waypoint.cpp
3 ** \brief Template Header
5 ** $Id: widget_waypoint.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
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 "dialog_waypoint.h"
35 #include <gtkmm/spinbutton.h>
36 #include <gtkmm/combo.h>
37 #include <ETL/stringf>
38 #include "widget_value.h"
40 #include <gtkmm/menu.h>
41 #include <gtkmm/optionmenu.h>
42 #include "widget_time.h"
43 #include "widget_waypoint.h"
46 using namespace synfig;
49 using namespace studio;
51 /* === M A C R O S ========================================================= */
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
60 Gtk::Table(4,3,false),
61 waypoint(synfig::ValueBase(),0),
62 adj_tension(0.0,-20,20,0.1,1),
63 adj_continuity(0.0,-20,20,0.1,1),
64 adj_bias(0.0,-20,20,0.1,1),
65 adj_temporal_tension(0.0,-20,20,0.1,1)
67 value_widget=manage(new Widget_ValueBase());
68 value_widget->set_canvas(canvas);
71 value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
74 time_widget=manage(new Widget_Time());
75 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
76 //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
77 //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
80 before_options=manage(new class Gtk::Menu());
81 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
82 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
83 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
84 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease In"));
85 before_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
87 after_options=manage(new class Gtk::Menu());
88 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("TCB Smooth"));
89 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Constant"));
90 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Linear"));
91 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Ease Out"));
92 after_options->items().push_back(Gtk::Menu_Helpers::MenuElem("Manual"));
94 before=manage(new class Gtk::OptionMenu());
96 before->set_menu(*before_options);
98 after=manage(new class Gtk::OptionMenu());
100 after->set_menu(*after_options);
102 spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
103 spin_tension->show();
104 spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
105 spin_continuity->show();
106 spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
108 spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
109 spin_temporal_tension->show();
112 Gtk::HBox *hbox(manage(new Gtk::HBox()));
114 hbox->pack_start(*value_widget);
115 hbox->pack_start(*value_node_label);
117 attach(*manage(new Gtk::Label(_("ValueBase:"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
118 //attach(*value_widget, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
119 //attach(*value_node_label, 0, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
120 attach(*manage(new Gtk::Label(_("Time:"))), 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
121 attach(*time_widget, 1, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
122 attach(*manage(new Gtk::Label(_("In:"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
123 attach(*before, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
124 attach(*manage(new Gtk::Label(_("Out:"))), 2, 3, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
125 attach(*after, 3, 4, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
127 attach(*manage(new Gtk::Label(_("Tension:"))), 0, 1, 4, 5, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
128 attach(*spin_tension, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
129 attach(*manage(new Gtk::Label(_("Continuity:"))), 2, 3, 4, 5, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
130 attach(*spin_continuity, 3, 4, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
131 attach(*manage(new Gtk::Label(_("Bias:"))), 0, 1, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
132 attach(*spin_bias, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
133 attach(*manage(new Gtk::Label(_("Temporal Tension:"))), 2, 3, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
134 attach(*spin_temporal_tension, 3, 4, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
138 attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
143 Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
148 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
149 value_widget->set_canvas(canvas);
153 Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
155 time_widget->set_fps(canvas->rend_desc().get_frame_rate());
159 #warning This really needs to be fixed to support value node waypoints!
160 if(waypoint.is_static())
162 value_widget->set_value(waypoint.get_value());
163 value_widget->show();
164 value_node_label->hide();
168 value_widget->hide();
169 value_node_label->show();
172 time_widget->set_value(waypoint.get_time());
174 before->set_history((int)waypoint.get_before());
175 after->set_history((int)waypoint.get_after());
177 adj_tension.set_value(waypoint.get_tension());
178 adj_continuity.set_value(waypoint.get_continuity());
179 adj_bias.set_value(waypoint.get_bias());
180 adj_temporal_tension.set_value(waypoint.get_temporal_tension());
183 const synfig::Waypoint &
184 Widget_Waypoint::get_waypoint()const
187 waypoint.set_time(time_widget->get_value());
188 waypoint.set_value(value_widget->get_value());
191 waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
192 waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
194 waypoint.set_tension(adj_tension.get_value());
195 waypoint.set_continuity(adj_continuity.get_value());
196 waypoint.set_bias(adj_bias.get_value());
197 waypoint.set_temporal_tension(adj_temporal_tension.get_value());