1 /* === S Y N F I G ========================================================= */ 2 /*! \file layerparamtreestore.h 3 ** \brief Template Header 4 ** 5 ** $Id$ 6 ** 7 ** \legal 8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley 9 ** Copyright (c) 2007 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 /* === S T A R T =========================================================== */ 25 26 #ifndef __SYNFIG_STUDIO_LAYERPARAMTREESTORE_H 27 #define __SYNFIG_STUDIO_LAYERPARAMTREESTORE_H 28 29 /* === H E A D E R S ======================================================= */ 30 31 #include <gtkmm/treestore.h> 32 #include <synfigapp/canvasinterface.h> 33 #include "trees/canvastreestore.h" 34 #include <synfig/value.h> 35 #include <synfig/valuenode.h> 36 #include <synfig/paramdesc.h> 37 38 /* === M A C R O S ========================================================= */ 39 40 /* === T Y P E D E F S ===================================================== */ 41 42 /* === C L A S S E S & S T R U C T S ======================================= */ 43 44 namespace studio { 45 46 class LayerTree; 47 48 class LayerParamTreeStore : public CanvasTreeStore 49 { 50 /* 51 -- ** -- P U B L I C T Y P E S --------------------------------------------- 52 */ 53 54 public: 55 typedef std::list<synfig::Layer::Handle> LayerList; 56 57 /* 58 -- ** -- P U B L I C D A T A ------------------------------------------------ 59 */ 60 61 public: 62 63 //! TreeModel for the layer parameters 64 class Model : public CanvasTreeStore::Model 65 { 66 public: 67 68 Gtk::TreeModelColumn<synfig::ParamDesc> param_desc; 69 70 Gtk::TreeModelColumn<bool> is_inconsistent; 71 Gtk::TreeModelColumn<bool> is_toplevel; 72 Model()73 Model() 74 { 75 add(param_desc); 76 add(is_inconsistent); 77 add(is_toplevel); 78 } 79 }; 80 81 Model model; 82 83 84 /* 85 -- ** -- P R I V A T E D A T A --------------------------------------------- 86 */ 87 88 private: 89 90 int queued; 91 92 LayerTree* layer_tree; 93 94 LayerList layer_list; 95 96 sigc::connection queue_connection; 97 98 std::list<sigc::connection> changed_connection_list; 99 100 sigc::signal<void> signal_changed_; 101 102 /* 103 -- ** -- P R I V A T E M E T H O D S --------------------------------------- 104 */ 105 106 private: 107 108 protected: 109 virtual void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const; 110 virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value); 111 using CanvasTreeStore::set_row; 112 virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc); 113 114 /* 115 -- ** -- S I G N A L T E R M I N A L S ------------------------------------- 116 */ 117 118 private: 119 120 void on_value_node_child_added(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child); 121 void on_value_node_child_removed(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child); 122 123 void on_value_node_added(synfig::ValueNode::Handle value_node); 124 void on_value_node_deleted(synfig::ValueNode::Handle value_node); 125 virtual void on_value_node_changed(synfig::ValueNode::Handle value_node); 126 virtual void on_value_node_renamed(synfig::ValueNode::Handle value_node); 127 void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node); 128 void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name); 129 130 /* 131 -- ** -- P U B L I C M E T H O D S ----------------------------------------- 132 */ 133 134 public: 135 136 LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, 137 LayerTree* layer_tree); 138 ~LayerParamTreeStore(); 139 140 void rebuild(); 141 142 void refresh(); 143 144 void queue_refresh(); 145 146 void queue_rebuild(); 147 148 void refresh_row(Gtk::TreeModel::Row &row); 149 150 //! \brief Search for a value descriptor on the parameter tree. 151 //! On success get the node reference of the synfigapp::ValueDesc on the tree 152 //! \Param[in] value_desc The value to search for 153 //! \Param[out] iter The node reference of the value in the tree 154 //! \Return Failed or success to find 155 bool find_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter); 156 157 //! \brief Search for a value descriptor on the parameter tree from a given treenode level 158 //! On success get the node reference of the synfigapp::ValueDesc on the tree 159 //! \Param[in] value_desc The value to search for 160 //! \Param[out] iter The node reference of the value in the tree 161 //! \Param[in] child_iter The node level to look from 162 //! \Return Failed or success to find 163 bool find_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter, const Gtk::TreeNodeChildren child_iter); 164 signal_changed()165 sigc::signal<void>& signal_changed() { return signal_changed_; } 166 changed()167 void changed() { signal_changed_(); } 168 169 /* 170 -- ** -- S T A T I C P U B L I C M E T H O D S --------------------------- 171 */ 172 173 public: 174 175 static Glib::RefPtr<LayerParamTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, LayerTree*layer_tree); 176 }; // END of class LayerParamTreeStore 177 178 }; // END of namespace studio 179 180 /* === E N D =============================================================== */ 181 182 #endif 183