Blame synfig-studio/src/gui/docks/dock_timetrack.cpp

Carlos Lopez a09598
/* === S Y N F I G ========================================================= */
Carlos Lopez a09598
/*!	\file dock_timetrack.cpp
Carlos Lopez a09598
**	\brief Template File
Carlos Lopez a09598
**
Carlos Lopez a09598
**	$Id$
Carlos Lopez a09598
**
Carlos Lopez a09598
**	\legal
Carlos Lopez a09598
**	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
Carlos Lopez a09598
**	Copyright (c) 2007, 2008 Chris Moore
Carlos Lopez 42fd7a
**  Copyright (c) 2010 Carlos Lรณpez
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is free software; you can redistribute it and/or
Carlos Lopez a09598
**	modify it under the terms of the GNU General Public License as
Carlos Lopez a09598
**	published by the Free Software Foundation; either version 2 of
Carlos Lopez a09598
**	the License, or (at your option) any later version.
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is distributed in the hope that it will be useful,
Carlos Lopez a09598
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
Carlos Lopez a09598
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Carlos Lopez a09598
**	General Public License for more details.
Carlos Lopez a09598
**	\endlegal
Carlos Lopez a09598
*/
Carlos Lopez a09598
/* ========================================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === H E A D E R S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
#ifdef USING_PCH
Carlos Lopez a09598
#	include "pch.h"
Carlos Lopez a09598
#else
Carlos Lopez a09598
#ifdef HAVE_CONFIG_H
Carlos Lopez a09598
#	include <config.h></config.h>
Carlos Lopez a09598
#endif
Carlos Lopez a09598
d421d7
#include <cassert></cassert>
Carlos Lopez a09598
Carlos Lopez a09598
#include <gtkmm scrolledwindow.h=""></gtkmm>
d421d7
d421d7
#include <synfig general.h=""></synfig>
Carlos Lopez a09598
#include <synfig timepointcollect.h=""></synfig>
Carlos Lopez a09598
a64bc0
#include <gui helpers.h=""></gui>
d421d7
#include <app.h></app.h>
d421d7
#include <instance.h></instance.h>
d421d7
#include <canvasview.h></canvasview.h>
d421d7
#include <workarea.h></workarea.h>
d421d7
#include <trees layertree.h=""></trees>
d421d7
#include <trees layerparamtreestore.h=""></trees>
d421d7
#include <widgets widget_canvastimeslider.h=""></widgets>
d421d7
#include <widgets widget_keyframe_list.h=""></widgets>
d421d7
d421d7
#include "dock_timetrack.h"
d421d7
a64bc0
#include <gui localization.h=""></gui>
d421d7
Carlos Lopez a09598
#endif
Carlos Lopez a09598
Carlos Lopez a09598
/* === U S I N G =========================================================== */
Carlos Lopez a09598
Carlos Lopez a09598
using namespace std;
Carlos Lopez a09598
using namespace etl;
Carlos Lopez a09598
using namespace synfig;
Carlos Lopez a09598
using namespace studio;
Carlos Lopez a09598
Carlos Lopez a09598
/* === M A C R O S ========================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === C L A S S E S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
class TimeTrackView : public Gtk::TreeView
Carlos Lopez a09598
{
Carlos Lopez a09598
	CellRenderer_TimeTrack *cellrenderer_time_track;
Carlos Lopez a09598
Carlos Lopez a09598
	Glib::RefPtr<layerparamtreestore> param_tree_store_;</layerparamtreestore>
Carlos Lopez a09598
Carlos Lopez a09598
	Gtk::TreeView *mimic_tree_view;
Carlos Lopez a09598
public:
Carlos Lopez a09598
Carlos Lopez a09598
	sigc::signal<void,synfigapp::valuedesc,std::set<synfig::waypoint, std::less<uniqueid=""> >,int> signal_waypoint_clicked_timetrackview;</void,synfigapp::valuedesc,std::set<synfig::waypoint,>
Carlos Lopez a09598
Carlos Lopez a09598
	LayerParamTreeStore::Model model;
Carlos Lopez a09598
Carlos Lopez a09598
	void set_canvas_view(handle<canvasview> canvas_view)</canvasview>
Carlos Lopez a09598
	{
d96b6a
		cellrenderer_time_track->set_time_model(canvas_view->time_model());
d96b6a
		cellrenderer_time_track->set_canvas_interface(canvas_view->canvas_interface());
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	TimeTrackView()
Carlos Lopez a09598
	{
[d.j.a.y] Jerome Blanchi 6dee96
		//Text attributes must be the same that layer param tree's to have aligned rows
[d.j.a.y] Jerome Blanchi 6dee96
		Pango::AttrList attr_list;
[d.j.a.y] Jerome Blanchi 6dee96
		{
[d.j.a.y] Jerome Blanchi 6dee96
			Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
[d.j.a.y] Jerome Blanchi 6dee96
			pango_size.set_start_index(0);
[d.j.a.y] Jerome Blanchi 6dee96
			pango_size.set_end_index(64);
[d.j.a.y] Jerome Blanchi 6dee96
			attr_list.change(pango_size);
[d.j.a.y] Jerome Blanchi 6dee96
		}
[d.j.a.y] Jerome Blanchi 6dee96
Carlos Lopez a09598
		int label_index(append_column_editable(_("Name"),model.label));
Carlos Lopez a09598
		Gtk::TreeView::Column* label_column = get_column(label_index-1);
[d.j.a.y] Jerome Blanchi 0f88f6
		label_column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
Carlos Lopez a09598
Carlos Lopez a09598
		{	// --- T I M E   T R A C K --------------------------------------------
Carlos Lopez a09598
			Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
4b2c9e
			Gtk::TreeView::Column* column2 = Gtk::manage( new Gtk::TreeView::Column("Align") );
Carlos Lopez a09598
Carlos Lopez a09598
			// Set up the value-node cell-renderer
Carlos Lopez a09598
			cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
Carlos Lopez a09598
			cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
Carlos Lopez a09598
			cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_clicked_timetrackview));
Carlos Lopez a09598
			cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_changed) );
4b2c9e
			//column->add_attribute(cellrenderer_time_track->property_value_desc(), model.value_desc);
4b2c9e
			//column->add_attribute(cellrenderer_time_track->property_canvas(), model.canvas);
Carlos Lopez a09598
			//column->add_attribute(cellrenderer_time_track->property_visible(), model.is_value_node);
Carlos Lopez a09598
Carlos Lopez a09598
			//column->pack_start(*cellrenderer_time_track);
Carlos Lopez a09598
[d.j.a.y] Jerome Blanchi 3c69d4
			// Add a fixed size (same that layer param tree) empty text renderer
[d.j.a.y] Jerome Blanchi 3c69d4
			// to align the rows with params dock when the text is taller than value_type icons height
[d.j.a.y] Jerome Blanchi 6dee96
			Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
[d.j.a.y] Jerome Blanchi 6dee96
			text_cellrenderer->property_attributes()=attr_list;
4b2c9e
			column2->pack_end(*text_cellrenderer,false);
4b2c9e
			text_cellrenderer->set_fixed_size (1,-1);
[d.j.a.y] Jerome Blanchi 6dee96
[d.j.a.y] Jerome Blanchi 3c69d4
			// Add a fixed size (1pixel widht, same height than value_type icon) empty (alpha) icon
[d.j.a.y] Jerome Blanchi 3c69d4
			// to align the rows with params dock when the text is smaller than value_type icons height
[d.j.a.y] Jerome Blanchi b1d0e2
			Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
[d.j.a.y] Jerome Blanchi edf738
			Glib::RefPtr<gdk::pixbuf> pixbuf;</gdk::pixbuf>
3cbd34
			pixbuf=Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-utils_timetrack_align"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
[d.j.a.y] Jerome Blanchi edf738
			icon_cellrenderer->property_pixbuf() = pixbuf;
4b2c9e
			column2->pack_end(*icon_cellrenderer,false);
4b2c9e
			icon_cellrenderer->set_fixed_size(1,-1);
[d.j.a.y] Jerome Blanchi b1d0e2
4b2c9e
			// Finish setting up the columns
Carlos Lopez a09598
			column->set_reorderable();
[d.j.a.y] Jerome Blanchi 513684
			column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
Carlos Lopez a09598
			column->set_resizable();
4b2c9e
			column->set_expand(true);
[d.j.a.y] Jerome Blanchi 090aef
// Commented during Align rows fixing
[d.j.a.y] Jerome Blanchi 090aef
// http://www.synfig.org/issues/thebuggenie/synfig/issues/161
[d.j.a.y] Jerome Blanchi 513684
// 			column->set_min_width(200);
4b2c9e
			
4b2c9e
			column2->set_resizable();
4b2c9e
			column2->set_fixed_width(1);
Carlos Lopez a09598
Carlos Lopez a09598
			append_column(*column);
4b2c9e
			append_column(*column2);
Carlos Lopez a09598
		}
Carlos Lopez a09598
		set_rules_hint();
Carlos Lopez a09598
Carlos Lopez a09598
		set_expander_column(*label_column);
Carlos Lopez a09598
		label_column->set_visible(false);
Carlos Lopez a09598
		set_headers_visible(false);
Carlos Lopez a09598
		set_size_request(-1,64);
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	bool
Carlos Lopez a09598
	on_event(GdkEvent *event)
Carlos Lopez a09598
	{
Carlos Lopez a09598
		switch(event->type)
Carlos Lopez a09598
		{
Carlos Lopez a09598
		case GDK_SCROLL:
a64bc0
			if (mimic_tree_view) {
Carlos Lopez a09598
				if(event->scroll.direction==GDK_SCROLL_DOWN)
a64bc0
					ConfigureAdjustment(mimic_tree_view->get_vadjustment())
a64bc0
						.set_value( std::min(
a64bc0
							mimic_tree_view->get_vadjustment()->get_value()
a64bc0
						  +	mimic_tree_view->get_vadjustment()->get_step_increment(),
a64bc0
							mimic_tree_view->get_vadjustment()->get_upper()
a64bc0
						  - mimic_tree_view->get_vadjustment()->get_page_size() ))
a64bc0
						.finish();
a64bc0
				else
a64bc0
				if(event->scroll.direction==GDK_SCROLL_UP)
a64bc0
					ConfigureAdjustment(mimic_tree_view->get_vadjustment())
a64bc0
						.set_value( std::max(
a64bc0
							mimic_tree_view->get_vadjustment()->get_value()
a64bc0
						  -	mimic_tree_view->get_vadjustment()->get_step_increment(),
a64bc0
							mimic_tree_view->get_vadjustment()->get_lower() ))
a64bc0
						.finish();
Carlos Lopez a09598
			}
Carlos Lopez a09598
			break;
Carlos Lopez a09598
		case GDK_BUTTON_PRESS:
Carlos Lopez a09598
			{
Carlos Lopez a09598
				Gtk::TreeModel::Path path;
Carlos Lopez a09598
				Gtk::TreeViewColumn *column;
Carlos Lopez a09598
				int cell_x, cell_y;
Carlos Lopez a09598
				if(!get_path_at_pos(
Carlos Lopez a09598
					int(event->button.x),int(event->button.y),	// x, y
Carlos Lopez a09598
					path, // TreeModel::Path&
Carlos Lopez a09598
					column, //TreeViewColumn*&
Carlos Lopez a09598
					cell_x,cell_y //int&cell_x,int&cell_y
Carlos Lopez a09598
					)
Carlos Lopez a09598
				) break;
Carlos Lopez a09598
				const Gtk::TreeRow row = *(get_model()->get_iter(path));
Carlos Lopez a09598
d342d4
				if(column && column->get_first_cell()==cellrenderer_time_track)
Carlos Lopez a09598
				{
Carlos Lopez a09598
					Gdk::Rectangle rect;
Carlos Lopez a09598
					get_cell_area(path,*column,rect);
Carlos Lopez a09598
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
Carlos Lopez a09598
					cellrenderer_time_track->property_canvas()=row[model.canvas];
Carlos Lopez a09598
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
Carlos Lopez a09598
					queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
Carlos Lopez a09598
					return true;
Carlos Lopez a09598
					//return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
Carlos Lopez a09598
				}
Carlos Lopez a09598
			}
Carlos Lopez a09598
			break;
Carlos Lopez a09598
Carlos Lopez a09598
		case GDK_MOTION_NOTIFY:
Carlos Lopez a09598
			{
Carlos Lopez a09598
				Gtk::TreeModel::Path path;
Carlos Lopez a09598
				Gtk::TreeViewColumn *column;
Carlos Lopez a09598
				int cell_x, cell_y;
Carlos Lopez a09598
				if(!get_path_at_pos(
Carlos Lopez a09598
					(int)event->motion.x,(int)event->motion.y,	// x, y
Carlos Lopez a09598
					path, // TreeModel::Path&
Carlos Lopez a09598
					column, //TreeViewColumn*&
Carlos Lopez a09598
					cell_x,cell_y //int&cell_x,int&cell_y
Carlos Lopez a09598
					)
Carlos Lopez a09598
				) break;
Carlos Lopez a09598
Carlos Lopez a09598
				if(!get_model()->get_iter(path))
Carlos Lopez a09598
					break;
Carlos Lopez a09598
Carlos Lopez a09598
				Gtk::TreeRow row = *(get_model()->get_iter(path));
Carlos Lopez a09598
6320b8
				if (((event->motion.state&GDK_BUTTON1_MASK) || (event->motion.state&GDK_BUTTON3_MASK)) &&
Carlos Lopez a09598
					column &&
d342d4
					cellrenderer_time_track == column->get_first_cell())
Carlos Lopez a09598
				{
Carlos Lopez a09598
					Gdk::Rectangle rect;
Carlos Lopez a09598
					get_cell_area(path,*column,rect);
Carlos Lopez a09598
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
Carlos Lopez a09598
					cellrenderer_time_track->property_canvas()=row[model.canvas];
Carlos Lopez a09598
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
Carlos Lopez a09598
					queue_draw();
Carlos Lopez a09598
					//queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
Carlos Lopez a09598
					return true;
Carlos Lopez a09598
				}
Carlos Lopez a09598
/*				else
Carlos Lopez a09598
				if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
Carlos Lopez a09598
				{
Carlos Lopez a09598
					tooltips_.unset_tip(*this);
Carlos Lopez a09598
					Glib::ustring tooltips_string(row[layer_model.tooltip]);
Carlos Lopez a09598
					last_tooltip_path=path;
Carlos Lopez a09598
					if(!tooltips_string.empty())
Carlos Lopez a09598
					{
Carlos Lopez a09598
						tooltips_.set_tip(*this,tooltips_string);
Carlos Lopez a09598
						tooltips_.force_window();
Carlos Lopez a09598
					}
Carlos Lopez a09598
				}
Carlos Lopez a09598
*/
Carlos Lopez a09598
				return true;
Carlos Lopez a09598
			}
Carlos Lopez a09598
			break;
Carlos Lopez a09598
		case GDK_BUTTON_RELEASE:
Carlos Lopez a09598
			{
Carlos Lopez a09598
				Gtk::TreeModel::Path path;
Carlos Lopez a09598
				Gtk::TreeViewColumn *column;
Carlos Lopez a09598
				int cell_x, cell_y;
Carlos Lopez a09598
				if(!get_path_at_pos(
Carlos Lopez a09598
					(int)event->button.x,(int)event->button.y,	// x, y
Carlos Lopez a09598
					path, // TreeModel::Path&
Carlos Lopez a09598
					column, //TreeViewColumn*&
Carlos Lopez a09598
					cell_x,cell_y //int&cell_x,int&cell_y
Carlos Lopez a09598
					)
Carlos Lopez a09598
				) break;
Carlos Lopez a09598
Carlos Lopez a09598
				if(!get_model()->get_iter(path))
Carlos Lopez a09598
					break;
Carlos Lopez a09598
Carlos Lopez a09598
				Gtk::TreeRow row = *(get_model()->get_iter(path));
Carlos Lopez a09598
d342d4
				if(column && cellrenderer_time_track==column->get_first_cell())
Carlos Lopez a09598
				{
Carlos Lopez a09598
					Gdk::Rectangle rect;
Carlos Lopez a09598
					get_cell_area(path,*column,rect);
Carlos Lopez a09598
					cellrenderer_time_track->property_value_desc()=row[model.value_desc];
Carlos Lopez a09598
					cellrenderer_time_track->property_canvas()=row[model.canvas];
Carlos Lopez a09598
					cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
Carlos Lopez a09598
					queue_draw();
Carlos Lopez a09598
					queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
Carlos Lopez a09598
					return true;
Carlos Lopez a09598
				}
Carlos Lopez a09598
			}
Carlos Lopez a09598
			break;
Carlos Lopez a09598
		default:
Carlos Lopez a09598
			break;
Carlos Lopez a09598
		}
Carlos Lopez a09598
		mimic_resync();
Carlos Lopez a09598
		return Gtk::TreeView::on_event(event);
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	void
Carlos Lopez a09598
	queue_draw_msg()
Carlos Lopez a09598
	{
Carlos Lopez a09598
		synfig::info("*************QUEUE_DRAW***************** (time track view)");
Carlos Lopez a09598
		Widget::queue_draw();
Carlos Lopez a09598
	}
Carlos Lopez a09598
	void set_model(Glib::RefPtr<layerparamtreestore> store)</layerparamtreestore>
Carlos Lopez a09598
	{
Carlos Lopez a09598
		Gtk::TreeView::set_model(store);
Carlos Lopez a09598
		param_tree_store_=store;
Carlos Lopez a09598
		cellrenderer_time_track->set_canvas_interface(param_tree_store_->canvas_interface());
Carlos Lopez a09598
		store->signal_changed().connect(sigc::mem_fun(*this, &TimeTrackView::queue_draw));
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	void
Carlos Lopez a09598
	on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
Carlos Lopez a09598
	{
Nikita Kitaev da3b47
		// \todo is this code used?
Carlos Lopez a09598
		assert(0);
Carlos Lopez a09598
Carlos Lopez a09598
		synfigapp::Action::ParamList param_list;
Carlos Lopez a09598
		param_list.add("canvas",param_tree_store_->canvas_interface()->get_canvas());
Carlos Lopez a09598
		param_list.add("canvas_interface",param_tree_store_->canvas_interface());
Carlos Lopez a09598
		param_list.add("value_node",value_node);
Carlos Lopez a09598
		param_list.add("waypoint",waypoint);
Carlos Lopez a09598
	//	param_list.add("time",canvas_interface()->get_time());
Carlos Lopez a09598
Carlos Lopez a09598
		etl::handle<studio::instance>::cast_static(param_tree_store_->canvas_interface()->get_instance())->process_action("WaypointSetSmart", param_list);</studio::instance>
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	void mimic(Gtk::TreeView *param_tree_view)
Carlos Lopez a09598
	{
Carlos Lopez a09598
		mimic_tree_view=param_tree_view;
Carlos Lopez a09598
		param_tree_view->signal_row_expanded().connect(
Carlos Lopez a09598
			sigc::hide<0>(
Carlos Lopez a09598
			sigc::hide_return(
Carlos Lopez a09598
				sigc::bind<-1>(
Carlos Lopez a09598
					sigc::mem_fun(
Carlos Lopez a09598
						*this,
Carlos Lopez a09598
						&Gtk::TreeView::expand_row
Carlos Lopez a09598
					),
Carlos Lopez a09598
					false
Carlos Lopez a09598
				)
Carlos Lopez a09598
			))
Carlos Lopez a09598
		);
Carlos Lopez a09598
		param_tree_view->signal_row_collapsed().connect(
Carlos Lopez a09598
			sigc::hide<0>(
Carlos Lopez a09598
			sigc::hide_return(
Carlos Lopez a09598
					sigc::mem_fun(
Carlos Lopez a09598
						*this,
Carlos Lopez a09598
						&Gtk::TreeView::collapse_row
Carlos Lopez a09598
					)
Carlos Lopez a09598
			))
Carlos Lopez a09598
		);
Carlos Lopez a09598
		mimic_resync();
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	void mimic_resync()
Carlos Lopez a09598
	{
Carlos Lopez a09598
		if(mimic_tree_view)
Carlos Lopez a09598
		{
536d22
			Glib::RefPtr<gtk::adjustment> adjustment(mimic_tree_view->get_vadjustment());</gtk::adjustment>
Carlos Lopez a09598
			set_vadjustment(adjustment);
Carlos Lopez a09598
a64bc0
			if (adjustment->get_page_size()>get_height())
a64bc0
				ConfigureAdjustment(adjustment)
a64bc0
					.set_page_size(get_height())
a64bc0
					.finish();
[d.j.a.y] Jerome Blanchi 090aef
/* Commented during Align rows fixing
[d.j.a.y] Jerome Blanchi 090aef
// http://www.synfig.org/issues/thebuggenie/synfig/issues/161
Carlos Lopez a09598
			int row_height = 0;
Carlos Lopez a09598
			if(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"))
Carlos Lopez a09598
				row_height = atoi(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"));
Carlos Lopez a09598
			if (row_height < 3)
Carlos Lopez a09598
				row_height = 18;
Carlos Lopez a09598
Carlos Lopez a09598
			cellrenderer_time_track->set_fixed_size(-1,row_height);
[d.j.a.y] Jerome Blanchi 0f88f6
*/
Carlos Lopez a09598
		}
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	void
Carlos Lopez a09598
	on_waypoint_clicked_timetrackview(const etl::handle<synfig::node>& node,</synfig::node>
Carlos Lopez a09598
									  const synfig::Time& time,
Carlos Lopez a09598
									  const synfig::Time& time_offset __attribute__ ((unused)),
a3e9cf
									  const synfig::Time& time_dilation __attribute__ ((unused)),
Carlos Lopez a09598
									  int button)
Carlos Lopez a09598
	{
Carlos Lopez a09598
		std::set<synfig::waypoint, std::less<uniqueid=""> > waypoint_set;</synfig::waypoint,>
Carlos Lopez a09598
		synfig::waypoint_collect(waypoint_set,time,node);
Carlos Lopez a09598
Carlos Lopez a09598
		synfigapp::ValueDesc value_desc;
Carlos Lopez a09598
Carlos Lopez a09598
		if (waypoint_set.size() == 1)
Carlos Lopez a09598
		{
Carlos Lopez a09598
			ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
Carlos Lopez a09598
			assert(value_node);
Carlos Lopez a09598
Carlos Lopez a09598
			Gtk::TreeRow row;
Carlos Lopez a09598
			if (param_tree_store_->find_first_value_node(value_node, row) && row)
Carlos Lopez a09598
				value_desc = static_cast<synfigapp::valuedesc>(row[model.value_desc]);</synfigapp::valuedesc>
Carlos Lopez a09598
		}
Carlos Lopez a09598
Carlos Lopez a09598
		if (!waypoint_set.empty())
Carlos Lopez a09598
			signal_waypoint_clicked_timetrackview(value_desc,waypoint_set,button);
Carlos Lopez a09598
	}
Carlos Lopez a09598
};
Carlos Lopez a09598
Carlos Lopez a09598
/* === G L O B A L S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === P R O C E D U R E S ================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === M E T H O D S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
Dock_Timetrack::Dock_Timetrack():
d421d7
	Dock_CanvasSpecific("timetrack",_("Timetrack"),Gtk::StockID("synfig-timetrack")),
d421d7
	table_(),
d421d7
	mimic_tree_view()
Carlos Lopez a09598
{
86a7b1
	set_use_scrolled(false);
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
Dock_Timetrack::~Dock_Timetrack()
Carlos Lopez a09598
{
d421d7
	if (table_) delete table_;
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
void
Carlos Lopez a09598
Dock_Timetrack::init_canvas_view_vfunc(etl::loose_handle<canvasview> canvas_view)</canvasview>
Carlos Lopez a09598
{
Carlos Lopez a09598
	LayerParamTreeStore::Model model;
Carlos Lopez a09598
Carlos Lopez a09598
	Glib::RefPtr<layerparamtreestore> tree_store(</layerparamtreestore>
Carlos Lopez a09598
		Glib::RefPtr<layerparamtreestore>::cast_dynamic(</layerparamtreestore>
Carlos Lopez a09598
			canvas_view->get_tree_model("params")
Carlos Lopez a09598
		)
Carlos Lopez a09598
	);
Carlos Lopez a09598
Carlos Lopez a09598
	TimeTrackView* tree_view(new TimeTrackView());
Carlos Lopez a09598
	tree_view->set_canvas_view(canvas_view);
Carlos Lopez a09598
	tree_view->set_model(tree_store);
Carlos Lopez a09598
	Gtk::TreeView* param_tree_view(dynamic_cast<gtk::treeview*>(canvas_view->get_ext_widget("params")));</gtk::treeview*>
Carlos Lopez a09598
	tree_view->mimic(param_tree_view);
344291
	mimic_tree_view=param_tree_view;
Carlos Lopez a09598
Carlos Lopez a09598
	tree_view->signal_waypoint_clicked_timetrackview.connect(sigc::mem_fun(*canvas_view, &studio::CanvasView::on_waypoint_clicked_canvasview));
Carlos Lopez a09598
[d.j.a.y] Jerome Blanchi e53d19
	studio::LayerTree* tree_layer(dynamic_cast<studio::layertree*>(canvas_view->get_ext_widget("layers_cmp")));</studio::layertree*>
[d.j.a.y] Jerome Blanchi 2daf9c
[d.j.a.y] Jerome Blanchi 26c086
	tree_layer->signal_param_tree_header_height_changed().connect(sigc::mem_fun(*this, &studio::Dock_Timetrack::on_update_header_height));
6eb56a
	canvas_view->time_model()->signal_time_changed().connect(sigc::mem_fun(*tree_view,&Gtk::TreeView::queue_draw));
Carlos Lopez a09598
	canvas_view->set_ext_widget(get_name(),tree_view);
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
void
Carlos Lopez a09598
Dock_Timetrack::refresh_selected_param()
Carlos Lopez a09598
{
Carlos Lopez a09598
/*	Gtk::TreeView* tree_view(
Carlos Lopez a09598
		static_cast<gtk::treeview*>(get_canvas_view()->get_ext_widget(get_name()))</gtk::treeview*>
Carlos Lopez a09598
	);
Carlos Lopez a09598
	Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
Carlos Lopez a09598
Carlos Lopez a09598
	if(iter)
Carlos Lopez a09598
	{
Carlos Lopez a09598
		LayerParamTreeStore::Model model;
Carlos Lopez a09598
		get_canvas_view()->work_area->set_selected_value_node(
Carlos Lopez a09598
			(synfig::ValueNode::Handle)(*iter)[model.value_node]
Carlos Lopez a09598
		);
Carlos Lopez a09598
	}
Carlos Lopez a09598
	else
Carlos Lopez a09598
	{
Carlos Lopez a09598
		get_canvas_view()->work_area->set_selected_value_node(0);
Carlos Lopez a09598
	}
Carlos Lopez a09598
*/
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez e14143
void
Carlos Lopez a09598
Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle<canvasview> canvas_view)</canvasview>
Carlos Lopez a09598
{
Carlos Lopez a09598
	if(table_)
Carlos Lopez a09598
	{
527eb3
		clear_previous();
d421d7
f53fc7
		hscrollbar_.unset_adjustment();
f53fc7
		vscrollbar_.unset_adjustment();
d421d7
f53fc7
		widget_timeslider_.set_canvas_view( CanvasView::Handle() );
d421d7
008ed2
		widget_kf_list_.set_time_model( etl::handle<timemodel>() );</timemodel>
f53fc7
		widget_kf_list_.set_canvas_interface( etl::loose_handle<synfigapp::canvasinterface>() );</synfigapp::canvasinterface>
d421d7
d421d7
		delete table_;
Carlos Lopez a09598
		table_=0;
Carlos Lopez a09598
	}
Carlos Lopez a09598
Carlos Lopez a09598
	if(canvas_view)
Carlos Lopez a09598
	{
Carlos Lopez a09598
		TimeTrackView* tree_view(dynamic_cast<timetrackview*>(canvas_view->get_ext_widget(get_name())));</timetrackview*>
[d.j.a.y] Jerome Blanchi edf738
		Gtk::TreeView* param_tree_view(dynamic_cast<gtk::treeview*>(canvas_view->get_ext_widget("params")));</gtk::treeview*>
c52704
		Gtk::ScrolledWindow* scrolled = Gtk::manage(new Gtk::ScrolledWindow);
68cab5
		scrolled->get_vscrollbar()->hide();
c52704
		scrolled->add(*tree_view);
c52704
		scrolled->set_policy(Gtk::POLICY_NEVER,Gtk::POLICY_AUTOMATIC);
c52704
		scrolled->set_vadjustment(param_tree_view->get_vadjustment());
c52704
		scrolled->show_all();
Carlos Lopez a09598
Carlos Lopez a09598
		assert(tree_view);
[d.j.a.y] Jerome Blanchi a66c8b
		// Fixed size drawing areas to align the widget_timeslider and tree_view time cursors
[d.j.a.y] Jerome Blanchi a66c8b
		// TODO ?: one align_drawingArea.(0, 1, 0, 1) modify_bg KF's color another (0, 1, 1, 2) modify_bg TS's color
[d.j.a.y] Jerome Blanchi a66c8b
		Gtk::DrawingArea* align_drawingArea1 = Gtk::manage(new Gtk::DrawingArea);
[d.j.a.y] Jerome Blanchi a66c8b
		// TODO ?: one align_drawingArea.(2, 3, 0, 1) modify_bg KF's color another (2, 3, 1, 2) modify_bg TS's color
[d.j.a.y] Jerome Blanchi a66c8b
		Gtk::DrawingArea* align_drawingArea2 = Gtk::manage(new Gtk::DrawingArea);
239936
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 14)
239936
		align_drawingArea1->set_size_request(4,-1);
239936
		align_drawingArea2->set_size_request(9,-1);
239936
#else
2d7a8c
		align_drawingArea1->set_size_request(2,-1);
970b6e
		align_drawingArea2->set_size_request(4,-1);
239936
#endif
d421d7
f53fc7
		widget_timeslider_.set_canvas_view(canvas_view);
Carlos Lopez a09598
008ed2
		widget_kf_list_.set_time_model(canvas_view->time_model());
f53fc7
		widget_kf_list_.set_canvas_interface(canvas_view->canvas_interface());
Carlos Lopez a09598
f53fc7
		vscrollbar_.set_adjustment(tree_view->get_vadjustment());
6eb56a
		hscrollbar_.set_adjustment(canvas_view->time_model()->scroll_time_adjustment());
[d.j.a.y] Jerome Blanchi 3c69d4
d421d7
		//  0------1------2------3------4
d421d7
		//  |  A   |  KF  |  A   |  v   |
d421d7
		//  |  L   |      |  L   |  s   |
d421d7
		//  1--I---x------x--I---x--c---x
d421d7
		//  |  G   |  TS  |  G   |  r   |
d421d7
		//  |  N1  |      |  N2  |  o   |
d421d7
		//  2------x------x------x--l---x
d421d7
		//  |  TV  |  TV  |  TV  |  l   |
d421d7
		//  |      |      |      |  b   |
d421d7
		//  3------x------x------x------x
d421d7
		//  | hscrollbar
d421d7
		//
d421d7
		// KF = widget_kf_list
d421d7
		// TS = widget_timeslider
d421d7
		// TV = tree_view
d421d7
		// ALIGN1 = align_drawingArea1
d421d7
		// ALIGN2 = align_drawingArea2
d421d7
[d.j.a.y] Jerome Blanchi a66c8b
		table_=new Gtk::Table(3,4);
[d.j.a.y] Jerome Blanchi a66c8b
		table_->attach(*align_drawingArea1, 0, 1, 0, 2, Gtk::SHRINK, Gtk::FILL);
f53fc7
		table_->attach(widget_kf_list_,     1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
f53fc7
		table_->attach(widget_timeslider_,  1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
[d.j.a.y] Jerome Blanchi a66c8b
		table_->attach(*align_drawingArea2, 2, 3, 0, 2, Gtk::SHRINK, Gtk::FILL);
9914c6
		table_->attach(*scrolled,           0, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
f53fc7
		table_->attach(hscrollbar_,         0, 3, 3, 4, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
f53fc7
		table_->attach(vscrollbar_,         3, 4, 0, 3, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
Carlos Lopez a09598
		add(*table_);
68cab5
		
68cab5
		// Should be here, after the widget was attached to table
68cab5
		tree_view->add_events(Gdk::SCROLL_MASK);
Carlos Lopez a09598
Carlos Lopez a09598
		//add(*last_widget_curves_);
Carlos Lopez a09598
		table_->show_all();
Carlos Lopez a09598
		show_all();
Carlos Lopez a09598
	}
Carlos Lopez a09598
	else
Carlos Lopez a09598
	{
Carlos Lopez a09598
		//clear_previous();
Carlos Lopez a09598
	}
Carlos Lopez a09598
}
[d.j.a.y] Jerome Blanchi e53d19
[d.j.a.y] Jerome Blanchi e53d19
void
300bf8
Dock_Timetrack::on_update_header_height( int /*header_height*/)
[d.j.a.y] Jerome Blanchi e53d19
{
344291
	int width=0;
344291
	int height=0;
344291
	int kf_list_height=10;
344291
	mimic_tree_view->convert_bin_window_to_widget_coords(0, 0, width, height);
f53fc7
	widget_timeslider_.set_size_request(-1,height-kf_list_height);
f53fc7
	widget_kf_list_.set_size_request(-1,kf_list_height);
[d.j.a.y] Jerome Blanchi 4a2d38
}