Move Transform Tool into Normal Tool
[synfig.git] / synfig-studio / src / gtkmm / state_null.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file state_null.cpp
3 **      \brief Null State File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007, 2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === H E A D E R S ======================================================= */
25
26 #ifdef USING_PCH
27 #       include "pch.h"
28 #else
29 #ifdef HAVE_CONFIG_H
30 #       include <config.h>
31 #endif
32
33 #include "state_null.h"
34 #include "workarea.h"
35 #include "event_mouse.h"
36 #include "event_layerclick.h"
37 #include "toolbox.h"
38 #include "dialog_tooloptions.h"
39 #include <gtkmm/dialog.h>
40 #include "widget_waypointmodel.h"
41 #include <synfig/valuenode_animated.h>
42 #include <synfig/valuenode_composite.h>
43 #include <synfig/valuenode_const.h>
44 #include "canvasview.h"
45 #include "general.h"
46
47 #endif
48
49 /* === U S I N G =========================================================== */
50
51 using namespace std;
52 using namespace etl;
53 using namespace synfig;
54 using namespace studio;
55
56 /* === M A C R O S ========================================================= */
57
58 /* === G L O B A L S ======================================================= */
59
60 StateNull studio::state_null;
61
62 /* === C L A S S E S & S T R U C T S ======================================= */
63
64 class studio::StateNull_Context : public sigc::trackable
65 {
66         CanvasView *canvas_view;
67
68         CanvasView* get_canvas_view() { return canvas_view; }
69         Canvas::Handle get_canvas() { return canvas_view->get_canvas(); }
70         WorkArea* get_work_area() { return canvas_view->get_work_area(); }
71         etl::handle<synfigapp::CanvasInterface> get_canvas_interface() { return canvas_view->canvas_interface(); }
72
73         Gtk::Table options_table;
74
75 public:
76         StateNull_Context(CanvasView *canvas_view);
77         ~StateNull_Context();
78
79         Smach::event_result event_refresh_tool_options(const Smach::event& x);
80
81         void refresh_tool_options();
82 }; // END of class StateNull_Context
83
84 /* === P R O C E D U R E S ================================================= */
85
86 /* === M E T H O D S ======================================================= */
87
88 StateNull::StateNull():
89         Smach::state<StateNull_Context>("null")
90 {
91         insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateNull_Context::event_refresh_tool_options));
92 }
93
94 StateNull::~StateNull()
95 {
96 }
97
98 StateNull_Context::StateNull_Context(CanvasView *canvas_view):
99         canvas_view(canvas_view)
100 {
101         // Synfig Studio's default state is initialized in the canvas view constructor
102         // As a result, it cannot reference canvas view or workarea when created
103         // Other states need to reference the workarea,
104         //    so a null state was created to be the default
105
106         options_table.attach(*manage(new Gtk::Label(_("Welcome to Synfig Studio"))),    0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
107         options_table.show_all();
108         refresh_tool_options();
109 }
110
111 StateNull_Context::~StateNull_Context()
112 {
113 }
114
115 void
116 StateNull_Context::refresh_tool_options()
117 {
118         App::dialog_tool_options->clear();
119         App::dialog_tool_options->set_widget(options_table);
120         App::dialog_tool_options->set_local_name(_("Welcome to Synfig Studio"));
121         App::dialog_tool_options->set_name("null");
122 }
123
124 Smach::event_result
125 StateNull_Context::event_refresh_tool_options(const Smach::event& /*x*/)
126 {
127         refresh_tool_options();
128         return Smach::RESULT_ACCEPT;
129 }