1 /* === S Y N F I G ========================================================= */
2 /*! \file gtkmm/instance.h
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
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.
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.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_STUDIO_INSTANCE_H
27 #define __SYNFIG_STUDIO_INSTANCE_H
29 /* === H E A D E R S ======================================================= */
32 #include <gtkmm/treeview.h>
33 #include <gtkmm/treestore.h>
34 #include <synfigapp/instance.h>
35 #include <sigc++/object.h>
36 #include <synfigapp/value_desc.h>
37 #include "historytreestore.h"
38 #include <synfig/canvas.h>
40 /* === M A C R O S ========================================================= */
41 #define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
43 /* === T Y P E D E F S ===================================================== */
45 /* === C L A S S E S & S T R U C T S ======================================= */
47 namespace Gtk { class Menu; class ActionGroup; };
54 class Instance : public synfigapp::Instance
57 typedef std::list< etl::handle<CanvasView> > CanvasViewList;
66 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
69 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
70 Gtk::TreeModelColumn<Glib::ustring> label;
71 Gtk::TreeModelColumn<Glib::ustring> name;
72 Gtk::TreeModelColumn<Glib::ustring> id;
74 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
75 Gtk::TreeModelColumn<bool> is_canvas;
77 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
78 Gtk::TreeModelColumn<bool> is_value_node;
79 Gtk::TreeModelColumn<synfig::ValueBase> value;
80 Gtk::TreeModelColumn<Glib::ustring> type;
81 Gtk::TreeModelColumn<int> link_id;
82 Gtk::TreeModelColumn<int> link_count;
84 Gtk::TreeModelColumn<bool> is_editable;
86 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
110 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
111 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
113 sigc::signal<void> signal_undo_redo_status_changed_;
115 //! Tree containing the canvases -- used for the "canvas browser"
116 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
118 //! Tree containing the actions -- used for the "canvas browser"
119 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
124 //! Used to calculate instance ID
125 static int instance_count_;
127 //! List of canvas view windows
128 CanvasViewList canvas_view_list_;
133 void set_undo_status(bool x);
134 void set_redo_status(bool x);
136 static void _revert(Instance *);
140 Instance(synfig::Canvas::Handle);
144 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
148 sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
149 sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
151 bool get_undo_status()const { return undo_status_; }
153 bool get_redo_status()const { return redo_status_; }
155 int get_visible_canvases()const;
157 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
159 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
161 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
163 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
165 //! Returns the number of instances that are currently open in the program
166 static int get_count() { return instance_count_; }
168 //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
170 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
172 //! Sets the focus to a specific canvas
173 void focus(etl::handle<synfig::Canvas> canvas);
175 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
177 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
179 bool save_as(const synfig::String &filename);
181 //! returns true if the instance has a real filename associated with it, rather than the made up "synfig animation 1" or some such
182 bool has_real_filename();
184 //! Opens a "Save As" dialog, and then saves the composition to that file
185 //! returns true if the save was successful
186 bool dialog_save_as();
192 void dialog_cvs_commit();
194 void dialog_cvs_add();
196 void dialog_cvs_update();
198 void dialog_cvs_revert();
200 //! Closes the instance of this composition
205 void update_all_titles();
207 void refresh_canvas_tree();
212 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
213 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list1,const synfigapp::Action::ParamList ¶m_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
215 void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
217 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
219 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
221 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
224 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
227 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
230 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
231 }; // END class Instance
233 }; // END namespace studio
235 /* === E N D =============================================================== */