PALETTE_HH = \
- mod_palette/dock_palbrowse.h \
- mod_palette/dock_paledit.h \
- mod_palette/mod_palette.h
+ modules/mod_palette/dock_palbrowse.h \
+ modules/mod_palette/dock_paledit.h \
+ modules/mod_palette/mod_palette.h
PALETTE_CC = \
- mod_palette/dock_palbrowse.cpp \
- mod_palette/dock_paledit.cpp \
- mod_palette/mod_palette.cpp
-
-
-MOD_MIRROR_HH = \
- mod_mirror/mod_mirror.h \
- mod_mirror/state_mirror.h
-
-MOD_MIRROR_CC = \
- mod_mirror/mod_mirror.cpp \
- mod_mirror/state_mirror.cpp
+ modules/mod_palette/dock_palbrowse.cpp \
+ modules/mod_palette/dock_paledit.cpp \
+ modules/mod_palette/mod_palette.cpp
DIALOG_HH = \
state_eyedrop.h \
state_fill.h \
state_gradient.h \
+ state_mirror.h \
state_normal.h \
state_polygon.h \
state_rectangle.h \
state_eyedrop.cpp \
state_fill.cpp \
state_gradient.cpp \
+ state_mirror.cpp \
state_normal.cpp \
state_polygon.cpp \
state_rectangle.cpp \
instance.h \
ipc.h \
keymapsettings.h \
- module.h \
+ modules/module.h \
onemoment.h \
preview.h \
renddesc.h \
instance.cpp \
ipc.cpp \
keymapsettings.cpp \
- module.cpp \
+ modules/module.cpp \
onemoment.cpp \
preview.cpp \
renddesc.cpp \
bin_PROGRAMS = synfigstudio
synfigstudio_SOURCES = \
- $(MOD_MIRROR_CC) \
- $(MOD_MIRROR_HH) \
$(PALETTE_CC) \
$(PALETTE_HH) \
$(WORKAREARENDERER_CC) \
#include "state_eyedrop.h"
#include "state_normal.h"
+#include "state_mirror.h"
#include "state_draw.h"
#include "state_fill.h"
#include "state_bline.h"
#include "dock_timetrack.h"
#include "dock_curves.h"
-#include "mod_palette/mod_palette.h"
-#include "mod_mirror/mod_mirror.h"
+#include "modules/module.h"
+#include "modules/mod_palette/mod_palette.h"
#include <sys/stat.h>
#include "ipc.h"
-#include "module.h"
-
#include "statemanager.h"
#ifdef WITH_FMOD
state_manager->add_state(&state_smooth_move);
state_manager->add_state(&state_scale);
state_manager->add_state(&state_rotate);
- studio_init_cb.task(_("Init ModMirror...")); module_list_.push_back(new ModMirror()); module_list_.back()->start();
+ state_manager->add_state(&state_mirror);
if(!getenv("SYNFIG_DISABLE_WIDTH" )) state_manager->add_state(&state_width); // Enabled since 0.61.09
/* new objects */
#include "state_bline.h"
#include "state_normal.h"
#include "state_eyedrop.h"
-#include "state_draw.h"
#include "ducktransform_scale.h"
#include "ducktransform_translate.h"
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file mod_mirror.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "mod_mirror.h"
-#include "state_mirror.h"
-
-#include "../app.h"
-#include "../statemanager.h"
-
-#include "../general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-bool
-studio::ModMirror::start_vfunc()
-{
- App::get_state_manager()->add_state(&state_mirror);
- return true;
-}
-
-bool
-studio::ModMirror::stop_vfunc()
-{
- return true;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file mod_mirror.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_MOD_MIRROR_H
-#define __SYNFIG_MOD_MIRROR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include "../module.h"
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace studio {
-
-class State_Mirror;
-
-class ModMirror : public Module
-{
- friend class State_Mirror;
-
-protected:
- virtual bool start_vfunc();
- virtual bool stop_vfunc();
-
-public:
- virtual ~ModMirror() { stop(); }
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file state_mirror.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2009 Nikita Kitaev
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_mirror.h"
-#include "../state_normal.h"
-#include "../canvasview.h"
-#include "../workarea.h"
-#include "../app.h"
-
-#include <synfigapp/action.h>
-#include "../event_mouse.h"
-#include "../event_layerclick.h"
-#include "../toolbox.h"
-#include "../dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "../duck.h"
-#include <synfigapp/main.h>
-
-#include "../general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-enum Axis {
- AXIS_X,
- AXIS_Y
-} ;
-
-/* === G L O B A L S ======================================================= */
-
-StateMirror studio::state_mirror;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class DuckDrag_Mirror : public DuckDrag_Base
-{
- synfig::Vector center;
-
- std::vector<synfig::Vector> positions;
-
-public:
- Axis axis;
-
- DuckDrag_Mirror();
- void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin);
- bool end_duck_drag(Duckmatic* duckmatic);
- void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector);
-};
-
-class studio::StateMirror_Context : public sigc::trackable
-{
- etl::handle<CanvasView> canvas_view_;
- CanvasView::IsWorking is_working;
-
- synfigapp::Settings& settings;
-
- sigc::connection keypress_connect;
- sigc::connection keyrelease_connect;
-
- etl::handle<DuckDrag_Mirror> duck_dragger_;
-
- Gtk::Table options_table;
-
- Gtk::RadioButton::Group radiobutton_group;
- Gtk::RadioButton radiobutton_axis_x;
- Gtk::RadioButton radiobutton_axis_y;
-
-public:
-
- Axis get_axis()const { return radiobutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
- void set_axis(Axis a)
- {
- if(a==AXIS_X)
- radiobutton_axis_x.set_active(true);
- else
- radiobutton_axis_y.set_active(true);
-
- duck_dragger_->axis=get_axis();
- }
-
- void update_axes()
- {
- duck_dragger_->axis=get_axis();
- get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW);
- }
-
- Smach::event_result event_stop_handler(const Smach::event& x);
- Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
- void refresh_tool_options();
-
- StateMirror_Context(CanvasView* canvas_view);
-
- ~StateMirror_Context();
-
- const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
- etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
- synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
- WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
-
- void load_settings();
- void save_settings();
-
- bool key_event(GdkEventKey *event);
-}; // END of class StateMirror_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateMirror::StateMirror():
- Smach::state<StateMirror_Context>("mirror")
-{
- insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateMirror_Context::event_refresh_tool_options));
- insert(event_def(EVENT_STOP,&StateMirror_Context::event_stop_handler));
-}
-
-StateMirror::~StateMirror()
-{
-}
-
-void
-StateMirror_Context::load_settings()
-{
- String value;
-
- settings.get_value("mirror.axis",value);
- set_axis((Axis)atoi(value.c_str()));
-}
-
-void
-StateMirror_Context::save_settings()
-{
- settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
-}
-
-StateMirror_Context::StateMirror_Context(CanvasView* canvas_view):
- canvas_view_(canvas_view),
- is_working(*canvas_view),
- settings(synfigapp::Main::get_selected_input_device()->settings()),
- duck_dragger_(new DuckDrag_Mirror()),
- radiobutton_axis_x(radiobutton_group,_("Horizontal")),
- radiobutton_axis_y(radiobutton_group,_("Vertical"))
-{
- // Set up the tool options dialog
- options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(radiobutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(radiobutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(*manage(new Gtk::Label(_("(Shift key toggles axis)"))), 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
- radiobutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
- radiobutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
-
- options_table.show_all();
- refresh_tool_options();
- App::dialog_tool_options->present();
-
- get_work_area()->set_allow_layer_clicks(true);
- get_work_area()->set_duck_dragger(duck_dragger_);
-
- keypress_connect=get_work_area()->signal_key_press_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false);
- keyrelease_connect=get_work_area()->signal_key_release_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false);
-
- get_work_area()->set_cursor(Gdk::SB_H_DOUBLE_ARROW);
-// get_work_area()->reset_cursor();
-
- App::toolbox->refresh();
-
- set_axis(AXIS_X);
- load_settings();
-}
-
-bool
-StateMirror_Context::key_event(GdkEventKey *event)
-{
- if (event->keyval==GDK_Shift_L || event->keyval==GDK_Shift_R )
- {
- set_axis(get_axis()==AXIS_X ? AXIS_Y:AXIS_X);
- get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW);
- }
-
- return false; //Pass on the event to other handlers, just in case
-}
-
-void
-StateMirror_Context::refresh_tool_options()
-{
- App::dialog_tool_options->clear();
- App::dialog_tool_options->set_widget(options_table);
- App::dialog_tool_options->set_local_name(_("Mirror Tool"));
- App::dialog_tool_options->set_name("mirror");
-}
-
-Smach::event_result
-StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
- refresh_tool_options();
- return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateMirror_Context::event_stop_handler(const Smach::event& /*x*/)
-{
- throw &state_normal;
- return Smach::RESULT_OK;
-}
-
-StateMirror_Context::~StateMirror_Context()
-{
- save_settings();
-
- get_work_area()->clear_duck_dragger();
- get_work_area()->reset_cursor();
-
- keypress_connect.disconnect();
- keyrelease_connect.disconnect();
-
- App::dialog_tool_options->clear();
-
- App::toolbox->refresh();
-}
-
-DuckDrag_Mirror::DuckDrag_Mirror():
- axis(AXIS_X)
-{
-}
-
-#ifndef EPSILON
-#define EPSILON 0.0000001
-#endif
-
-void
-DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& /*offset*/)
-{
- const DuckList selected_ducks(duckmatic->get_selected_ducks());
- DuckList::const_iterator iter;
-
- positions.clear();
- int i;
- for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
- {
- Point p((*iter)->get_trans_point());
- positions.push_back(p);
- }
-
-}
-
-void
-DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
-{
- center=vector;
- int i;
-
- const DuckList selected_ducks(duckmatic->get_selected_ducks());
- DuckList::const_iterator iter;
-
- Time time(duckmatic->get_time());
-
- // do the Vertex and Position ducks first
- for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
- if ((*iter)->get_type() == Duck::TYPE_VERTEX ||
- (*iter)->get_type() == Duck::TYPE_POSITION)
- {
- Vector p(positions[i]);
-
- if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
- else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
-
- (*iter)->set_trans_point(p);
- }
-
- // then do the other ducks
- for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
- if ((*iter)->get_type() != Duck::TYPE_VERTEX &&
- (*iter)->get_type() != Duck::TYPE_POSITION)
- {
- // we don't need to mirror radius ducks - they're one-dimensional
- if ((*iter)->is_radius())
- continue;
-
- Vector p(positions[i]);
-
- if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
- else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
-
- (*iter)->set_trans_point(p);
- }
-}
-
-bool
-DuckDrag_Mirror::end_duck_drag(Duckmatic* duckmatic)
-{
- duckmatic->signal_edited_selected_ducks();
- return true;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file state_mirror.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_STUDIO_STATE_MIRROR_H
-#define __SYNFIG_STUDIO_STATE_MIRROR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "../smach.h"
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace studio {
-
-class StateMirror_Context;
-
-class StateMirror : public Smach::state<StateMirror_Context>
-{
-public:
- StateMirror();
- ~StateMirror();
-}; // END of class StateMirror
-
-extern StateMirror state_mirror;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file dock_palbrowse.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "dock_palbrowse.h"
-#include "dock_paledit.h"
-#include "mod_palette.h"
-
-#include "../general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_PalBrowse::Dock_PalBrowse():
- Dockable("pal_browse",_("Palette Browser")/*,Gtk::StockID("gtk-select-color")*/)
-{
-}
-
-Dock_PalBrowse::~Dock_PalBrowse()
-{
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file dock_palbrowse.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
-#define __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "../dockable.h"
-#include <synfig/palette.h>
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace synfigapp {
-class CanvasInterface;
-};
-
-namespace studio {
-
-/*
-
-The palette browser was intended to be a way to manage and select a single
-palette from a set of palettes that you could save to files. The palette
-editor was for editing individual palettes. Unfortunately the palette
-browser was never implemented.
-
-*/
-
-class Dock_PalBrowse : public Dockable
-{
-public:
- Dock_PalBrowse();
- ~Dock_PalBrowse();
-}; // END of Dock_PalBrowse
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file dock_paledit.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "dock_paledit.h"
-#include "../widget_color.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <synfig/general.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "../widget_color.h"
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/menu.h>
-#include <synfigapp/main.h>
-#include "../app.h"
-#include "../dialog_color.h"
-
-#include "../general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-/*
-class studio::PaletteSettings : public synfigapp::Settings
-{
- Dock_PalEdit* dialog_palette;
- synfig::String name;
-public:
- PaletteSettings(Dock_PalEdit* window,const synfig::String& name):
- dialog_palette(window),
- name(name)
- {
- dialog_palette->dialog_settings.add_domain(this,name);
- }
-
- virtual ~PaletteSettings()
- {
- dialog_palette->dialog_settings.remove_domain(name);
- }
-
- virtual bool get_value(const synfig::String& key, synfig::String& value)const
- {
- int i(atoi(key.c_str()));
- if(i<0 || i>=dialog_palette->size())
- return false;
- Color c(dialog_palette->get_color(i));
- value=strprintf("%f %f %f %f",c.get_r(),c.get_g(),c.get_b(),c.get_a());
- return true;
- }
-
- virtual bool set_value(const synfig::String& key,const synfig::String& value)
- {
- int i(atoi(key.c_str()));
- if(i<0)
- return false;
- if(i>=dialog_palette->size())
- dialog_palette->palette_.resize(i+1);
- float r,g,b,a;
- if(!strscanf(value,"%f %f %f %f",&r,&g,&b,&a))
- return false;
- dialog_palette->set_color(Color(r,g,b,a),i);
- return true;
- }
-
- virtual KeyList get_key_list()const
- {
- synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
-
- int i;
- for(i=0;i<dialog_palette->size();i++)
- ret.push_back(strprintf("%03d",i));
- return ret;
- }
-};
-*/
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_PalEdit::Dock_PalEdit():
- Dockable("pal_edit",_("Palette Editor"),Gtk::StockID("gtk-select-color")),
- //palette_settings(new PaletteSettings(this,"colors")),
- table(2,2,false)
-{
- action_group=Gtk::ActionGroup::create("action_group_pal_edit");
- action_group->add(Gtk::Action::create(
- "palette-add-color",
- Gtk::StockID("gtk-add"),
- _("Add Color"),
- _("Add current outline color\nto the palette")
- ),
- sigc::mem_fun(
- *this,
- &Dock_PalEdit::on_add_pressed
- )
- );
-
- App::ui_manager()->insert_action_group(action_group);
-
- Glib::ustring ui_info =
- "<ui>"
- " <toolbar action='toolbar-palette'>"
- " <toolitem action='palette-add-color' />"
- " </toolbar>"
- "</ui>"
- ;
-
- App::ui_manager()->add_ui_from_string(ui_info);
-
- set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-palette")));
-
- /*
- add_button(
- Gtk::StockID("gtk-add"),
- _("Add current outline color\nto the palette")
- )->signal_clicked().connect(
- sigc::mem_fun(
- *this,
- &Dock_PalEdit::on_add_pressed
- )
- );
- */
-
- add(table);
- table.set_homogeneous(true);
-
- set_default_palette();
-
- show_all_children();
-}
-
-Dock_PalEdit::~Dock_PalEdit()
-{
- //delete palette_settings;
-}
-
-void
-Dock_PalEdit::set_palette(const synfig::Palette& x)
-{
- palette_=x;
- refresh();
-}
-
-void
-Dock_PalEdit::on_add_pressed()
-{
- add_color(synfigapp::Main::get_outline_color());
-}
-
-void
-Dock_PalEdit::show_menu(int i)
-{
- Gtk::Menu* menu(manage(new Gtk::Menu()));
- menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-
- menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"),
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::edit_color),
- i
- )
- ));
-
- menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::erase_color),
- i
- )
- ));
-
- menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-
- menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Load Default Palette"),
- sigc::mem_fun(*this,&studio::Dock_PalEdit::set_default_palette)
- ));
-
- menu->popup(3,gtk_get_current_event_time());
-}
-
-int
-Dock_PalEdit::add_color(const synfig::Color& x)
-{
- palette_.push_back(x);
- signal_changed()();
- refresh();
- return size()-1;
-}
-
-void
-Dock_PalEdit::set_color(synfig::Color x, int i)
-{
- palette_[i].color=x;
- signal_changed()();
- refresh();
-}
-
-Color
-Dock_PalEdit::get_color(int i)const
-{
- return palette_[i].color;
-}
-
-void
-Dock_PalEdit::erase_color(int i)
-{
- palette_.erase(palette_.begin()+i);
- signal_changed()();
- refresh();
-}
-
-void
-Dock_PalEdit::refresh()
-{
- const int width(12);
-
- // Clear the table
- table.foreach(sigc::mem_fun(table,&Gtk::Table::remove));
-
- for(int i=0;i<size();i++)
- {
- Widget_Color* widget_color(manage(new Widget_Color()));
- widget_color->set_value(get_color(i));
- widget_color->set_size_request(12,12);
- widget_color->signal_activate().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::select_fill_color),
- i
- )
- );
- widget_color->signal_middle_click().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::select_outline_color),
- i
- )
- );
- widget_color->signal_right_click().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::show_menu),
- i
- )
- );
- int c(i%width),r(i/width);
- table.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- }
- table.show_all();
- queue_draw();
-}
-
-
-void
-Dock_PalEdit::edit_color(int i)
-{
- App::dialog_color->reset();
- App::dialog_color->set_color(get_color(i));
- App::dialog_color->signal_edited().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::Dock_PalEdit::set_color),
- i
- )
- );
- App::dialog_color->present();
-}
-
-void
-Dock_PalEdit::select_fill_color(int i)
-{
- synfigapp::Main::set_fill_color(get_color(i));
-}
-
-void
-Dock_PalEdit::select_outline_color(int i)
-{
- synfigapp::Main::set_outline_color(get_color(i));
-}
-
-void
-Dock_PalEdit::set_default_palette()
-{
- int width=12;
-
- palette_.clear();
-
- // Greys
- palette_.push_back(Color::alpha());
- for(int i=0;i<width-1;i++)
- {
- Color c(
- float(i)/(float)(width-2),
- float(i)/(float)(width-2),
- float(i)/(float)(width-2)
- );
- palette_.push_back(c);
- }
-
- // Tans
- for(int i=0;i<width;i++)
- {
- float x(float(i)/(float)(width-1));
- const Color tan1(0.2,0.05,0);
- const Color tan2(0.85,0.64,0.20);
-
- palette_.push_back(Color::blend(tan2,tan1,x));
- }
-
- // Solids
- palette_.push_back(Color::red());
- palette_.push_back(Color(1.0f,0.25f,0.0f)); // Orange
- palette_.push_back(Color::yellow());
- palette_.push_back(Color(0.25f,1.00f,0.0f)); // yellow-green
- palette_.push_back(Color::green());
- palette_.push_back(Color(0.0f,1.00f,0.25f)); // green-blue
- palette_.push_back(Color::cyan());
- palette_.push_back(Color(0.0f,0.25f,1.0f)); // Sea Blue
- palette_.push_back(Color::blue());
- palette_.push_back(Color(0.25f,0.0f,1.0f));
- palette_.push_back(Color::magenta());
- palette_.push_back(Color(1.0f,0.0f,0.25f));
-
-
- const int levels(3);
-
- // Colors
- for(int j=0;j<levels;j++)
- for(int i=0;i<width;i++)
- {
- Color c(Color::red());
- c.set_hue(c.get_hue()-Angle::rot(float(i)/(float)(width)));
- c=c.clamped();
- float s(float(levels-j)/float(levels));
- s*=s;
- c.set_r(c.get_r()*s);
- c.set_g(c.get_g()*s);
- c.set_b(c.get_b()*s);
- palette_.push_back(c);
- }
-
-
- /*
- const int levels(3);
-
- for(int i=0;i<levels*levels*levels;i++)
- {
- Color c(
- float(i%levels)/(float)(levels-1),
- float(i/levels%levels)/(float)(levels-1),
- float(i/(levels*levels))/(float)(levels-1)
- );
- palette_.push_back(c);
- }
- */
- refresh();
-}
-
-int
-Dock_PalEdit::size()const
-{
- return palette_.size();
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file dock_paledit.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
-#define __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/checkbutton.h>
-
-#include <synfig/gamma.h>
-#include <synfig/time.h>
-
-#include "../widget_coloredit.h"
-
-#include <synfigapp/value_desc.h>
-#include <synfig/time.h>
-
-#include "../dockable.h"
-#include <vector>
-#include <gtkmm/actiongroup.h>
-
-#include <synfig/palette.h>
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace synfigapp {
-class CanvasInterface;
-};
-
-namespace studio {
-
-class Widget_Color;
-class PaletteSettings;
-
-class Dock_PalEdit : public Dockable
-{
- friend class PaletteSettings;
-
- Glib::RefPtr<Gtk::ActionGroup> action_group;
-
- synfig::Palette palette_;
-
- Gtk::Table table;
-
- void on_add_pressed();
-
- void show_menu(int i);
-
- sigc::signal<void> signal_changed_;
-
-
-private:
- int add_color(const synfig::Color& x);
- void set_color(synfig::Color x, int i);
- void erase_color(int i);
-
- void select_fill_color(int i);
- void select_outline_color(int i);
- synfig::Color get_color(int i)const;
- void edit_color(int i);
-public:
- void set_palette(const synfig::Palette& x);
- const synfig::Palette& get_palette()const { return palette_; }
-
- int size()const;
-
- void set_default_palette();
-
- void refresh();
-
- const sigc::signal<void>& signal_changed() { return signal_changed_; }
-
- Dock_PalEdit();
- ~Dock_PalEdit();
-}; // END of Dock_PalEdit
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file mod_palette.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "mod_palette.h"
-#include "dock_paledit.h"
-#include "dock_palbrowse.h"
-
-#include "../app.h"
-#include "../dockmanager.h"
-
-#include "../general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-bool
-studio::ModPalette::start_vfunc()
-{
- dock_pal_edit=new Dock_PalEdit();
- App::get_dock_manager()->register_dockable(*dock_pal_edit);
-
- //dock_pal_browse=new Dock_PalBrowse();
- //App::get_dock_manager()->register_dockable(*dock_pal_browse);
-
- return true;
-}
-
-bool
-studio::ModPalette::stop_vfunc()
-{
- //App::get_dock_manager()->unregister_dockable(*dock_pal_browse);
- App::get_dock_manager()->unregister_dockable(*dock_pal_edit);
-
- delete dock_pal_edit;
- //delete dock_pal_browse;
-
- return true;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file mod_palette.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_MOD_PALETTE_H
-#define __SYNFIG_MOD_PALETTE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include "../module.h"
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace studio {
-
-class Dock_PalEdit;
-class Dock_PalBrowse;
-
-class ModPalette : public Module
-{
- friend class Dock_PalEdit;
- friend class Dock_PalBrowse;
-
- Dock_PalEdit* dock_pal_edit;
- Dock_PalBrowse* dock_pal_browse;
-
-protected:
- virtual bool start_vfunc();
- virtual bool stop_vfunc();
-
-public:
- virtual ~ModPalette() { stop(); }
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file gtkmm/module.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "module.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-//using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Module::Module():status_(false)
-{
-}
-
-Module::~Module()
-{
- stop();
-}
-
-bool
-Module::get_status()const
-{
- return status_;
-}
-
-bool
-Module::start()
-{
- if(!get_status())
- status_=start_vfunc();
- return get_status();
-}
-
-bool
-Module::stop()
-{
- if(get_status() && count()<=1 && stop_vfunc())
- {
- status_=false;
- return true;
- }
- return false;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file gtkmm/module.h
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-** 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.
-**
-** 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 __SYNFIG_MODULE_H
-#define __SYNFIG_MODULE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-
-/* === M A C R O S ========================================================= */
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace studio {
-
-class Module : public etl::shared_object
-{
- bool status_;
-
-protected:
- Module();
-
-public:
- virtual ~Module();
-
- bool start();
-
- bool stop();
-
- bool get_status()const;
-
-protected:
-
- virtual bool start_vfunc()=0;
- virtual bool stop_vfunc()=0;
-};
-
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dock_palbrowse.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "dock_palbrowse.h"
+#include "dock_paledit.h"
+#include "mod_palette.h"
+
+#include "../../general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_PalBrowse::Dock_PalBrowse():
+ Dockable("pal_browse",_("Palette Browser")/*,Gtk::StockID("gtk-select-color")*/)
+{
+}
+
+Dock_PalBrowse::~Dock_PalBrowse()
+{
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dock_palbrowse.h
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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 __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
+#define __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "../../dockable.h"
+#include <synfig/palette.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+class CanvasInterface;
+};
+
+namespace studio {
+
+/*
+
+The palette browser was intended to be a way to manage and select a single
+palette from a set of palettes that you could save to files. The palette
+editor was for editing individual palettes. Unfortunately the palette
+browser was never implemented.
+
+*/
+
+class Dock_PalBrowse : public Dockable
+{
+public:
+ Dock_PalBrowse();
+ ~Dock_PalBrowse();
+}; // END of Dock_PalBrowse
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dock_paledit.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** 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.
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "dock_paledit.h"
+#include "../../widget_color.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <synfig/general.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "../../widget_color.h"
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/menu.h>
+#include <synfigapp/main.h>
+#include "../../app.h"
+#include "../../dialog_color.h"
+
+#include "../../general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+/*
+class studio::PaletteSettings : public synfigapp::Settings
+{
+ Dock_PalEdit* dialog_palette;
+ synfig::String name;
+public:
+ PaletteSettings(Dock_PalEdit* window,const synfig::String& name):
+ dialog_palette(window),
+ name(name)
+ {
+ dialog_palette->dialog_settings.add_domain(this,name);
+ }
+
+ virtual ~PaletteSettings()
+ {
+ dialog_palette->dialog_settings.remove_domain(name);
+ }
+
+ virtual bool get_value(const synfig::String& key, synfig::String& value)const
+ {
+ int i(atoi(key.c_str()));
+ if(i<0 || i>=dialog_palette->size())
+ return false;
+ Color c(dialog_palette->get_color(i));
+ value=strprintf("%f %f %f %f",c.get_r(),c.get_g(),c.get_b(),c.get_a());
+ return true;
+ }
+
+ virtual bool set_value(const synfig::String& key,const synfig::String& value)
+ {
+ int i(atoi(key.c_str()));
+ if(i<0)
+ return false;
+ if(i>=dialog_palette->size())
+ dialog_palette->palette_.resize(i+1);
+ float r,g,b,a;
+ if(!strscanf(value,"%f %f %f %f",&r,&g,&b,&a))
+ return false;
+ dialog_palette->set_color(Color(r,g,b,a),i);
+ return true;
+ }
+
+ virtual KeyList get_key_list()const
+ {
+ synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
+
+ int i;
+ for(i=0;i<dialog_palette->size();i++)
+ ret.push_back(strprintf("%03d",i));
+ return ret;
+ }
+};
+*/
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_PalEdit::Dock_PalEdit():
+ Dockable("pal_edit",_("Palette Editor"),Gtk::StockID("gtk-select-color")),
+ //palette_settings(new PaletteSettings(this,"colors")),
+ table(2,2,false)
+{
+ action_group=Gtk::ActionGroup::create("action_group_pal_edit");
+ action_group->add(Gtk::Action::create(
+ "palette-add-color",
+ Gtk::StockID("gtk-add"),
+ _("Add Color"),
+ _("Add current outline color\nto the palette")
+ ),
+ sigc::mem_fun(
+ *this,
+ &Dock_PalEdit::on_add_pressed
+ )
+ );
+
+ App::ui_manager()->insert_action_group(action_group);
+
+ Glib::ustring ui_info =
+ "<ui>"
+ " <toolbar action='toolbar-palette'>"
+ " <toolitem action='palette-add-color' />"
+ " </toolbar>"
+ "</ui>"
+ ;
+
+ App::ui_manager()->add_ui_from_string(ui_info);
+
+ set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-palette")));
+
+ /*
+ add_button(
+ Gtk::StockID("gtk-add"),
+ _("Add current outline color\nto the palette")
+ )->signal_clicked().connect(
+ sigc::mem_fun(
+ *this,
+ &Dock_PalEdit::on_add_pressed
+ )
+ );
+ */
+
+ add(table);
+ table.set_homogeneous(true);
+
+ set_default_palette();
+
+ show_all_children();
+}
+
+Dock_PalEdit::~Dock_PalEdit()
+{
+ //delete palette_settings;
+}
+
+void
+Dock_PalEdit::set_palette(const synfig::Palette& x)
+{
+ palette_=x;
+ refresh();
+}
+
+void
+Dock_PalEdit::on_add_pressed()
+{
+ add_color(synfigapp::Main::get_outline_color());
+}
+
+void
+Dock_PalEdit::show_menu(int i)
+{
+ Gtk::Menu* menu(manage(new Gtk::Menu()));
+ menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+
+ menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"),
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::edit_color),
+ i
+ )
+ ));
+
+ menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::erase_color),
+ i
+ )
+ ));
+
+ menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+ menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Load Default Palette"),
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::set_default_palette)
+ ));
+
+ menu->popup(3,gtk_get_current_event_time());
+}
+
+int
+Dock_PalEdit::add_color(const synfig::Color& x)
+{
+ palette_.push_back(x);
+ signal_changed()();
+ refresh();
+ return size()-1;
+}
+
+void
+Dock_PalEdit::set_color(synfig::Color x, int i)
+{
+ palette_[i].color=x;
+ signal_changed()();
+ refresh();
+}
+
+Color
+Dock_PalEdit::get_color(int i)const
+{
+ return palette_[i].color;
+}
+
+void
+Dock_PalEdit::erase_color(int i)
+{
+ palette_.erase(palette_.begin()+i);
+ signal_changed()();
+ refresh();
+}
+
+void
+Dock_PalEdit::refresh()
+{
+ const int width(12);
+
+ // Clear the table
+ table.foreach(sigc::mem_fun(table,&Gtk::Table::remove));
+
+ for(int i=0;i<size();i++)
+ {
+ Widget_Color* widget_color(manage(new Widget_Color()));
+ widget_color->set_value(get_color(i));
+ widget_color->set_size_request(12,12);
+ widget_color->signal_activate().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::select_fill_color),
+ i
+ )
+ );
+ widget_color->signal_middle_click().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::select_outline_color),
+ i
+ )
+ );
+ widget_color->signal_right_click().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::show_menu),
+ i
+ )
+ );
+ int c(i%width),r(i/width);
+ table.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ }
+ table.show_all();
+ queue_draw();
+}
+
+
+void
+Dock_PalEdit::edit_color(int i)
+{
+ App::dialog_color->reset();
+ App::dialog_color->set_color(get_color(i));
+ App::dialog_color->signal_edited().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Dock_PalEdit::set_color),
+ i
+ )
+ );
+ App::dialog_color->present();
+}
+
+void
+Dock_PalEdit::select_fill_color(int i)
+{
+ synfigapp::Main::set_fill_color(get_color(i));
+}
+
+void
+Dock_PalEdit::select_outline_color(int i)
+{
+ synfigapp::Main::set_outline_color(get_color(i));
+}
+
+void
+Dock_PalEdit::set_default_palette()
+{
+ int width=12;
+
+ palette_.clear();
+
+ // Greys
+ palette_.push_back(Color::alpha());
+ for(int i=0;i<width-1;i++)
+ {
+ Color c(
+ float(i)/(float)(width-2),
+ float(i)/(float)(width-2),
+ float(i)/(float)(width-2)
+ );
+ palette_.push_back(c);
+ }
+
+ // Tans
+ for(int i=0;i<width;i++)
+ {
+ float x(float(i)/(float)(width-1));
+ const Color tan1(0.2,0.05,0);
+ const Color tan2(0.85,0.64,0.20);
+
+ palette_.push_back(Color::blend(tan2,tan1,x));
+ }
+
+ // Solids
+ palette_.push_back(Color::red());
+ palette_.push_back(Color(1.0f,0.25f,0.0f)); // Orange
+ palette_.push_back(Color::yellow());
+ palette_.push_back(Color(0.25f,1.00f,0.0f)); // yellow-green
+ palette_.push_back(Color::green());
+ palette_.push_back(Color(0.0f,1.00f,0.25f)); // green-blue
+ palette_.push_back(Color::cyan());
+ palette_.push_back(Color(0.0f,0.25f,1.0f)); // Sea Blue
+ palette_.push_back(Color::blue());
+ palette_.push_back(Color(0.25f,0.0f,1.0f));
+ palette_.push_back(Color::magenta());
+ palette_.push_back(Color(1.0f,0.0f,0.25f));
+
+
+ const int levels(3);
+
+ // Colors
+ for(int j=0;j<levels;j++)
+ for(int i=0;i<width;i++)
+ {
+ Color c(Color::red());
+ c.set_hue(c.get_hue()-Angle::rot(float(i)/(float)(width)));
+ c=c.clamped();
+ float s(float(levels-j)/float(levels));
+ s*=s;
+ c.set_r(c.get_r()*s);
+ c.set_g(c.get_g()*s);
+ c.set_b(c.get_b()*s);
+ palette_.push_back(c);
+ }
+
+
+ /*
+ const int levels(3);
+
+ for(int i=0;i<levels*levels*levels;i++)
+ {
+ Color c(
+ float(i%levels)/(float)(levels-1),
+ float(i/levels%levels)/(float)(levels-1),
+ float(i/(levels*levels))/(float)(levels-1)
+ );
+ palette_.push_back(c);
+ }
+ */
+ refresh();
+}
+
+int
+Dock_PalEdit::size()const
+{
+ return palette_.size();
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dock_paledit.h
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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 __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
+#define __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/checkbutton.h>
+
+#include <synfig/gamma.h>
+#include <synfig/time.h>
+
+#include "../../widget_coloredit.h"
+
+#include <synfigapp/value_desc.h>
+#include <synfig/time.h>
+
+#include "../../dockable.h"
+#include <vector>
+#include <gtkmm/actiongroup.h>
+
+#include <synfig/palette.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+class CanvasInterface;
+};
+
+namespace studio {
+
+class Widget_Color;
+class PaletteSettings;
+
+class Dock_PalEdit : public Dockable
+{
+ friend class PaletteSettings;
+
+ Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+ synfig::Palette palette_;
+
+ Gtk::Table table;
+
+ void on_add_pressed();
+
+ void show_menu(int i);
+
+ sigc::signal<void> signal_changed_;
+
+
+private:
+ int add_color(const synfig::Color& x);
+ void set_color(synfig::Color x, int i);
+ void erase_color(int i);
+
+ void select_fill_color(int i);
+ void select_outline_color(int i);
+ synfig::Color get_color(int i)const;
+ void edit_color(int i);
+public:
+ void set_palette(const synfig::Palette& x);
+ const synfig::Palette& get_palette()const { return palette_; }
+
+ int size()const;
+
+ void set_default_palette();
+
+ void refresh();
+
+ const sigc::signal<void>& signal_changed() { return signal_changed_; }
+
+ Dock_PalEdit();
+ ~Dock_PalEdit();
+}; // END of Dock_PalEdit
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file mod_palette.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "mod_palette.h"
+#include "dock_paledit.h"
+#include "dock_palbrowse.h"
+
+#include "../../app.h"
+#include "../../dockmanager.h"
+
+#include "../../general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+bool
+studio::ModPalette::start_vfunc()
+{
+ dock_pal_edit=new Dock_PalEdit();
+ App::get_dock_manager()->register_dockable(*dock_pal_edit);
+
+ //dock_pal_browse=new Dock_PalBrowse();
+ //App::get_dock_manager()->register_dockable(*dock_pal_browse);
+
+ return true;
+}
+
+bool
+studio::ModPalette::stop_vfunc()
+{
+ //App::get_dock_manager()->unregister_dockable(*dock_pal_browse);
+ App::get_dock_manager()->unregister_dockable(*dock_pal_edit);
+
+ delete dock_pal_edit;
+ //delete dock_pal_browse;
+
+ return true;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file mod_palette.h
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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 __SYNFIG_MOD_PALETTE_H
+#define __SYNFIG_MOD_PALETTE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include "../module.h"
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class Dock_PalEdit;
+class Dock_PalBrowse;
+
+class ModPalette : public Module
+{
+ friend class Dock_PalEdit;
+ friend class Dock_PalBrowse;
+
+ Dock_PalEdit* dock_pal_edit;
+ Dock_PalBrowse* dock_pal_browse;
+
+protected:
+ virtual bool start_vfunc();
+ virtual bool stop_vfunc();
+
+public:
+ virtual ~ModPalette() { stop(); }
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file gtkmm/module.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "module.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+//using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Module::Module():status_(false)
+{
+}
+
+Module::~Module()
+{
+ stop();
+}
+
+bool
+Module::get_status()const
+{
+ return status_;
+}
+
+bool
+Module::start()
+{
+ if(!get_status())
+ status_=start_vfunc();
+ return get_status();
+}
+
+bool
+Module::stop()
+{
+ if(get_status() && count()<=1 && stop_vfunc())
+ {
+ status_=false;
+ return true;
+ }
+ return false;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file gtkmm/module.h
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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 __SYNFIG_MODULE_H
+#define __SYNFIG_MODULE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class Module : public etl::shared_object
+{
+ bool status_;
+
+protected:
+ Module();
+
+public:
+ virtual ~Module();
+
+ bool start();
+
+ bool stop();
+
+ bool get_status()const;
+
+protected:
+
+ virtual bool start_vfunc()=0;
+ virtual bool stop_vfunc()=0;
+};
+
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file state_mirror.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2009 Nikita Kitaev
+**
+** 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.
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_mirror.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include <synfigapp/main.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+enum Axis {
+ AXIS_X,
+ AXIS_Y
+} ;
+
+/* === G L O B A L S ======================================================= */
+
+StateMirror studio::state_mirror;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class DuckDrag_Mirror : public DuckDrag_Base
+{
+ synfig::Vector center;
+
+ std::vector<synfig::Vector> positions;
+
+public:
+ Axis axis;
+
+ DuckDrag_Mirror();
+ void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin);
+ bool end_duck_drag(Duckmatic* duckmatic);
+ void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector);
+};
+
+class studio::StateMirror_Context : public sigc::trackable
+{
+ etl::handle<CanvasView> canvas_view_;
+ CanvasView::IsWorking is_working;
+
+ synfigapp::Settings& settings;
+
+ sigc::connection keypress_connect;
+ sigc::connection keyrelease_connect;
+
+ etl::handle<DuckDrag_Mirror> duck_dragger_;
+
+ Gtk::Table options_table;
+
+ Gtk::RadioButton::Group radiobutton_group;
+ Gtk::RadioButton radiobutton_axis_x;
+ Gtk::RadioButton radiobutton_axis_y;
+
+public:
+
+ Axis get_axis()const { return radiobutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
+ void set_axis(Axis a)
+ {
+ if(a==AXIS_X)
+ radiobutton_axis_x.set_active(true);
+ else
+ radiobutton_axis_y.set_active(true);
+
+ duck_dragger_->axis=get_axis();
+ }
+
+ void update_axes()
+ {
+ duck_dragger_->axis=get_axis();
+ get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW);
+ }
+
+ Smach::event_result event_stop_handler(const Smach::event& x);
+ Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+ void refresh_tool_options();
+
+ StateMirror_Context(CanvasView* canvas_view);
+
+ ~StateMirror_Context();
+
+ const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+ etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
+ synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
+ WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
+
+ void load_settings();
+ void save_settings();
+
+ bool key_event(GdkEventKey *event);
+}; // END of class StateMirror_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateMirror::StateMirror():
+ Smach::state<StateMirror_Context>("mirror")
+{
+ insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateMirror_Context::event_refresh_tool_options));
+ insert(event_def(EVENT_STOP,&StateMirror_Context::event_stop_handler));
+}
+
+StateMirror::~StateMirror()
+{
+}
+
+void
+StateMirror_Context::load_settings()
+{
+ String value;
+
+ settings.get_value("mirror.axis",value);
+ set_axis((Axis)atoi(value.c_str()));
+}
+
+void
+StateMirror_Context::save_settings()
+{
+ settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
+}
+
+StateMirror_Context::StateMirror_Context(CanvasView* canvas_view):
+ canvas_view_(canvas_view),
+ is_working(*canvas_view),
+ settings(synfigapp::Main::get_selected_input_device()->settings()),
+ duck_dragger_(new DuckDrag_Mirror()),
+ radiobutton_axis_x(radiobutton_group,_("Horizontal")),
+ radiobutton_axis_y(radiobutton_group,_("Vertical"))
+{
+ // Set up the tool options dialog
+ options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(radiobutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(radiobutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("(Shift key toggles axis)"))), 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ radiobutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
+ radiobutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
+
+ options_table.show_all();
+ refresh_tool_options();
+ App::dialog_tool_options->present();
+
+ get_work_area()->set_allow_layer_clicks(true);
+ get_work_area()->set_duck_dragger(duck_dragger_);
+
+ keypress_connect=get_work_area()->signal_key_press_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false);
+ keyrelease_connect=get_work_area()->signal_key_release_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false);
+
+ get_work_area()->set_cursor(Gdk::SB_H_DOUBLE_ARROW);
+// get_work_area()->reset_cursor();
+
+ App::toolbox->refresh();
+
+ set_axis(AXIS_X);
+ load_settings();
+}
+
+bool
+StateMirror_Context::key_event(GdkEventKey *event)
+{
+ if (event->keyval==GDK_Shift_L || event->keyval==GDK_Shift_R )
+ {
+ set_axis(get_axis()==AXIS_X ? AXIS_Y:AXIS_X);
+ get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW);
+ }
+
+ return false; //Pass on the event to other handlers, just in case
+}
+
+void
+StateMirror_Context::refresh_tool_options()
+{
+ App::dialog_tool_options->clear();
+ App::dialog_tool_options->set_widget(options_table);
+ App::dialog_tool_options->set_local_name(_("Mirror Tool"));
+ App::dialog_tool_options->set_name("mirror");
+}
+
+Smach::event_result
+StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+ refresh_tool_options();
+ return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateMirror_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+ throw &state_normal;
+ return Smach::RESULT_OK;
+}
+
+StateMirror_Context::~StateMirror_Context()
+{
+ save_settings();
+
+ get_work_area()->clear_duck_dragger();
+ get_work_area()->reset_cursor();
+
+ keypress_connect.disconnect();
+ keyrelease_connect.disconnect();
+
+ App::dialog_tool_options->clear();
+
+ App::toolbox->refresh();
+}
+
+DuckDrag_Mirror::DuckDrag_Mirror():
+ axis(AXIS_X)
+{
+}
+
+#ifndef EPSILON
+#define EPSILON 0.0000001
+#endif
+
+void
+DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& /*offset*/)
+{
+ const DuckList selected_ducks(duckmatic->get_selected_ducks());
+ DuckList::const_iterator iter;
+
+ positions.clear();
+ int i;
+ for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+ {
+ Point p((*iter)->get_trans_point());
+ positions.push_back(p);
+ }
+
+}
+
+void
+DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
+{
+ center=vector;
+ int i;
+
+ const DuckList selected_ducks(duckmatic->get_selected_ducks());
+ DuckList::const_iterator iter;
+
+ Time time(duckmatic->get_time());
+
+ // do the Vertex and Position ducks first
+ for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+ if ((*iter)->get_type() == Duck::TYPE_VERTEX ||
+ (*iter)->get_type() == Duck::TYPE_POSITION)
+ {
+ Vector p(positions[i]);
+
+ if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+ else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
+
+ (*iter)->set_trans_point(p);
+ }
+
+ // then do the other ducks
+ for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+ if ((*iter)->get_type() != Duck::TYPE_VERTEX &&
+ (*iter)->get_type() != Duck::TYPE_POSITION)
+ {
+ // we don't need to mirror radius ducks - they're one-dimensional
+ if ((*iter)->is_radius())
+ continue;
+
+ Vector p(positions[i]);
+
+ if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+ else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
+
+ (*iter)->set_trans_point(p);
+ }
+}
+
+bool
+DuckDrag_Mirror::end_duck_drag(Duckmatic* duckmatic)
+{
+ duckmatic->signal_edited_selected_ducks();
+ return true;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file state_mirror.h
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** 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.
+**
+** 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 __SYNFIG_STUDIO_STATE_MIRROR_H
+#define __SYNFIG_STUDIO_STATE_MIRROR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "smach.h"
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class StateMirror_Context;
+
+class StateMirror : public Smach::state<StateMirror_Context>
+{
+public:
+ StateMirror();
+ ~StateMirror();
+}; // END of class StateMirror
+
+extern StateMirror state_mirror;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif