1 /* === S I N F G =========================================================== */
3 ** \brief Canvas Class Implementation
5 ** $Id: canvas.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_CANVAS_H
25 #define __SINFG_CANVAS_H
27 /* === H E A D E R S ======================================================= */
32 #include <sigc++/signal.h>
36 #include "canvasbase.h"
37 #include "valuenode.h"
43 /* === M A C R O S ========================================================= */
45 /* === T Y P E D E F S ===================================================== */
47 /* === C L A S S E S & S T R U C T S ======================================= */
57 class Canvas : public CanvasBase, public Node
60 -- ** -- T Y P E S -----------------------------------------------------------
64 typedef etl::handle<Canvas> Handle;
65 typedef etl::loose_handle<Canvas> LooseHandle;
66 typedef etl::handle<const Canvas> ConstHandle;
68 typedef std::list<Handle> Children;
70 friend void sinfg::optimize_layers(Context, Canvas::Handle);
73 -- ** -- D A T A -------------------------------------------------------------
78 //! Contains the ID string for the Canvas
79 /*! \see get_id(), set_id() */
82 //! Contains the name of the Canvas
83 /*! \see set_name(), get_name() */
86 //! Contains a description of the Canvas
87 /*! \see set_description(), get_description() */
90 //! Contains the author's name
91 /*! \see set_author(), get_author() */
94 //! Contains the author's email address
95 /*! \todo This private parameter has no binding, so it's unusable at the moment */
98 //! File name of Canvas
99 /*! \see get_file_name(), set_file_name() */
102 //! Metadata map for Canvas.
103 /*! \see get_meta_data(), set_meta_data(), erase_meta_data() */
104 std::map<String, String> meta_data_;
106 //! Contains a list of ValueNodes that are in this Canvas
107 /*! \see value_node_list(), find_value_node() */
108 ValueNodeList value_node_list_;
111 KeyframeList keyframe_list_;
113 //! A handle to the parent canvas of this canvas.
114 /*! If canvas is a root canvas, then this handle is empty
119 //! List containing any child Canvases
120 /*! \see children() */
123 //! Render Description for Canvas
124 /*! \see rend_desc() */
127 //! Contains the value of the last call to set_time()
131 mutable std::map<String,Handle> externals_;
133 //! This flag is set if this canvas is "inline"
136 mutable bool is_dirty_;
140 //! Layer Group database
141 std::map<String,std::set<etl::handle<Layer> > > group_db_;
144 -- ** -- S I G N A L S -------------------------------------------------------
150 sigc::signal<void,String> signal_group_added_;
153 sigc::signal<void,String> signal_group_removed_;
156 sigc::signal<void,String> signal_group_changed_;
158 sigc::signal<void,String,etl::handle<sinfg::Layer> > signal_group_pair_added_;
159 sigc::signal<void,String,etl::handle<sinfg::Layer> > signal_group_pair_removed_;
162 sigc::signal<void,int*> signal_layers_reordered_;
165 sigc::signal<void> signal_rend_desc_changed_;
168 sigc::signal<void> signal_id_changed_;
171 //sigc::signal<void> signal_dirty_;
174 sigc::signal<void> signal_file_name_changed_;
177 sigc::signal<void, String> signal_meta_data_changed_;
179 //! Key-Specific meta data changed signals
180 std::map<String, sigc::signal<void> > signal_map_meta_data_changed_;
183 //! ValueBasenode Changed
184 sigc::signal<void, etl::handle<ValueNode> > signal_value_node_changed_;
186 sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> > signal_value_node_child_added_;
188 sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> > signal_value_node_child_removed_;
191 -- ** -- S I G N A L I N T E R F A C E -------------------------------------
196 sigc::signal<void,String,etl::handle<sinfg::Layer> >& signal_group_pair_added() { return signal_group_pair_added_; }
197 sigc::signal<void,String,etl::handle<sinfg::Layer> >& signal_group_pair_removed() { return signal_group_pair_removed_; }
200 sigc::signal<void,String>& signal_group_added() { return signal_group_added_; }
203 sigc::signal<void,String>& signal_group_removed() { return signal_group_removed_; }
206 sigc::signal<void,String>& signal_group_changed() { return signal_group_changed_; }
209 sigc::signal<void,int*>& signal_layers_reordered() { return signal_layers_reordered_; }
212 sigc::signal<void>& signal_rend_desc_changed() { return signal_rend_desc_changed_; }
215 sigc::signal<void>& signal_id_changed() { return signal_id_changed_; }
217 //! File name Changed
218 sigc::signal<void>& signal_file_name_changed();
221 sigc::signal<void, String>& signal_meta_data_changed() { return signal_meta_data_changed_; }
224 sigc::signal<void>& signal_meta_data_changed(const String& key) { return signal_map_meta_data_changed_[key]; }
227 sigc::signal<void, etl::handle<ValueNode> >& signal_value_node_changed() { return signal_value_node_changed_; }
230 sigc::signal<void>& signal_dirty() { return signal_changed(); }
233 sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> >& signal_value_node_child_added() { return signal_value_node_child_added_; }
236 sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> >& signal_value_node_child_removed() { return signal_value_node_child_removed_; }
239 -- ** -- C O N S T R U C T O R S ---------------------------------------------
244 Canvas(const String &name);
251 -- ** -- M E M B E R F U N C T I O N S -------------------------------------
256 //! Returns the set of layers in group
257 std::set<etl::handle<Layer> > get_layers_in_group(const String&group);
259 //! Gets all the groups
260 std::set<String> get_groups()const;
262 //! Gets the number of groups in this canvas
263 int get_group_count()const;
265 //! Renames the given group
266 void rename_group(const String&old_name,const String&new_name);
269 bool is_inline()const { return is_inline_; }
271 //! Returns a handle to the RendDesc for this Canvas
272 RendDesc &rend_desc() { return desc_; }
274 //! Returns a handle to the RendDesc for this Canvas
275 const RendDesc &rend_desc()const { return desc_; }
277 //! Gets the name of the canvas
278 const String & get_name()const { return name_; }
280 //! Sets the name of the canvas
281 void set_name(const String &x);
283 //! Gets the author of the canvas
284 const String & get_author()const { return author_; }
286 //! Sets the author of the canvas
287 void set_author(const String &x);
289 //! Gets the description of the canvas
290 const String & get_description()const { return description_; }
292 //! Sets the name of the canvas
293 void set_description(const String &x);
295 //! Gets the ID of the canvas
296 const String & get_id()const { return id_; }
298 //! Sets the ID of the canvas
299 void set_id(const String &x);
301 //! Returns the data string for the given meta data key
302 String get_meta_data(const String& key)const;
304 //! Returns a list of meta data keys
305 std::list<String> get_meta_data_keys()const;
307 //! Sets a meta data key to a specific string
308 void set_meta_data(const String& key, const String& data);
310 //! Removes a meta data key
311 void erase_meta_data(const String& key);
314 String get_relative_id(etl::loose_handle<const Canvas> x)const;
316 //! \internal \writeme
317 String _get_relative_id(etl::loose_handle<const Canvas> x)const;
319 //! Returns \c true if the Canvas is a root Canvas. \c false otherwise
320 bool is_root()const { return !parent_; }
322 //! Returns a handle to the parent Canvas.
323 /*! The returned handle will be empty if this is a root canvas */
324 LooseHandle parent()const { return parent_; }
326 LooseHandle get_root()const;
328 //! Returns a list of all child canvases in this canvas
329 std::list<Handle> &children() { return children_; }
331 //! Returns a list of all child canvases in this canvas
332 const std::list<Handle> &children()const { return children_; }
334 //! Gets the color at the specified point
335 //Color get_color(const Point &pos)const;
337 //! Sets the time for all the layers in the canvas
338 void set_time(Time t)const;
341 Time get_time()const { return cur_time_; }
343 //! Returns the number of layers in the canvas
346 //! Removes all the layers from the canvas
349 //! Returns true if the canvas has no layers
352 //! Returns a reference to the ValueNodeList for this Canvas
353 // ValueNodeList &value_node_list() { return value_node_list_; }
355 //! Returns a reference to the ValueNodeList for this Canvas
356 const ValueNodeList &value_node_list()const;
358 //! Returns a reference to the KeyframeList for this Canvas
359 KeyframeList &keyframe_list();
361 //! Returns a reference to the KeyframeList for this Canvas
362 const KeyframeList &keyframe_list()const;
364 //! Finds the ValueNode in the Canvas with the given \a id
365 /*! \return If found, returns a handle to the ValueNode.
366 ** Otherwise, returns an empty handle.
368 ValueNode::Handle find_value_node(const String &id);
370 //! \internal \writeme
371 ValueNode::Handle surefind_value_node(const String &id);
373 //! Finds the ValueNode in the Canvas with the given \a id
374 /*! \return If found, returns a handle to the ValueNode.
375 ** Otherwise, returns an empty handle.
377 ValueNode::ConstHandle find_value_node(const String &id)const;
380 void add_value_node(ValueNode::Handle x, const String &id);
383 //void rename_value_node(ValueNode::Handle x, const String &id);
386 void remove_value_node(ValueNode::Handle x);
389 void remove_value_node(const String &id) { remove_value_node(find_value_node(id)); }
391 //! Finds a child Canvas in the Canvas with the given \a name
392 /*! \return If found, returns a handle to the child Canvas.
393 ** If not found, it creates a new Canvas and returns it
394 ** If an error occurs, it returns an empty handle
396 Handle surefind_canvas(const String &id);
398 //! Finds a child Canvas in the Canvas with the given \a id
399 /*! \return If found, returns a handle to the child Canvas.
400 ** Otherwise, returns an empty handle.
402 Handle find_canvas(const String &id);
404 //! Finds a child Canvas in the Canvas with the given \a id
405 /*! \return If found, returns a handle to the child Canvas.
406 ** Otherwise, returns an empty handle.
408 ConstHandle find_canvas(const String &id)const;
410 //! Sets the file path for the Canvas
411 //void set_file_path(const String &);
413 //! Returns the file path from the file name
414 String get_file_path()const;
416 //! Sets the filename (with path)
417 void set_file_name(const String &);
419 //! Gets the filename (with path)
420 String get_file_name()const;
422 //! Creates a new child canvas, and returns its handle
423 Handle new_child_canvas();
425 //! Creates a new child canvas with an ID of \aid, and returns its handle
426 Handle new_child_canvas(const String &id);
428 //! Adds the given canvas as a child
429 Handle add_child_canvas(Handle child_canvas, const String &id);
431 void remove_child_canvas(Handle child_canvas);
433 etl::handle<Layer> find_layer(const Point &pos);
435 int get_depth(etl::handle<Layer>)const;
437 Context get_context()const;
441 const_iterator end()const;
443 reverse_iterator rbegin();
445 const_reverse_iterator rbegin()const;
447 etl::handle<Layer> &back();
449 void push_back(etl::handle<Layer> x);
451 void push_front(etl::handle<Layer> x);
453 void push_back_simple(etl::handle<Layer> x);
455 void insert(iterator iter,etl::handle<Layer> x);
456 void erase(iterator iter);
458 const etl::handle<Layer> &back()const;
460 void set_inline(LooseHandle parent);
462 static Handle create();
464 static Handle create_inline(Handle parent);
466 Handle clone(const GUID& deriv_guid=GUID())const;
469 void add_group_pair(String group, etl::handle<Layer> layer);
470 void remove_group_pair(String group, etl::handle<Layer> layer);
473 virtual void on_changed();
474 virtual void get_times_vfunc(Node::time_set &set) const;
475 }; // END of class Canvas
477 void optimize_layers(Context context, Canvas::Handle op_canvas);
480 }; // END of namespace sinfg
482 /* === E N D =============================================================== */