X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Faction.h;h=1dec9c57eed879457d73274b00738aeda45870ed;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=c2c9265387a57aaed9eb6c688fef5227f6ea22b4;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/action.h b/synfig-studio/trunk/src/synfigapp/action.h index c2c9265..1dec9c5 100644 --- a/synfig-studio/trunk/src/synfigapp/action.h +++ b/synfig-studio/trunk/src/synfigapp/action.h @@ -2,19 +2,21 @@ /*! \file action.h ** \brief Template File ** -** $Id: action.h,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 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 */ /* ========================================================================= */ @@ -73,10 +75,14 @@ #define ACTION_SET_CVS_ID(class,x) const char class::cvs_id__[]=x -#define ACTION_INIT(class) \ - Action::Base* class::create() { return new class(); } \ - synfig::String class::get_name()const { return name__; } \ - synfig::String class::get_local_name()const { return local_name__; } \ +//! don't define get_local_name() - allow the action code to define its own +#define ACTION_INIT_NO_GET_LOCAL_NAME(class) \ + Action::Base* class::create() { return new class(); } \ + synfig::String class::get_name()const { return name__; } + +#define ACTION_INIT(class) \ + ACTION_INIT_NO_GET_LOCAL_NAME(class) \ + synfig::String class::get_local_name()const { return dgettext("synfigstudio",local_name__); } /* === T Y P E D E F S ===================================================== */ @@ -91,11 +97,11 @@ namespace synfigapp { class Instance; class Main; - -namespace Action { + +namespace Action { class System; - + //! Exception class, thrown when redoing or undoing an action class Error @@ -118,7 +124,7 @@ private: synfig::String desc_; public: - + Error(Type type, const char *format, ...): type_(type) { @@ -139,10 +145,10 @@ public: type_(type) { } - + Type get_type()const { return type_; } synfig::String get_desc()const { return desc_; } - + }; // END of class Action::Error class Param; @@ -162,11 +168,12 @@ enum Category CATEGORY_VALUENODE =(1<<5), CATEGORY_KEYFRAME =(1<<6), CATEGORY_GROUP =(1<<7), + CATEGORY_BEZIER =(1<<8), CATEGORY_OTHER =(1<<12), CATEGORY_DRAG =(1<<24), - + CATEGORY_HIDDEN =(1<<31), CATEGORY_ALL =(~0)-(1<<31) //!< All categories (EXCEPT HIDDEN) }; // END of enum Category @@ -176,40 +183,42 @@ inline Category operator|(Category lhs, Category rhs) -//! Action Base Class +//! Top-level base class for all actions /*! An action should implement the following functions: -** static bool is_canidate(const ParamList &x); +** - static bool is_candidate(const ParamList &x); ** - Checks the ParamList to see if this action could be performed. -** static ParamVocab get_param_vocab(); +** - static ParamVocab get_param_vocab(); ** - Yields the ParamVocab object which describes what ** this action needs before it can perform the act. -** static Action::Base* create(); +** - static Action::Base* create(); ** - Factory for creating this action from a ParamList ** */ -class Base : public etl::shared_object +class Base : public etl::shared_object { protected: Base() { } - + public: virtual ~Base() { }; //! This function will throw an Action::Error() on failure virtual void perform()=0; - - virtual bool set_param(const synfig::String& name, const Param &) { return false; } + + virtual bool set_param(const synfig::String& /*name*/, const Param &) { return false; } virtual bool is_ready()const=0; - + virtual synfig::String get_name()const =0; virtual synfig::String get_local_name()const { return get_name(); } void set_param_list(const ParamList &); - + + static synfig::String get_layer_descriptions(const std::list layers, synfig::String singular_prefix = "", synfig::String plural_prefix = ""); + static synfig::String get_layer_descriptions(const std::list > layers, synfig::String singular_prefix = "", synfig::String plural_prefix = ""); }; // END of class Action::Base typedef Action::Base* (*Factory)(); -typedef bool (*CanidateChecker)(const ParamList &x); +typedef bool (*CandidateChecker)(const ParamList &x); typedef ParamVocab (*GetParamVocab)(); typedef etl::handle Handle; @@ -236,7 +245,7 @@ public: }; // END of class Action::Undoable //! Action base class for canvas-specific actions -class CanvasSpecific +class CanvasSpecific { private: bool is_dirty_; @@ -247,11 +256,11 @@ private: protected: CanvasSpecific(const synfig::Canvas::Handle &canvas):is_dirty_(true),mode_(MODE_UNDEFINED),canvas_(canvas) { } - CanvasSpecific():mode_(MODE_UNDEFINED) { } + CanvasSpecific():is_dirty_(true), mode_(MODE_UNDEFINED) { } virtual ~CanvasSpecific() { }; - - + + public: void set_canvas(synfig::Canvas::Handle x) { canvas_=x; } @@ -267,10 +276,10 @@ public: EditMode get_edit_mode()const; void set_edit_mode(EditMode x) { mode_=x; } - + bool is_dirty()const { return is_dirty_; } void set_dirty(bool x=true) { is_dirty_=x; } - + }; // END of class Action::Undoable typedef std::list< etl::handle > ActionList; @@ -293,9 +302,9 @@ public: virtual void prepare()=0; void clear() { action_list().clear(); } - + bool first_time()const { return action_list_.empty(); } - + void add_action(etl::handle action); void add_action_front(etl::handle action); @@ -321,7 +330,7 @@ public: virtual void prepare() { }; - virtual bool set_param(const synfig::String& name, const Param &)const { return false; } + virtual bool set_param(const synfig::String& /*name*/, const Param &)const { return false; } virtual bool is_ready()const { return ready_; } void set_name(std::string&x) { name_=x; } @@ -340,27 +349,27 @@ struct BookEntry int priority; Category category; Factory factory; - CanidateChecker is_canidate; - GetParamVocab get_param_vocab; - + CandidateChecker is_candidate; + GetParamVocab get_param_vocab; + bool operator<(const BookEntry &rhs)const { return priority Book; -class CanidateList : public std::list +class CandidateList : public std::list { public: iterator find(const synfig::String& x); - const_iterator find(const synfig::String& x)const { return const_cast(this)->find(x); } + const_iterator find(const synfig::String& x)const { return const_cast(this)->find(x); } }; Book& book(); Handle create(const synfig::String &name); -//! Compiles a list of potential canidate actions with the given \a param_list and \a category -CanidateList compile_canidate_list(const ParamList& param_list, Category category=CATEGORY_ALL); +//! Compiles a list of potential candidate actions with the given \a param_list and \a category +CandidateList compile_candidate_list(const ParamList& param_list, Category category=CATEGORY_ALL); /*! \class synfigapp::Action::Main ** \brief \writeme