source: synfigstudio/trunk/fuentes/src/gui/dialogs/dialog_keyframe.cpp @ 481

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

First release to xenial

File size: 6.2 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file dialog_keyframe.cpp
3**      \brief Keyframe properties dialog implementation
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 "dialogs/dialog_keyframe.h"
33#include <gtkmm/scrolledwindow.h>
34#include <gtkmm/button.h>
35#include "widgets/widget_waypointmodel.h"
36#include <synfigapp/action.h>
37#include <synfigapp/instance.h>
38
39#include "general.h"
40
41#endif
42
43/* === U S I N G =========================================================== */
44
45using namespace std;
46using namespace etl;
47using namespace synfig;
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
58Dialog_Keyframe::Dialog_Keyframe(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
59        Gtk::Dialog(_("Keyframe Dialog"),parent),
60        canvas_interface(canvas_interface)
61{
62        // Set up the buttons
63        {
64                Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
65                ok_button->show();
66                add_action_widget(*ok_button,2);
67                ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_ok_pressed));
68
69                Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
70                apply_button->show();
71                add_action_widget(*apply_button,1);
72                apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_apply_pressed));
73
74                Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
75                delete_button->show();
76                add_action_widget(*delete_button,3);
77                delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_delete_pressed));
78
79                Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
80                cancel_button->show();
81                add_action_widget(*cancel_button,0);
82                cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::hide));
83        }
84
85        Gtk::Grid *grid=manage(new Gtk::Grid());
86        grid->set_row_spacing(6);
87        grid->set_column_spacing(12);
88
89        get_content_area()->add(*grid);
90
91        // Allow setting descriptions for keyframes
92        entry_description.set_text("");
93        grid->attach(*manage(new Gtk::Label(_("Description :"))),   0, 0, 1, 1);
94        grid->attach(entry_description,                             1, 0, 3, 1);
95        entry_description.set_hexpand(true);
96
97        // Allow toggling active status for keyframes
98        grid->attach(*manage(new Gtk::Label(_("Active :"))),        4, 0, 1, 1);
99        grid->attach(entry_toogle,                                  5, 0, 1, 1);
100
101        widget_waypoint_model=Gtk::manage(new Widget_WaypointModel());
102        widget_waypoint_model->show();
103        grid->attach(*widget_waypoint_model,                        0, 1, 6, 2);
104
105        grid->show_all();
106}
107
108Dialog_Keyframe::~Dialog_Keyframe()
109{
110}
111
112const synfig::Keyframe&
113Dialog_Keyframe::get_keyframe()const
114{
115        return keyframe_;
116}
117
118void
119Dialog_Keyframe::set_keyframe(const synfig::Keyframe& x)
120{
121        keyframe_=x;
122        entry_description.set_text(keyframe_.get_description());
123        entry_toogle.set_active(keyframe_.active());
124
125        widget_waypoint_model->reset_waypoint_model();
126
127        if (keyframe_.has_model())
128        {
129            // TODO operator = for wp::model ?
130            widget_waypoint_model->set_waypoint_model(keyframe_.get_waypoint_model());
131        }
132}
133
134void
135Dialog_Keyframe::on_ok_pressed()
136{
137        on_apply_pressed();
138        hide();
139}
140
141
142void
143Dialog_Keyframe::on_delete_pressed()
144{
145        synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
146
147        assert(action);
148
149        action->set_param("canvas",canvas_interface->get_canvas());
150        action->set_param("canvas_interface",canvas_interface);
151        action->set_param("keyframe",keyframe_);
152        action->set_param("model",widget_waypoint_model->get_waypoint_model());
153
154        if(canvas_interface->get_instance()->perform_action(action))
155        {
156                hide();
157        }
158}
159
160
161void
162Dialog_Keyframe::on_apply_pressed()
163{
164        //! Set the new description if needed
165        if(entry_description.get_text() != keyframe_.get_description())
166        {
167                keyframe_.set_description(entry_description.get_text());
168
169                synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
170                assert(action);
171
172                action->set_param("canvas",canvas_interface->get_canvas());
173                action->set_param("canvas_interface",canvas_interface);
174                action->set_param("keyframe",keyframe_);
175
176                if(!canvas_interface->get_instance()->perform_action(action))
177                {
178                }
179        }
180
181        //! Update the active status if needed
182        if(entry_toogle.get_active() != keyframe_.active())
183        {
184                keyframe_.set_active(entry_toogle.get_active());
185
186                synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeToggl"));
187                assert(action);
188
189                action->set_param("canvas",canvas_interface->get_canvas());
190                action->set_param("canvas_interface",canvas_interface);
191                action->set_param("keyframe",keyframe_);
192                action->set_param("new_status",keyframe_.active ());
193
194                if(!canvas_interface->get_instance()->perform_action(action))
195                {
196                }
197        }
198
199        if(widget_waypoint_model->get_waypoint_model().is_trivial())
200                return;
201
202        synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeWaypointSet"));
203
204        assert(action);
205
206        action->set_param("canvas",canvas_interface->get_canvas());
207        action->set_param("canvas_interface",canvas_interface);
208        action->set_param("keyframe",keyframe_);
209        action->set_param("model",widget_waypoint_model->get_waypoint_model());
210
211        if(!canvas_interface->get_instance()->perform_action(action))
212        {
213        }
214}
Note: See TracBrowser for help on using the repository browser.