1 /* === S Y N F I G ========================================================= */
2 /*! \file gtkmm/instance.h
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_STUDIO_INSTANCE_H
26 #define __SYNFIG_STUDIO_INSTANCE_H
28 /* === H E A D E R S ======================================================= */
31 #include <gtkmm/treeview.h>
32 #include <gtkmm/treestore.h>
33 #include <synfigapp/instance.h>
34 #include <sigc++/object.h>
35 #include <synfigapp/value_desc.h>
36 #include "historytreestore.h"
37 #include <synfig/canvas.h>
39 /* === M A C R O S ========================================================= */
40 #define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
42 /* === T Y P E D E F S ===================================================== */
44 /* === C L A S S E S & S T R U C T S ======================================= */
46 namespace Gtk { class Menu; class ActionGroup; };
53 class Instance : public synfigapp::Instance
56 typedef std::list< etl::handle<CanvasView> > CanvasViewList;
58 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
61 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
62 Gtk::TreeModelColumn<Glib::ustring> label;
63 Gtk::TreeModelColumn<Glib::ustring> name;
64 Gtk::TreeModelColumn<Glib::ustring> id;
66 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
67 Gtk::TreeModelColumn<bool> is_canvas;
69 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
70 Gtk::TreeModelColumn<bool> is_value_node;
71 Gtk::TreeModelColumn<synfig::ValueBase> value;
72 Gtk::TreeModelColumn<Glib::ustring> type;
73 Gtk::TreeModelColumn<int> link_id;
74 Gtk::TreeModelColumn<int> link_count;
76 Gtk::TreeModelColumn<bool> is_editable;
78 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
102 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
103 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
105 sigc::signal<void> signal_undo_redo_status_changed_;
107 //! Tree containing the canvases -- used for the "canvas browser"
108 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
110 //! Tree containing the actions -- used for the "canvas browser"
111 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
116 //! Used to calculate instance ID
117 static int instance_count_;
119 //! List of canvas view windows
120 CanvasViewList canvas_view_list_;
125 void set_undo_status(bool x);
126 void set_redo_status(bool x);
128 static void _revert(Instance *);
132 Instance(synfig::Canvas::Handle);
136 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
140 sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
141 sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
143 bool get_undo_status()const { return undo_status_; }
145 bool get_redo_status()const { return redo_status_; }
147 int get_visible_canvases()const;
149 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
151 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
153 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
155 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
157 //! Returns the number of instances that are currently open in the program
158 static int get_count() { return instance_count_; }
160 //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
162 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
164 //! Sets the focus to a specific canvas
165 void focus(etl::handle<synfig::Canvas> canvas);
167 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
169 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
171 bool save_as(const synfig::String &filename);
173 //! Opens a "Save As" dialog, and then saves the composition to that file
174 //! returns true if the save was successful
175 bool dialog_save_as();
179 void dialog_cvs_commit();
181 void dialog_cvs_add();
183 void dialog_cvs_update();
185 void dialog_cvs_revert();
187 //! Closes the instance of this composition
192 void update_all_titles();
194 void refresh_canvas_tree();
199 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
200 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;
202 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;
204 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
206 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f);
208 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
211 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
214 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
217 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
218 }; // END class Instance
220 }; // END namespace studio
222 /* === E N D =============================================================== */