Move dialogs into subfolder
[synfig.git] / synfig-studio / src / gui / dialogs / dialog_keyframe.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dialog_keyframe.cpp
3 **      \brief Template File
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 "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
45 using namespace std;
46 using namespace etl;
47 using namespace synfig;
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 Dialog_Keyframe::Dialog_Keyframe(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
59         Gtk::Dialog(_("Keyframe Dialog"),parent,false,true),
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::Table *table=manage(new Gtk::Table(2,2,false));
86
87         get_vbox()->pack_start(*table);
88
89 /*  // \todo Allow setting descriptions for keyframes
90
91         entry_description.set_text(_("Not yet implemented"));
92
93         table->attach(*manage(new Gtk::Label(_("Description"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
94         table->attach(entry_description, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
95 */
96
97         table->show_all();
98
99         widget_waypoint_model=Gtk::manage(new Widget_WaypointModel());
100         widget_waypoint_model->show();
101         table->attach(*widget_waypoint_model, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
102
103 }
104
105 Dialog_Keyframe::~Dialog_Keyframe()
106 {
107 }
108
109 const synfig::Keyframe&
110 Dialog_Keyframe::get_keyframe()const
111 {
112         return keyframe_;
113 }
114
115 void
116 Dialog_Keyframe::set_keyframe(const synfig::Keyframe& x)
117 {
118         keyframe_=x;
119 }
120
121 void
122 Dialog_Keyframe::on_ok_pressed()
123 {
124         on_apply_pressed();
125         hide();
126 }
127
128
129 void
130 Dialog_Keyframe::on_delete_pressed()
131 {
132         synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
133
134         assert(action);
135
136         action->set_param("canvas",canvas_interface->get_canvas());
137         action->set_param("canvas_interface",canvas_interface);
138         action->set_param("keyframe",keyframe_);
139         action->set_param("model",widget_waypoint_model->get_waypoint_model());
140
141         if(canvas_interface->get_instance()->perform_action(action))
142         {
143                 hide();
144         }
145 }
146
147
148 void
149 Dialog_Keyframe::on_apply_pressed()
150 {
151         if(widget_waypoint_model->get_waypoint_model().is_trivial())
152                 return;
153
154         synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeWaypointSet"));
155
156         assert(action);
157
158         action->set_param("canvas",canvas_interface->get_canvas());
159         action->set_param("canvas_interface",canvas_interface);
160         action->set_param("keyframe",keyframe_);
161         action->set_param("model",widget_waypoint_model->get_waypoint_model());
162
163         if(!canvas_interface->get_instance()->perform_action(action))
164         {
165         }
166 }