/* === S Y N F I G ========================================================= */
-/*! \file template.cpp
+/*! \file layeractionmanager.cpp
** \brief Template File
**
-** $Id: layeractionmanager.cpp,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
*/
/* ========================================================================= */
#include "instance.h"
#include <synfigapp/selectionmanager.h>
+#include "general.h"
+
#endif
/* === U S I N G =========================================================== */
LayerActionManager::LayerActionManager():
action_group_(Gtk::ActionGroup::create()),
- action_group_copy_paste(Gtk::ActionGroup::create()),
popup_id_(no_prev_popup),
+ action_group_copy_paste(Gtk::ActionGroup::create()),
queued(false)
{
action_cut_=Gtk::Action::create(
&LayerActionManager::paste
)
);
-
-
+
+
action_amount_inc_=Gtk::Action::create(
"amount-inc",
Gtk::StockID("gtk-add"),
{
if(queued)
return;
-
+
//queue_refresh_connection.disconnect();
queue_refresh_connection=Glib::signal_idle().connect(
sigc::bind_return(
false
)
);
-
+
queued=true;
}
clear();
-
+
// Make sure we are ready
if(!ui_manager_ || !layer_tree_ || !canvas_interface_)
{
synfig::error("LayerActionManager::refresh(): Not ready!");
return;
}
-
-
+
+
String ui_info;
action_paste_->set_sensitive(!clipboard_.empty());
action_group_->add(action_paste_);
-
+
if(layer_tree_->get_selection()->count_selected_rows()!=0)
{
bool multiple_selected(layer_tree_->get_selection()->count_selected_rows()>1);
Layer::Handle layer(layer_tree_->get_selected_layer());
-
+
{
bool canvas_set(false);
synfigapp::Action::ParamList param_list;
action_group_->add(action_amount_inc_);
action_group_->add(action_amount_dec_);
action_group_->add(action_amount_);
-
+
for(iter=layer_list.begin();iter!=layer_list.end();++iter)
{
update_connection_list.push_back(
sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
)
);
-
+
if(!canvas_set)
{
param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
param_list.add("layer",Layer::Handle(*iter));
}
}
-
+
if(!multiple_selected && layer->get_name()=="PasteCanvas")
{
action_group_->add(Gtk::Action::create(
add_actions_to_group(action_group_, ui_info, param_list, synfigapp::Action::CATEGORY_LAYER);
}
}
-
- ui_info="<ui><menubar action='menu-main'><menu action='menu-layer'>"+ui_info+"<separator/><menuitem action='cut' /><menuitem action='copy' /><menuitem action='paste' /><separator/></menu></menubar></ui>";
- popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+
+ ui_info="<ui><popup action='menu-main'><menu action='menu-layer'>"+ui_info+"<separator/><menuitem action='cut' /><menuitem action='copy' /><menuitem action='paste' /><separator/></menu></popup></ui>";
+ popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
#ifdef ONE_ACTION_GROUP
#else
get_ui_manager()->insert_action_group(action_group_);
#endif
- DEBUGPOINT();
}
void
synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
clipboard_.clear();
synfig::GUID guid;
-
+
while(!layer_list.empty())
{
clipboard_.push_back(layer_list.front()->clone(guid));
}
action_paste_->set_sensitive(!clipboard_.empty());
-
+
//queue_refresh();
}
Canvas::Handle canvas(get_canvas_interface()->get_canvas());
int depth(0);
-
+
// we are temporarily using the layer to hold something
Layer::Handle layer(layer_tree_->get_selected_layer());
if(layer)
depth=layer->get_depth();
canvas=layer->get_canvas();
}
-
+
synfigapp::SelectionManager::LayerList layer_selection;
-
+
for(std::list<synfig::Layer::Handle>::iterator iter=clipboard_.begin();iter!=clipboard_.end();++iter)
{
layer=(*iter)->clone(guid);
layer_selection.push_back(layer);
synfigapp::Action::Handle action(synfigapp::Action::create("layer_add"));
-
+
assert(action);
if(!action)
return;
-
+
action->set_param("canvas",canvas);
action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
action->set_param("new",layer);
-
+
if(!action->is_ready())
{
return;
}
-
+
if(!get_instance()->perform_action(action))
{
return;
}
-
+
synfig::info("DEPTH=%d",depth);
// Action to move the layer (if necessary)
if(depth>0)
{
synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
-
+
assert(action);
if(!action)
return;
-
+
action->set_param("canvas",canvas);
action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
action->set_param("layer",layer);
action->set_param("new_index",depth);
-
+
if(!action->is_ready())
{
- //get_ui_interface()->error(_("Move Action Not Ready"));
+ //get_ui_interface()->error(_("Move Action Not Ready"));
//return 0;
return;
}
-
+
if(!get_instance()->perform_action(action))
{
- //get_ui_interface()->error(_("Move Action Not Ready"));
+ //get_ui_interface()->error(_("Move Action Not Ready"));
//return 0;
return;
}
- }
+ }
depth++;
+
+ // automatically export the Index parameter of Duplicate layers when pasting
+ if (layer->get_name() == "duplicate")
+ for (int i = 1; ; i++)
+ {
+ String name = strprintf(_("Index %d"), i);
+ try
+ {
+ canvas->find_value_node(name);
+ }
+ catch (Exception::IDNotFound x)
+ {
+ get_canvas_interface()->add_value_node(layer->dynamic_param_list().find("index")->second, name);
+ break;
+ }
+ }
}
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
LayerActionManager::amount_inc()
{
float adjust(0.1);
-
+
// Create the action group
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-
+
if(adjust>0)
group.set_name(_("Increase Amount"));
while(!layer_list.empty())
{
ValueBase value(layer_list.front()->get_param("amount"));
- if(value.same_as(Real()))
+ if(value.same_type_as(Real()))
{
get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
}
LayerActionManager::amount_dec()
{
float adjust(-0.1);
-
+
// Create the action group
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-
+
if(adjust>0)
group.set_name(_("Increase Amount"));
while(!layer_list.empty())
{
ValueBase value(layer_list.front()->get_param("amount"));
- if(value.same_as(Real()))
+ if(value.same_type_as(Real()))
{
get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
}