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;
65 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
68 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
69 Gtk::TreeModelColumn<Glib::ustring> label;
70 Gtk::TreeModelColumn<Glib::ustring> name;
71 Gtk::TreeModelColumn<Glib::ustring> id;
73 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
74 Gtk::TreeModelColumn<bool> is_canvas;
76 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
77 Gtk::TreeModelColumn<bool> is_value_node;
78 Gtk::TreeModelColumn<synfig::ValueBase> value;
79 Gtk::TreeModelColumn<Glib::ustring> type;
80 Gtk::TreeModelColumn<int> link_id;
81 Gtk::TreeModelColumn<int> link_count;
83 Gtk::TreeModelColumn<bool> is_editable;
85 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
109 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
110 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
112 sigc::signal<void> signal_undo_redo_status_changed_;
114 //! Tree containing the canvases -- used for the "canvas browser"
115 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
117 //! Tree containing the actions -- used for the "canvas browser"
118 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
123 //! Used to calculate instance ID
124 static int instance_count_;
126 //! List of canvas view windows
127 CanvasViewList canvas_view_list_;
132 void set_undo_status(bool x);
133 void set_redo_status(bool x);
135 static void _revert(Instance *);
139 Instance(synfig::Canvas::Handle);
143 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
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_; }
150 bool get_undo_status()const { return undo_status_; }
152 bool get_redo_status()const { return redo_status_; }
154 int get_visible_canvases()const;
156 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
158 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
160 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
162 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
164 //! Returns the number of instances that are currently open in the program
165 static int get_count() { return instance_count_; }
167 //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
169 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
171 //! Sets the focus to a specific canvas
172 void focus(etl::handle<synfig::Canvas> canvas);
174 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
176 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
178 bool save_as(const synfig::String &filename);
180 //! Opens a "Save As" dialog, and then saves the composition to that file
181 //! returns true if the save was successful
182 bool dialog_save_as();
186 void dialog_cvs_commit();
188 void dialog_cvs_add();
190 void dialog_cvs_update();
192 void dialog_cvs_revert();
194 //! Closes the instance of this composition
199 void update_all_titles();
201 void refresh_canvas_tree();
206 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
207 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;
209 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;
211 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
213 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f);
215 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
218 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
221 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
224 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
225 }; // END class Instance
227 }; // END namespace studio
229 /* === E N D =============================================================== */