X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcanvas.h;h=a6474da9afbb902d93c77e582cbdb5fa748caa4a;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=c6ff79b5b7309a4393d65b2ea7bd4cf64ccc4ccd;hpb=28f28705612902c15cd0702cc891fba35bf2d2df;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/canvas.h b/synfig-core/trunk/src/synfig/canvas.h index c6ff79b..a6474da 100644 --- a/synfig-core/trunk/src/synfig/canvas.h +++ b/synfig-core/trunk/src/synfig/canvas.h @@ -2,19 +2,21 @@ /*! \file canvas.h ** \brief Canvas Class Implementation ** -** $Id: canvas.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -30,6 +32,7 @@ #include #include #include +#include #include "vector.h" #include "string.h" @@ -42,6 +45,66 @@ /* === M A C R O S ========================================================= */ +/* version change history: + * + * 0.1: the original version + * + * if a waypoint goes from -179 to 179 degrees, that is a 2 + * degree change. there's no way to express a 720 degree + * rotation with a single pair of waypoints + * + * 0.2: svn r1227 + * + * angles no longer wrap at -180 degrees back to 180 degrees; if + * a waypoint goes from -179 to 179 degrees, that is a rotation + * of 358 degrees. loading a version 0.1 canvas will modify + * constant angle waypoints to that they are within 180 degrees + * of the previous waypoint's value + * + * the 'straight' blend method didn't used to work properly. it + * didn't work at all on transparent pixels in layers other than + * the PasteCanvas layer. for example, the examples/japan.sifz + * file has a red circle (straight, amount=1.0) on top of a + * striped conical gradient. if 'straight' was working, the + * conical gradient would be entirely obscured by the circle + * layer (even by its transparent pixels) + * + * 0.3: svn r1422 + * + * the 'straight' blend method was fixed. loading a version 0.2 + * or older canvas will replace the 'straight' blend method in + * non-pastecanvas layers with 'composite', unless they're + * completely transparent, in which case it will replace them + * with an 'alpha over' blend instead. Images like + * examples/logo.sifz use transparent straight blends to do + * masking, which no longer works now that 'straight' blending is + * fixed. + * + * Tangent lengths calculated by the "Segment Tangent" and "BLine + * Tangent" ValueNodes were scaled by a factor of 0.5. + * + * 0.4: svn r1856 + * + * Stop scaling tangents by 0.5. + * + * 0.5: svn r1863 + * + * Added "offset", "scale", and "fixed_length" links to the + * "BLine Tangent" ValueNode. + * + * 0.6: svn r2067 + * + * Added "scale" link to the "BLine Width" ValueNode in svn r1872. + * + * Added "loop" link to the "Gradient Color" ValueNode in svn r1901. + * + * 0.7: svn r2315 + * + * Added "loop" link to the "Random" ValueNode in svn r2315. + */ + +#define CURRENT_CANVAS_VERSION "0.7" + /* === T Y P E D E F S ===================================================== */ /* === C L A S S E S & S T R U C T S ======================================= */ @@ -50,7 +113,7 @@ namespace synfig { class Context; class GUID; - + /*! \class Canvas ** \todo writeme */ @@ -67,7 +130,7 @@ public: typedef std::list Children; - friend void synfig::optimize_layers(Context, Canvas::Handle); + friend void synfig::optimize_layers(Time, Context, Canvas::Handle, bool seen_motion_blur); /* -- ** -- D A T A ------------------------------------------------------------- @@ -87,6 +150,10 @@ private: /*! \see set_description(), get_description() */ String description_; + //! Contains the canvas' version string + /*! \see set_version(), get_version() */ + String version_; + //! Contains the author's name /*! \see set_author(), get_author() */ String author_; @@ -118,8 +185,8 @@ private: //! List containing any child Canvases /*! \see children() */ - Children children_; - + Children children_; + //! Render Description for Canvas /*! \see rend_desc() */ RendDesc desc_; @@ -129,16 +196,19 @@ private: //! \writeme mutable std::map externals_; - + //! This flag is set if this canvas is "inline" bool is_inline_; mutable bool is_dirty_; - + bool op_flag_; - + //! Layer Group database - std::map > > group_db_; + std::map > > group_db_; + + //! Layer Connection database + std::map,std::vector > connections_; /* -- ** -- S I G N A L S ------------------------------------------------------- @@ -147,45 +217,47 @@ private: private: //! Group Added - sigc::signal signal_group_added_; + sigc::signal signal_group_added_; //! Group Removed - sigc::signal signal_group_removed_; - + sigc::signal signal_group_removed_; + //! Group Changed - sigc::signal signal_group_changed_; + sigc::signal signal_group_changed_; sigc::signal > signal_group_pair_added_; sigc::signal > signal_group_pair_removed_; //! Layers Reordered - sigc::signal signal_layers_reordered_; - + sigc::signal signal_layers_reordered_; + //! RendDesc Changed - sigc::signal signal_rend_desc_changed_; - + sigc::signal signal_rend_desc_changed_; + //! ID Changed - sigc::signal signal_id_changed_; + sigc::signal signal_id_changed_; //! Dirty - //sigc::signal signal_dirty_; + //sigc::signal signal_dirty_; //! FileName Changed - sigc::signal signal_file_name_changed_; + sigc::signal signal_file_name_changed_; //! Metadata Changed - sigc::signal signal_meta_data_changed_; + sigc::signal signal_meta_data_changed_; //! Key-Specific meta data changed signals std::map > signal_map_meta_data_changed_; //! ValueBasenode Changed - sigc::signal > signal_value_node_changed_; + sigc::signal > signal_value_node_changed_; + + sigc::signal > signal_value_node_renamed_; - sigc::signal, etl::handle > signal_value_node_child_added_; + sigc::signal, etl::handle > signal_value_node_child_added_; - sigc::signal, etl::handle > signal_value_node_child_removed_; + sigc::signal, etl::handle > signal_value_node_child_removed_; /* -- ** -- S I G N A L I N T E R F A C E ------------------------------------- @@ -201,30 +273,32 @@ public: //! Group Removed sigc::signal& signal_group_removed() { return signal_group_removed_; } - + //! Group Changed sigc::signal& signal_group_changed() { return signal_group_changed_; } //! Layers Reordered sigc::signal& signal_layers_reordered() { return signal_layers_reordered_; } - + //! RendDesc Changed sigc::signal& signal_rend_desc_changed() { return signal_rend_desc_changed_; } - + //! ID Changed sigc::signal& signal_id_changed() { return signal_id_changed_; } //! File name Changed sigc::signal& signal_file_name_changed(); - + //! Metadata Changed sigc::signal& signal_meta_data_changed() { return signal_meta_data_changed_; } //! Metadata Changed sigc::signal& signal_meta_data_changed(const String& key) { return signal_map_meta_data_changed_[key]; } - - sigc::signal >& signal_value_node_changed() { return signal_value_node_changed_; } + + sigc::signal >& signal_value_node_changed() { return signal_value_node_changed_; } + + sigc::signal >& signal_value_node_renamed() { return signal_value_node_renamed_; } //! Dirty sigc::signal& signal_dirty() { return signal_changed(); } @@ -255,10 +329,10 @@ public: //! Returns the set of layers in group std::set > get_layers_in_group(const String&group); - + //! Gets all the groups std::set get_groups()const; - + //! Gets the number of groups in this canvas int get_group_count()const; @@ -280,6 +354,12 @@ public: //! Sets the name of the canvas void set_name(const String &x); + //! Gets the version string of the canvas + const String get_version()const { return version_; } + + //! Sets the version string of the canvas + void set_version(const String &x) { version_ = x; } + //! Gets the author of the canvas const String & get_author()const { return author_; } @@ -297,7 +377,7 @@ public: //! Sets the ID of the canvas void set_id(const String &x); - + //! Returns the data string for the given meta data key String get_meta_data(const String& key)const; @@ -324,7 +404,7 @@ public: LooseHandle parent()const { return parent_; } LooseHandle get_root()const; - + //! Returns a list of all child canvases in this canvas std::list &children() { return children_; } @@ -379,7 +459,7 @@ public: //! \writeme void add_value_node(ValueNode::Handle x, const String &id); - //! \writeme + //! writeme //void rename_value_node(ValueNode::Handle x, const String &id); //! \writeme @@ -393,19 +473,19 @@ public: ** If not found, it creates a new Canvas and returns it ** If an error occurs, it returns an empty handle */ - Handle surefind_canvas(const String &id); + Handle surefind_canvas(const String &id,String &warnings); //! Finds a child Canvas in the Canvas with the given \a id /*! \return If found, returns a handle to the child Canvas. ** Otherwise, returns an empty handle. */ - Handle find_canvas(const String &id); + Handle find_canvas(const String &id, String &warnings); //! Finds a child Canvas in the Canvas with the given \a id /*! \return If found, returns a handle to the child Canvas. ** Otherwise, returns an empty handle. */ - ConstHandle find_canvas(const String &id)const; + ConstHandle find_canvas(const String &id, String &warnings)const; //! Sets the file path for the Canvas //void set_file_path(const String &); @@ -418,11 +498,11 @@ public: //! Gets the filename (with path) String get_file_name()const; - + //! Creates a new child canvas, and returns its handle Handle new_child_canvas(); - //! Creates a new child canvas with an ID of \aid, and returns its handle + //! Creates a new child canvas with an ID of \a id, and returns its handle Handle new_child_canvas(const String &id); //! Adds the given canvas as a child @@ -445,7 +525,7 @@ public: const_reverse_iterator rbegin()const; etl::handle &back(); - + void push_back(etl::handle x); void push_front(etl::handle x); @@ -454,7 +534,7 @@ public: void insert(iterator iter,etl::handle x); void erase(iterator iter); - + const etl::handle &back()const; void set_inline(LooseHandle parent); @@ -462,19 +542,27 @@ public: static Handle create(); static Handle create_inline(Handle parent); - + Handle clone(const GUID& deriv_guid=GUID())const; + void register_external_canvas(String file, Handle canvas); + +#ifdef _DEBUG + void show_externals(String file, int line, String text) const; +#endif // _DEBUG + private: void add_group_pair(String group, etl::handle layer); void remove_group_pair(String group, etl::handle layer); + void add_connection(etl::loose_handle layer, sigc::connection connection); + void disconnect_connections(etl::loose_handle layer); protected: virtual void on_changed(); virtual void get_times_vfunc(Node::time_set &set) const; }; // END of class Canvas -void optimize_layers(Context context, Canvas::Handle op_canvas); +void optimize_layers(Time time, Context context, Canvas::Handle op_canvas, bool seen_motion_blur=false); }; // END of namespace synfig