source: synfigstudio/trunk/fuentes/src/gui/instance.h @ 481

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

First release to xenial

File size: 7.2 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file gtkmm/instance.h
3**      \brief writeme
4**
5**      $Id$
6**
7**      \legal
8**      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9**      Copyright (c) 2007 Chris Moore
10**      Copyright (c) 2012 Konstantin Dmitriev
11**
12**      This package is free software; you can redistribute it and/or
13**      modify it under the terms of the GNU General Public License as
14**      published by the Free Software Foundation; either version 2 of
15**      the License, or (at your option) any later version.
16**
17**      This package is distributed in the hope that it will be useful,
18**      but WITHOUT ANY WARRANTY; without even the implied warranty of
19**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20**      General Public License for more details.
21**      \endlegal
22*/
23/* ========================================================================= */
24
25/* === S T A R T =========================================================== */
26
27#ifndef __SYNFIG_STUDIO_INSTANCE_H
28#define __SYNFIG_STUDIO_INSTANCE_H
29
30/* === H E A D E R S ======================================================= */
31
32#include <ETL/handle>
33#include <gtkmm/treeview.h>
34#include <gtkmm/treestore.h>
35#include <synfigapp/instance.h>
36#include <sigc++/sigc++.h>
37#include <synfigapp/value_desc.h>
38#include "trees/historytreestore.h"
39#include <synfig/canvas.h>
40
41/* === M A C R O S ========================================================= */
42#define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
43
44/* === T Y P E D E F S ===================================================== */
45
46/* === C L A S S E S & S T R U C T S ======================================= */
47
48namespace Gtk { class Menu; class ActionGroup; };
49
50namespace studio {
51
52class CanvasView;
53
54
55class Instance : public synfigapp::Instance
56{
57public:
58        typedef std::list< etl::handle<CanvasView> > CanvasViewList;
59
60        enum Status
61        {
62                STATUS_OK,
63                STATUS_ERROR,
64                STATUS_CANCEL
65        };
66
67        class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
68        {
69        public:
70                Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
71                Gtk::TreeModelColumn<Glib::ustring> label;
72                Gtk::TreeModelColumn<Glib::ustring> name;
73                Gtk::TreeModelColumn<Glib::ustring> id;
74
75                Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
76                Gtk::TreeModelColumn<bool> is_canvas;
77
78                Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
79                Gtk::TreeModelColumn<bool> is_value_node;
80                Gtk::TreeModelColumn<synfig::ValueBase> value;
81                Gtk::TreeModelColumn<Glib::ustring> type;
82                Gtk::TreeModelColumn<int> link_id;
83                Gtk::TreeModelColumn<int> link_count;
84
85                Gtk::TreeModelColumn<bool> is_editable;
86
87                Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
88
89                CanvasTreeModel()
90                {
91                        add(value);
92                        add(name);
93                        add(label);
94                        add(icon);
95                        add(type);
96                        add(id);
97                        add(canvas);
98                        add(value_node);
99                        add(is_canvas);
100                        add(is_value_node);
101
102                        add(is_editable);
103                        add(value_desc);
104                        add(link_count);
105                        add(link_id);
106                }
107        } canvas_tree_model;
108
109private:
110
111        sigc::signal<void,CanvasView*> signal_canvas_view_created_;
112        sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
113
114        sigc::signal<void> signal_undo_redo_status_changed_;
115
116        //! Tree containing the canvases -- used for the "canvas browser"
117        Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
118
119        //! Tree containing the actions -- used for the "canvas browser"
120        Glib::RefPtr<HistoryTreeStore> history_tree_store_;
121
122        //! Instance number
123        int     id_;
124
125        //! Used to calculate instance ID
126        static int instance_count_;
127
128        //! List of canvas view windows
129        CanvasViewList canvas_view_list_;
130
131        bool undo_status_;
132        bool redo_status_;
133
134        void set_undo_status(bool x);
135        void set_redo_status(bool x);
136
137protected:
138
139        Instance(synfig::Canvas::Handle, etl::handle< synfig::FileContainerTemporary >);
140
141public:
142
143        sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
144
145        ~Instance();
146
147        sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
148        sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
149
150        bool get_undo_status()const { return undo_status_; }
151
152        bool get_redo_status()const { return redo_status_; }
153
154        int get_visible_canvases()const;
155
156        Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
157
158        Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
159
160        Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
161
162        Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
163
164        //! Returns the number of instances that are currently open in the program
165        static int get_count() { return instance_count_; }
166
167        //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
168
169        etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
170
171        //! Sets the focus to a specific canvas
172        void focus(etl::handle<synfig::Canvas> canvas);
173
174        CanvasViewList & canvas_view_list() { return canvas_view_list_; }
175
176        const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
177       
178        void run_plugin(std::string plugin_path);
179
180        bool save_as(const synfig::String &filename);
181
182        //! returns true if the instance has a real filename associated with it, rather than the made up "synfig animation 1" or some such
183        bool has_real_filename();
184
185        //! Opens a "Save As" dialog, and then saves the composition to that file
186        //! returns true if the save was successful
187        bool dialog_save_as();
188
189        void open();
190
191        Status save();
192
193        void dialog_cvs_commit();
194
195        void dialog_cvs_add();
196
197        void dialog_cvs_update();
198
199        void dialog_cvs_revert();
200
201        //! Closes the instance of this composition
202        void close();
203
204        void revert();
205
206        void update_all_titles();
207
208        void refresh_canvas_tree();
209
210        bool safe_revert();
211        bool safe_close();
212
213        void add_actions_to_menu(Gtk::Menu *menu,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
214        void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list1,const synfigapp::Action::ParamList &param_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
215
216        void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
217
218        void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
219
220        void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
221
222        void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list, const synfigapp::ValueDesc &value_desc = synfigapp::ValueDesc());
223
224
225        static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
226
227private:
228        void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
229
230public:
231        static etl::handle<Instance> create(synfig::Canvas::Handle canvas, etl::handle< synfig::FileContainerTemporary > container);
232}; // END class Instance
233
234}; // END namespace studio
235
236/* === E N D =============================================================== */
237
238#endif
Note: See TracBrowser for help on using the repository browser.