X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fduckmatic.h;h=b8d8247b8ef6f27dfcb0bb21ebc464345c140971;hb=392b62fa87099d8576a9da614be431a5046fe595;hp=3ed164e824a4fba31b73fa9e29017257f31f8f2f;hpb=3a3c4bca3a17137bec5d7960560934b91ef4146e;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/duckmatic.h b/synfig-studio/trunk/src/gtkmm/duckmatic.h index 3ed164e..b8d8247 100644 --- a/synfig-studio/trunk/src/gtkmm/duckmatic.h +++ b/synfig-studio/trunk/src/gtkmm/duckmatic.h @@ -1,28 +1,30 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file duckmatic.h ** \brief Template Header ** -** $Id: duckmatic.h,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 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 */ /* ========================================================================= */ /* === S T A R T =========================================================== */ -#ifndef __SINFG_STUDIO_DUCKMATIC_H -#define __SINFG_STUDIO_DUCKMATIC_H +#ifndef __SYNFIG_STUDIO_DUCKMATIC_H +#define __SYNFIG_STUDIO_DUCKMATIC_H /* === H E A D E R S ======================================================= */ @@ -33,32 +35,30 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include -#include -#include +#include +#include #include #include "duck.h" -#include -#include +#include +#include /* === M A C R O S ========================================================= */ -#define HASH_MAP_H - #ifdef HASH_MAP_H #include HASH_MAP_H #ifndef __STRING_HASH__ #define __STRING_HASH__ class StringHash { - __gnu_cxx::hash hasher_; + HASH_MAP_NAMESPACE::hash hasher_; public: - size_t operator()(const sinfg::String& x)const + size_t operator()(const synfig::String& x)const { return hasher_(x.c_str()); } @@ -72,34 +72,34 @@ public: /* === C L A S S E S & S T R U C T S ======================================= */ -namespace sinfgapp { class ValueDesc; } -namespace sinfg { class ParamDesc; } +namespace synfigapp { class ValueDesc; } +namespace synfig { class ParamDesc; } namespace studio { class CanvasView; class Duckmatic; - + class DuckDrag_Base : public etl::shared_object { public: - virtual void begin_duck_drag(Duckmatic* duckmatic, const sinfg::Vector& begin)=0; + virtual void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin)=0; virtual bool end_duck_drag(Duckmatic* duckmatic)=0; - virtual void duck_drag(Duckmatic* duckmatic, const sinfg::Vector& vector)=0; + virtual void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)=0; }; class DuckDrag_Translate : public DuckDrag_Base { - sinfg::Vector last_translate_; - sinfg::Vector drag_offset_; - sinfg::Vector snap; - std::vector positions; + synfig::Vector last_translate_; + synfig::Vector drag_offset_; + synfig::Vector snap; + std::vector positions; public: - void begin_duck_drag(Duckmatic* duckmatic, const sinfg::Vector& begin); + void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin); bool end_duck_drag(Duckmatic* duckmatic); - void duck_drag(Duckmatic* duckmatic, const sinfg::Vector& vector); + void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector); }; /*! \class Duckmatic @@ -114,17 +114,17 @@ class Duckmatic { friend class DuckDrag_Base; friend class DuckDrag_Translate; - + /* -- ** -- P U B L I C T Y P E S --------------------------------------------- */ - + public: #ifdef HASH_MAP_H -typedef __gnu_cxx::hash_map,sinfg::GUIDHash> DuckDataMap; +typedef HASH_MAP_CLASS,synfig::GUIDHash> DuckDataMap; #else -typedef std::map > DuckDataMap; +typedef std::map > DuckDataMap; #endif typedef studio::DuckMap DuckMap; @@ -136,13 +136,13 @@ typedef std::map > DuckDataMap; struct Bezier; class Push; - + friend class Push; - + typedef Duck::Type Type; - + typedef std::list GuideList; - + /* -- ** -- P R I V A T E D A T A --------------------------------------------- */ @@ -157,16 +157,16 @@ private: std::list > stroke_list_; - std::list > persistant_stroke_list_; + std::list > persistent_stroke_list_; - sinfg::GUIDSet selected_ducks; + synfig::GUIDSet selected_ducks; - sinfg::GUID last_duck_guid; + synfig::GUID last_duck_guid; - std::list > bezier_list_; + std::list > bezier_list_; //! I cannot recall what this is for - //sinfg::Vector snap; + //synfig::Vector snap; etl::handle duck_dragger_; @@ -177,12 +177,12 @@ private: sigc::signal signal_grid_changed_; mutable sigc::signal signal_sketch_saved_; - + GuideList guide_list_x_; GuideList guide_list_y_; - mutable sinfg::String sketch_filename_; - + mutable synfig::String sketch_filename_; + /* -- ** -- P R O T E C T E D D A T A ----------------------------------------- */ @@ -191,7 +191,7 @@ protected: etl::handle selected_bezier; - sinfg::Time cur_time; + synfig::Time cur_time; //! This flag is set if operations should snap to the grid /*! \todo perhaps there should be two of these flags, one for each axis? @@ -202,21 +202,21 @@ protected: //! This vector describes the grid size. /*! \see grid_snap, show_grid */ - sinfg::Vector grid_size; + synfig::Vector grid_size; - bool show_persistant_strokes; + bool show_persistent_strokes; bool axis_lock; - + /* -- ** -- P R I V A T E M E T H O D S --------------------------------------- */ private: - - sinfg::Vector last_translate_; - sinfg::Vector drag_offset_; - + + synfig::Vector last_translate_; + synfig::Vector drag_offset_; + //etl::handle selected_duck; @@ -225,7 +225,7 @@ private: */ public: - + Duckmatic(); virtual ~Duckmatic(); @@ -242,62 +242,62 @@ public: void set_guide_snap(bool x=true); bool get_guide_snap()const { return guide_snap; } void toggle_guide_snap() { set_guide_snap(!get_guide_snap()); } - + //! Sets the state of the grid snap flag void set_grid_snap(bool x=true); - + //! Gets the state of the grid snap flag bool get_grid_snap()const { return grid_snap; } - + void enable_grid_snap() { set_grid_snap(true); } void disable_grid_snap() { set_grid_snap(false); } void toggle_grid_snap() { set_grid_snap(!grid_snap); } - sinfg::Point snap_point_to_grid(const sinfg::Point& x, float radius=0.1)const; - - bool get_show_persistant_strokes()const { return show_persistant_strokes; } - void set_show_persistant_strokes(bool x); + synfig::Point snap_point_to_grid(const synfig::Point& x, float radius=0.1)const; + + bool get_show_persistent_strokes()const { return show_persistent_strokes; } + void set_show_persistent_strokes(bool x); //! Sets the size of the grid - void set_grid_size(const sinfg::Vector &s); - + void set_grid_size(const synfig::Vector &s); + //! Returns the size of the grid - const sinfg::Vector &get_grid_size()const { return grid_size; } - - - const sinfg::Time &get_time()const { return cur_time; } + const synfig::Vector &get_grid_size()const { return grid_size; } + + + const synfig::Time &get_time()const { return cur_time; } bool get_axis_lock()const { return axis_lock; } void set_axis_lock(bool x) { axis_lock=x; } - - void set_time(sinfg::Time x) { cur_time=x; } + + void set_time(synfig::Time x) { cur_time=x; } bool is_duck_group_selectable(const etl::handle& x)const; - - //const DuckMap& duck_map()const { return duck_map; } + + //const DuckMap& duck_map()const { return duck_map; } DuckList get_duck_list()const; - - const std::list >& bezier_list()const { return bezier_list_; } + + const std::list >& bezier_list()const { return bezier_list_; } const std::list >& stroke_list()const { return stroke_list_; } - const std::list >& persistant_stroke_list()const { return persistant_stroke_list_; } + const std::list >& persistent_stroke_list()const { return persistent_stroke_list_; } - std::list >& persistant_stroke_list() { return persistant_stroke_list_; } + std::list >& persistent_stroke_list() { return persistent_stroke_list_; } //! \todo We should modify this to support multiple selections etl::handle get_selected_duck()const; DuckList get_selected_ducks()const; - + //! Returns \a true if the given duck is currently selected bool duck_is_selected(const etl::handle &duck)const; void refresh_selected_ducks(); - + void clear_selected_ducks(); int count_selected_ducks()const; @@ -305,28 +305,30 @@ public: void toggle_select_duck(const etl::handle &duck); void select_duck(const etl::handle &duck); - - void select_ducks_in_box(const sinfg::Vector& tl,const sinfg::Vector& br); + + void toggle_select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br); + + void select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br); void unselect_duck(const etl::handle &duck); - void start_duck_drag(const sinfg::Vector& offset); - void translate_selected_ducks(const sinfg::Vector& vector); + void start_duck_drag(const synfig::Vector& offset); + void translate_selected_ducks(const synfig::Vector& vector); bool end_duck_drag(); - void signal_edited_selected_ducks(); + void signal_edited_selected_ducks(); + + void signal_user_click_selected_ducks(int button); - void signal_user_click_selected_ducks(int button); - etl::handle find_similar_duck(etl::handle duck); etl::handle add_similar_duck(etl::handle duck); - - void add_stroke(etl::smart_ptr > stroke_point_list, const sinfg::Color& color=sinfg::Color(0,0,0)); - void add_persistant_stroke(etl::smart_ptr > stroke_point_list, const sinfg::Color& color=sinfg::Color(0,0,0)); + void add_stroke(etl::smart_ptr > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0)); - void clear_persistant_strokes(); + void add_persistent_stroke(etl::smart_ptr > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0)); + + void clear_persistent_strokes(); void add_duck(const etl::handle &duck); @@ -340,27 +342,27 @@ public: etl::handle last_duck()const; etl::handle last_bezier()const; - + //! \note parameter is in canvas coordinates /*! A radius of "zero" will have an unlimited radius */ - etl::handle find_duck(sinfg::Point pos, sinfg::Real radius=0, Duck::Type type=Duck::TYPE_DEFAULT); + etl::handle find_duck(synfig::Point pos, synfig::Real radius=0, Duck::Type type=Duck::TYPE_DEFAULT); + + GuideList::iterator find_guide_x(synfig::Point pos, float radius=0.1); + GuideList::iterator find_guide_y(synfig::Point pos, float radius=0.1); + GuideList::const_iterator find_guide_x(synfig::Point pos, float radius=0.1)const { return const_cast(this)->find_guide_x(pos,radius); } + GuideList::const_iterator find_guide_y(synfig::Point pos, float radius=0.1)const { return const_cast(this)->find_guide_y(pos,radius); } - GuideList::iterator find_guide_x(sinfg::Point pos, float radius=0.1); - GuideList::iterator find_guide_y(sinfg::Point pos, float radius=0.1); - GuideList::const_iterator find_guide_x(sinfg::Point pos, float radius=0.1)const { return const_cast(this)->find_guide_x(pos,radius); } - GuideList::const_iterator find_guide_y(sinfg::Point pos, float radius=0.1)const { return const_cast(this)->find_guide_y(pos,radius); } - //! \note parameter is in canvas coordinates /*! A radius of "zero" will have an unlimited radius */ - //etl::handle find_bezier(sinfg::Point pos, sinfg::Real radius=0); + //etl::handle find_bezier(synfig::Point pos, synfig::Real radius=0); //! \note parameter is in canvas coordinates /*! A radius of "zero" will have an unlimited radius */ - etl::handle find_bezier(sinfg::Point pos, sinfg::Real radius=0, float* location=0); - - etl::handle find_bezier(sinfg::Point pos, sinfg::Real scale, sinfg::Real radius, float* location=0); - - bool add_to_ducks(const sinfgapp::ValueDesc& value_desc,etl::handle canvas_view, const sinfg::TransformStack& transform_stack_, sinfg::ParamDesc *param_desc=0, int multiple=0); + etl::handle find_bezier(synfig::Point pos, synfig::Real radius=0, float* location=0); + + etl::handle find_bezier(synfig::Point pos, synfig::Real scale, synfig::Real radius, float* location=0); + + bool add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle canvas_view, const synfig::TransformStack& transform_stack_, synfig::ParamDesc *param_desc=0, int multiple=0); //! \writeme void set_type_mask(Type x) { type_mask=x; } @@ -371,10 +373,10 @@ public: void select_all_ducks(); void clear_ducks(); - - bool save_sketch(const sinfg::String& filename)const; - bool load_sketch(const sinfg::String& filename); - const sinfg::String& get_sketch_filename()const { return sketch_filename_; } + + bool save_sketch(const synfig::String& filename)const; + bool load_sketch(const synfig::String& filename); + const synfig::String& get_sketch_filename()const { return sketch_filename_; } void set_duck_dragger(etl::handle x) { duck_dragger_=x; } etl::handle get_duck_dragger()const { return duck_dragger_; } @@ -387,14 +389,14 @@ public: class Duckmatic::Push { Duckmatic *duckmatic_; - DuckMap duck_map; + DuckMap duck_map; std::list > bezier_list_; std::list > stroke_list_; DuckDataMap duck_data_share_map; etl::handle duck_dragger_; - + bool needs_restore; - + public: Push(Duckmatic *duckmatic_); ~Push(); @@ -408,7 +410,7 @@ struct Duckmatic::Bezier : public etl::shared_object private: sigc::signal signal_user_click_[5]; public: - + etl::handle p1,p2,c1,c2; bool is_valid()const { return p1 && p2 && c1 && c2; } @@ -422,15 +424,15 @@ struct Duckmatic::Stroke : public etl::shared_object private: sigc::signal signal_user_click_[5]; public: - - etl::smart_ptr > stroke_data; - sinfg::Color color; + etl::smart_ptr > stroke_data; + + synfig::Color color; bool is_valid()const { return (bool)stroke_data; } sigc::signal &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; } -}; // END of struct Duckmatic::Bezier +}; // END of struct Duckmatic::Stroke }; // END of namespace studio