From 10b0dec21f2f97a175be16b75be8625658d2dda3 Mon Sep 17 00:00:00 2001 From: Nikita Kitaev Date: Fri, 16 Apr 2010 23:44:51 -0700 Subject: [PATCH] Move cellrenderers into subfolder --- synfig-studio/src/gui/Makefile.am | 16 +- synfig-studio/src/gui/canvasview.cpp | 4 +- synfig-studio/src/gui/canvasview.h | 2 +- .../src/gui/cellrenderer/cellrenderer_gradient.cpp | 96 +++ .../src/gui/cellrenderer/cellrenderer_gradient.h | 88 ++ .../src/gui/cellrenderer/cellrenderer_time.cpp | 133 +++ .../src/gui/cellrenderer/cellrenderer_time.h | 94 +++ .../gui/cellrenderer/cellrenderer_timetrack.cpp | 906 +++++++++++++++++++++ .../src/gui/cellrenderer/cellrenderer_timetrack.h | 207 +++++ .../src/gui/cellrenderer/cellrenderer_value.cpp | 604 ++++++++++++++ .../src/gui/cellrenderer/cellrenderer_value.h | 135 +++ synfig-studio/src/gui/cellrenderer_gradient.cpp | 96 --- synfig-studio/src/gui/cellrenderer_gradient.h | 88 -- synfig-studio/src/gui/cellrenderer_time.cpp | 133 --- synfig-studio/src/gui/cellrenderer_time.h | 94 --- synfig-studio/src/gui/cellrenderer_timetrack.cpp | 906 --------------------- synfig-studio/src/gui/cellrenderer_timetrack.h | 207 ----- synfig-studio/src/gui/cellrenderer_value.cpp | 604 -------------- synfig-studio/src/gui/cellrenderer_value.h | 135 --- synfig-studio/src/gui/trees/canvastreestore.cpp | 4 +- synfig-studio/src/gui/trees/childrentree.cpp | 6 +- synfig-studio/src/gui/trees/keyframetree.cpp | 2 +- synfig-studio/src/gui/trees/layertree.cpp | 4 +- synfig-studio/src/gui/widgets/widget_value.h | 2 +- 24 files changed, 2283 insertions(+), 2283 deletions(-) create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.cpp create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.h create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_time.cpp create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_time.h create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_timetrack.cpp create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_timetrack.h create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_value.cpp create mode 100644 synfig-studio/src/gui/cellrenderer/cellrenderer_value.h delete mode 100644 synfig-studio/src/gui/cellrenderer_gradient.cpp delete mode 100644 synfig-studio/src/gui/cellrenderer_gradient.h delete mode 100644 synfig-studio/src/gui/cellrenderer_time.cpp delete mode 100644 synfig-studio/src/gui/cellrenderer_time.h delete mode 100644 synfig-studio/src/gui/cellrenderer_timetrack.cpp delete mode 100644 synfig-studio/src/gui/cellrenderer_timetrack.h delete mode 100644 synfig-studio/src/gui/cellrenderer_value.cpp delete mode 100644 synfig-studio/src/gui/cellrenderer_value.h diff --git a/synfig-studio/src/gui/Makefile.am b/synfig-studio/src/gui/Makefile.am index b97c6a8..ac42f1b 100644 --- a/synfig-studio/src/gui/Makefile.am +++ b/synfig-studio/src/gui/Makefile.am @@ -8,16 +8,16 @@ MAINTAINERCLEANFILES = \ CELLRENDERER_HH = \ - cellrenderer_gradient.h \ - cellrenderer_time.h \ - cellrenderer_timetrack.h \ - cellrenderer_value.h + cellrenderer/cellrenderer_gradient.h \ + cellrenderer/cellrenderer_time.h \ + cellrenderer/cellrenderer_timetrack.h \ + cellrenderer/cellrenderer_value.h CELLRENDERER_CC = \ - cellrenderer_gradient.cpp \ - cellrenderer_time.cpp \ - cellrenderer_timetrack.cpp \ - cellrenderer_value.cpp + cellrenderer/cellrenderer_gradient.cpp \ + cellrenderer/cellrenderer_time.cpp \ + cellrenderer/cellrenderer_timetrack.cpp \ + cellrenderer/cellrenderer_value.cpp WORKAREARENDERER_HH = \ diff --git a/synfig-studio/src/gui/canvasview.cpp b/synfig-studio/src/gui/canvasview.cpp index 2485b7b..717e11f 100644 --- a/synfig-studio/src/gui/canvasview.cpp +++ b/synfig-studio/src/gui/canvasview.cpp @@ -77,8 +77,8 @@ #include "canvasview.h" #include "instance.h" #include "app.h" -#include "cellrenderer_value.h" -#include "cellrenderer_timetrack.h" +#include "cellrenderer/cellrenderer_value.h" +#include "cellrenderer/cellrenderer_timetrack.h" #include "workarea.h" #include "dialogs/dialog_color.h" #include "eventkey.h" diff --git a/synfig-studio/src/gui/canvasview.h b/synfig-studio/src/gui/canvasview.h index 3e0a47f..9b08626 100644 --- a/synfig-studio/src/gui/canvasview.h +++ b/synfig-studio/src/gui/canvasview.h @@ -55,7 +55,7 @@ #include "dialogs/canvasproperties.h" #include "dialogs/canvasoptions.h" #include "render.h" -#include "cellrenderer_timetrack.h" +#include "cellrenderer/cellrenderer_timetrack.h" #include "app.h" #include "trees/layertreestore.h" diff --git a/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.cpp b/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.cpp new file mode 100644 index 0000000..a3e6d88 --- /dev/null +++ b/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.cpp @@ -0,0 +1,96 @@ +/* === S Y N F I G ========================================================= */ +/*! \file cellrenderer_gradient.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 +#endif + +#include +#include +#include "cellrenderer_gradient.h" +#include "widgets/widget_gradient.h" +#include "app.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 ======================================================= */ + +CellRenderer_Gradient::CellRenderer_Gradient(): + Glib::ObjectBase (typeid(CellRenderer_Gradient)), + Gtk::CellRendererText (), + property_gradient_(*this,"gradient",synfig::Gradient()) +{ + assert(0); //CHECK: This class does not appear to be used. + //CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Gradient::string_edited_)); +} + +CellRenderer_Gradient::~CellRenderer_Gradient() +{ +} + + +void +CellRenderer_Gradient::render_vfunc( + const Glib::RefPtr& window, + Gtk::Widget& /*widget*/, + const Gdk::Rectangle& /*background_area*/, + const Gdk::Rectangle& ca, + const Gdk::Rectangle& /*expose_area*/, + Gtk::CellRendererState /*flags*/) +{ + if(!window) + return; + render_gradient_to_window(window,ca,property_gradient_.get_value()); +} + + +Gtk::CellEditable* +CellRenderer_Gradient::start_editing_vfunc( + GdkEvent* /*event*/, + Gtk::Widget& /*widget*/, + const Glib::ustring& /*path*/, + const Gdk::Rectangle& /*background_area*/, + const Gdk::Rectangle& /*cell_area*/, + Gtk::CellRendererState /*flags*/) +{ + return 0; +} diff --git a/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.h b/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.h new file mode 100644 index 0000000..10b54c5 --- /dev/null +++ b/synfig-studio/src/gui/cellrenderer/cellrenderer_gradient.h @@ -0,0 +1,88 @@ +/* === S Y N F I G ========================================================= */ +/*! \file cellrenderer_gradient.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_CELLRENDERER_GRADIENT_H +#define __SYNFIG_STUDIO_CELLRENDERER_GRADIENT_H + +/* === H E A D E R S ======================================================= */ + +#include +#include + +#include +#include + +#include + +/* === 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 Gtk { class Entry; class Button; }; + +namespace studio { + +class CellRenderer_Gradient : public Gtk::CellRendererText +{ + sigc::signal signal_secondary_click_; + sigc::signal signal_edited_; + + Glib::Property property_gradient_; + +public: + sigc::signal &signal_edited() + {return signal_edited_; } + + Glib::PropertyProxy property_gradient() { return property_gradient_.get_proxy();} + + CellRenderer_Gradient(); + ~CellRenderer_Gradient(); + +protected: + + virtual void + render_vfunc( + const Glib::RefPtr& window, + Gtk::Widget& widget, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& ca, + const Gdk::Rectangle& expose_area, + Gtk::CellRendererState flags); + + virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event, + Gtk::Widget& widget, + const Glib::ustring& path, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& cell_area, + Gtk::CellRendererState flags); + +}; // END of class CellRenderer_Gradient + +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/src/gui/cellrenderer/cellrenderer_time.cpp b/synfig-studio/src/gui/cellrenderer/cellrenderer_time.cpp new file mode 100644 index 0000000..9c70536 --- /dev/null +++ b/synfig-studio/src/gui/cellrenderer/cellrenderer_time.cpp @@ -0,0 +1,133 @@ +/* === S Y N F I G ========================================================= */ +/*! \file cellrenderer_time.cpp +** \brief Template File +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 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 +#endif + +#include +#include +#include "cellrenderer_time.h" +#include "app.h" +#include "widgets/widget_time.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 ======================================================= */ + +CellRenderer_Time::CellRenderer_Time(): + Glib::ObjectBase (typeid(CellRenderer_Time)), + Gtk::CellRendererText (), + property_time_(*this,"time",synfig::Time(0)), + property_fps_(*this,"fps", float(0)) +{ + CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Time::string_edited_)); +} + +CellRenderer_Time::~CellRenderer_Time() +{ + if (getenv("SYNFIG_DEBUG_DESTRUCTORS")) + synfig::info("CellRenderer_Time::~CellRenderer_Time(): Deleted"); +} + +void +CellRenderer_Time::string_edited_(const Glib::ustring&path,const Glib::ustring&str) +{ + signal_edited_(path,Time((String)str,(Real)Time(property_fps_))); +} + +void +CellRenderer_Time::render_vfunc( + const Glib::RefPtr& window, + Gtk::Widget& widget, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& ca, + const Gdk::Rectangle& expose_area, + Gtk::CellRendererState flags) +{ + if(!window) + return; + //int height = ca.get_height(); + + Gtk::StateType state = Gtk::STATE_INSENSITIVE; + if(property_editable()) + state = Gtk::STATE_NORMAL; + if((flags & Gtk::CELL_RENDERER_SELECTED) != 0) + state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE; + + const Time time(property_time_); + const float fps((Real)Time(property_fps_)); + + property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format()); + + CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags); +} + + +Gtk::CellEditable* +CellRenderer_Time::start_editing_vfunc( + GdkEvent* event, + Gtk::Widget& widget, + const Glib::ustring& path, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& cell_area, + Gtk::CellRendererState flags) +{ + // If we aren't editable, then there is nothing to do + if(!property_editable()) + return 0; + + const Time time(property_time_); + const float fps((Real)Time(property_fps_)); + + property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format()|Time::FORMAT_FULL); +#if 0 + Widget_Time* widget_time(manage(new Widget_Time)); + widget_time->set_fps(fps); + widget_time->set_value(time); + widget_time->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_Time::on_value_editing_done)); + return widget_time; +#else + return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags); +#endif +} diff --git a/synfig-studio/src/gui/cellrenderer/cellrenderer_time.h b/synfig-studio/src/gui/cellrenderer/cellrenderer_time.h new file mode 100644 index 0000000..149f7d8 --- /dev/null +++ b/synfig-studio/src/gui/cellrenderer/cellrenderer_time.h @@ -0,0 +1,94 @@ +/* === S Y N F I G ========================================================= */ +/*! \file cellrenderer_time.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_CELLRENDERER_TIME_H +#define __SYNFIG_STUDIO_CELLRENDERER_TIME_H + +/* === H E A D E R S ======================================================= */ + +#include +#include + +#include +#include + +#include + +/* === 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 Gtk { class Entry; class Button; }; + +namespace studio { + +class CellRenderer_Time : public Gtk::CellRendererText +{ + sigc::signal signal_secondary_click_; + sigc::signal signal_edited_; + + Glib::Property property_time_; + Glib::Property property_fps_; + + void string_edited_(const Glib::ustring&,const Glib::ustring&); + + void on_value_editing_done(); + +public: + sigc::signal &signal_edited() + {return signal_edited_; } + + Glib::PropertyProxy property_time() { return property_time_.get_proxy();} + Glib::PropertyProxy property_fps() { return property_fps_.get_proxy();} + + CellRenderer_Time(); + ~CellRenderer_Time(); + +protected: + + virtual void + render_vfunc( + const Glib::RefPtr& window, + Gtk::Widget& widget, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& ca, + const Gdk::Rectangle& expose_area, + Gtk::CellRendererState flags); + + virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event, + Gtk::Widget& widget, + const Glib::ustring& path, + const Gdk::Rectangle& background_area, + const Gdk::Rectangle& cell_area, + Gtk::CellRendererState flags); + +}; // END of class CellRenderer_Time + +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/src/gui/cellrenderer/cellrenderer_timetrack.cpp b/synfig-studio/src/gui/cellrenderer/cellrenderer_timetrack.cpp new file mode 100644 index 0000000..c06e9b1 --- /dev/null +++ b/synfig-studio/src/gui/cellrenderer/cellrenderer_timetrack.cpp @@ -0,0 +1,906 @@ +/* === S Y N F I G ========================================================= */ +/*! \file cellrenderer_timetrack.cpp +** \brief Template Header +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 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 +#endif + +#include +#include "cellrenderer_timetrack.h" +#include +#include +#include +#include +#include "widgets/widget_value.h" +#include "app.h" +#include +#include +#include "widgets/widget_time.h" +#include "widgets/widget_timeslider.h" + +#include +#include "instance.h" + +#include "general.h" + +#endif + +using namespace synfig; +using namespace std; +using namespace etl; +using namespace studio; + +/* === M A C R O S ========================================================= */ + +/* === G L O B A L S ======================================================= */ + +static char stipple_xpm[] = { 2, 0 }; + +//mode for modifier keys +enum MODMODE +{ + NONE = 0, + SELECT_MASK = Gdk::CONTROL_MASK, + COPY_MASK = Gdk::SHIFT_MASK, + DELETE_MASK = Gdk::MOD1_MASK +}; + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +CellRenderer_TimeTrack::CellRenderer_TimeTrack(): + Glib::ObjectBase (typeid(CellRenderer_TimeTrack)), + Gtk::CellRenderer (), + adjustment_ (10,10,20,0,0,0), + + property_valuedesc_ (*this,"value_desc",synfigapp::ValueDesc()), + property_canvas_ (*this,"canvas",synfig::Canvas::Handle()), + property_adjustment_(*this,"adjustment",&adjustment_), + property_enable_timing_info_(*this,"enable-timing-info", false) +{ + dragging=false; + selection=false; +} + +CellRenderer_TimeTrack::~CellRenderer_TimeTrack() +{ + if (getenv("SYNFIG_DEBUG_DESTRUCTORS")) + synfig::info("CellRenderer_TimeTrack::~CellRenderer_TimeTrack(): Deleted"); +} + +void +CellRenderer_TimeTrack::set_adjustment(Gtk::Adjustment &x) +{ + property_adjustment_=&x; +// x.signal_value_changed().connect(sigc::mem_fun(*this,&Gtk::Widget::queue_draw)); +} + +synfig::Canvas::Handle +CellRenderer_TimeTrack::get_canvas()const +{ + return const_cast(this)->property_canvas().get_value(); +} + +Gtk::Adjustment * +CellRenderer_TimeTrack::get_adjustment() +{ + return (Gtk::Adjustment*)property_adjustment_; +} + +const Gtk::Adjustment * +CellRenderer_TimeTrack::get_adjustment()const +{ + return (const Gtk::Adjustment*)property_adjustment_; +} + +bool +CellRenderer_TimeTrack::is_selected(const Waypoint& waypoint)const +{ + return selected==waypoint; +} + +const synfig::Time get_time_offset_from_vdesc(const synfigapp::ValueDesc &v) +{ +#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET + if(getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") || + v.get_value_type() != synfig::ValueBase::TYPE_CANVAS) + return synfig::Time::zero(); + + synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle()); + if(!canvasparam) + return synfig::Time::zero(); + + if (!v.parent_is_layer_param()) + return synfig::Time::zero(); + + synfig::Layer::Handle layer = v.get_layer(); + + if (layer->get_name()!="PasteCanvas") + return synfig::Time::zero(); + + return layer->get_param("time_offset").get(Time()); +#else // ADJUST_WAYPOINTS_FOR_TIME_OFFSET + return synfig::Time::zero(); +#endif +} + +//kind of a hack... pointer is ugly +const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v) +{ + if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") && + v.get_value_type() == synfig::ValueBase::TYPE_CANVAS) + { + synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle()); + + if(canvasparam) + return &canvasparam->get_times(); + } + + ValueNode *base_value = v.get_value_node().get(); + + ValueNode_DynamicList *parent_value_node = + v.parent_is_value_node() ? + dynamic_cast(v.get_parent_value_node().get()) : + 0; + + //we want a dynamic list entry to override the normal... + if(parent_value_node) + { + return &parent_value_node->list[v.get_index()].get_times(); + }else if(base_value) //don't render stuff if it's just animated... + { + return &base_value->get_times(); + } + return 0; +} + +bool get_closest_time(const synfig::Node::time_set &tset, const Time &t, const Time &range, Time &out) +{ + Node::time_set::const_iterator i,j,end = tset.end(); + + // stop the crash mentioned in bug #1689282 + // doesn't solve the underlying problem though, I don't think + if (tset.size() == 0) + { + synfig::error(__FILE__":%d: tset.size() == 0",__LINE__); + return false; + } + + //TODO add in RangeGet so it's not so damn hard to click on points + + i = tset.upper_bound(t); //where t is the lower bound, t < [first,i) + j = i; --j; + + double dist = Time::end(); + double closest = 0; + + if(i != end) + { + closest = i->get_time(); + dist = abs(i->get_time() - t); + } + + if(j != end && (abs(j->get_time() - t) < dist) ) + { + closest = j->get_time(); + dist = abs(j->get_time() - t); + } + + if( dist <= range/2 ) + { + out = closest; + return true; + } + + return false; +} + +void +CellRenderer_TimeTrack::render_vfunc( + const Glib::RefPtr& window, + Gtk::Widget& widget, + const Gdk::Rectangle& /*background_area*/, + const Gdk::Rectangle& area_, + const Gdk::Rectangle& /*expose_area*/, + Gtk::CellRendererState /*flags*/) +{ + if(!window) + return; + + Glib::RefPtr gc(Gdk::GC::create(window)); + Glib::RefPtr inactive_gc(Gdk::GC::create(window)); + Gtk::Adjustment *adjustment=get_adjustment(); + // Gtk::StateType state = Gtk::STATE_ACTIVE; + // Gtk::ShadowType shadow; + + Gdk::Color + curr_time_color("#0000ff"), + inactive_color("#000000"), + keyframe_color("#a07f7f"); + Gdk::Color activepoint_color[2]; + + activepoint_color[0]=Gdk::Color("#ff0000"); + activepoint_color[1]=Gdk::Color("#00ff00"); + + inactive_gc->set_rgb_fg_color(inactive_color); + inactive_gc->set_stipple(Gdk::Bitmap::create(stipple_xpm,2,2)); + inactive_gc->set_fill(Gdk::STIPPLED); + + synfig::Canvas::Handle canvas(property_canvas().get_value()); + + synfigapp::ValueDesc value_desc = property_value_desc().get_value(); + synfig::ValueNode *base_value = value_desc.get_value_node().get(); + // synfig::ValueNode_Animated *value_node=dynamic_cast(base_value); + + synfig::ValueNode_DynamicList *parent_value_node(0); + if(property_value_desc().get_value().parent_is_value_node()) + parent_value_node=dynamic_cast(property_value_desc().get_value().get_parent_value_node().get()); + + // If the canvas is defined, then load up the keyframes + if(canvas) + { + const synfig::KeyframeList& keyframe_list(canvas->keyframe_list()); + synfig::KeyframeList::const_iterator iter; + + for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter) + { + if(!iter->get_time().is_valid()) + continue; + + const int x((int)((float)area_.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower()))); + if(iter->get_time()>=adjustment->get_lower() && iter->get_time()get_upper()) + { + gc->set_rgb_fg_color(keyframe_color); + window->draw_rectangle(gc, true, area_.get_x()+x, area_.get_y(), 1, area_.get_height()+1); + } + } + } + + //render all the time points that exist + { + const synfig::Node::time_set *tset = get_times_from_vdesc(value_desc); + + if(tset) + { + const synfig::Time time_offset = get_time_offset_from_vdesc(value_desc); + synfig::Node::time_set::const_iterator i = tset->begin(), end = tset->end(); + + float lower = adjustment->get_lower(), + upper = adjustment->get_upper(); + + Glib::RefPtr gc = Gdk::GC::create(widget.get_window()); + + Gdk::Rectangle area(area_); + gc->set_clip_rectangle(area); + gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER); + + bool valselected = sel_value.get_value_node() == base_value && !sel_times.empty(); + + float cfps = get_canvas()->rend_desc().get_frame_rate(); + + vector