示例#1
0
void
HistoryTreeStore::insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool /*is_active*/, bool is_undo, bool is_redo)
{
	assert(action);

	row[model.action] = action;
	row[model.name] = static_cast<Glib::ustring>(action->get_local_name());
	row[model.is_active] = action->is_active();
	row[model.is_undo] = is_undo;
	row[model.is_redo] = is_redo;

	synfigapp::Action::CanvasSpecific *specific_action;
	specific_action=dynamic_cast<synfigapp::Action::CanvasSpecific*>(action.get());
	if(specific_action)
	{
		row[model.canvas] = specific_action->get_canvas();
		row[model.canvas_id] = specific_action->get_canvas()->get_id();
	}

	etl::handle<synfigapp::Action::Group> group;
	group=etl::handle<synfigapp::Action::Group>::cast_dynamic(action);
	if(group)
	{
		synfigapp::Action::ActionList::const_iterator iter;
		for(iter=group->action_list().begin();iter!=group->action_list().end();++iter)
		{
			Gtk::TreeRow child_row = *(append(row.children()));
			insert_action(child_row,*iter,true,is_undo,is_redo);
		}
	}

	//row[model.icon] = Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
}
示例#2
0
void
HistoryTreeStore::on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action)
{
	Gtk::TreeModel::Children::iterator iter;
	Gtk::TreeModel::Children children_(children());

	for(iter=children_.begin(); iter != children_.end(); ++iter)
	{
		Gtk::TreeModel::Row row = *iter;
		if(action == (etl::handle<synfigapp::Action::Undoable>)row[model.action])
		{
			row[model.is_active]=action->is_active();
			return;
		}
	}
}
示例#3
0
bool
Action::System::set_action_status(etl::handle<Action::Undoable> action, bool x)
{
	Stack::iterator iter;
	int failed=false;

	if(action->is_active()==x)
		return true;

	handle<Action::Undoable> cur_pos=undo_action_stack_.front();

	Action::CanvasSpecific* canvas_specific(dynamic_cast<Action::CanvasSpecific*>(action.get()));

	handle<UIInterface> uim=new ConfidentUIInterface();

	iter=find(undo_action_stack_.begin(),undo_action_stack_.end(),action);
	if(iter!=undo_action_stack_.end())
	{
		while(undo_action_stack_.front()!=action)
		{
			if(!undo_(uim))
			{
				return false;
			}
		}
		if(!undo_(uim))
		{
			return false;
		}

		action->set_active(x);

		if(redo_(get_ui_interface()))
		{
			signal_action_status_changed_(action);
		}
		else
		{
			action->set_active(!x);
			failed=true;
		}


		while(undo_action_stack_.front()!=cur_pos)
		{
			if(!redo_(uim))
			{
				redo_action_stack_.front()->set_active(false);
				signal_action_status_changed_(redo_action_stack_.front());
			}
		}

		if(!failed && canvas_specific && canvas_specific->is_dirty())
		{
			Canvas::Handle canvas=canvas_specific->get_canvas();
			handle<CanvasInterface> canvas_interface=static_cast<Instance*>(this)->find_canvas_interface(canvas);
			assert(canvas_interface);
			//canvas_interface->signal_dirty_preview()();
		}

		return true;
	}

	iter=find(redo_action_stack_.begin(),redo_action_stack_.end(),action);
	if(iter!=redo_action_stack_.end())
	{
		action->set_active(x);
		signal_action_status_changed_(action);




		if(canvas_specific && canvas_specific->is_dirty())
		{
			Canvas::Handle canvas=canvas_specific->get_canvas();
			handle<CanvasInterface> canvas_interface=static_cast<Instance*>(this)->find_canvas_interface(canvas);
			assert(canvas_interface);
			//canvas_interface->signal_dirty_preview()();
		}

		return true;
	}

	return false;
}