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 = \
#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"
#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"
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#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<Gdk::Drawable>& 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;
+}
--- /dev/null
+/* === 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 <gtkmm/entry.h>
+#include <gtkmm/cellrenderertext.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+
+#include <synfig/gradient.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class CellRenderer_Gradient : public Gtk::CellRendererText
+{
+ sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+ sigc::signal<void, const Glib::ustring&, synfig::Gradient> signal_edited_;
+
+ Glib::Property<synfig::Gradient> property_gradient_;
+
+public:
+ sigc::signal<void, const Glib::ustring&, synfig::Gradient> &signal_edited()
+ {return signal_edited_; }
+
+ Glib::PropertyProxy<synfig::Gradient> property_gradient() { return property_gradient_.get_proxy();}
+
+ CellRenderer_Gradient();
+ ~CellRenderer_Gradient();
+
+protected:
+
+ virtual void
+ render_vfunc(
+ const Glib::RefPtr<Gdk::Drawable>& 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
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#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<Gdk::Drawable>& 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
+}
--- /dev/null
+/* === 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 <gtkmm/entry.h>
+#include <gtkmm/cellrenderertext.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+
+#include <synfig/time.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class CellRenderer_Time : public Gtk::CellRendererText
+{
+ sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+ sigc::signal<void, const Glib::ustring&, synfig::Time> signal_edited_;
+
+ Glib::Property<synfig::Time> property_time_;
+ Glib::Property<synfig::Time> property_fps_;
+
+ void string_edited_(const Glib::ustring&,const Glib::ustring&);
+
+ void on_value_editing_done();
+
+public:
+ sigc::signal<void, const Glib::ustring&, synfig::Time> &signal_edited()
+ {return signal_edited_; }
+
+ Glib::PropertyProxy<synfig::Time> property_time() { return property_time_.get_proxy();}
+ Glib::PropertyProxy<synfig::Time> property_fps() { return property_fps_.get_proxy();}
+
+ CellRenderer_Time();
+ ~CellRenderer_Time();
+
+protected:
+
+ virtual void
+ render_vfunc(
+ const Glib::RefPtr<Gdk::Drawable>& 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
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include "cellrenderer_timetrack.h"
+#include <gtk/gtk.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/combo.h>
+#include <ETL/stringf>
+#include "widgets/widget_value.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include "widgets/widget_time.h"
+#include "widgets/widget_timeslider.h"
+
+#include <synfigapp/canvasinterface.h>
+#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<CellRenderer_TimeTrack*>(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<ValueNode_DynamicList *>(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<Gdk::Drawable>& 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<Gdk::GC> gc(Gdk::GC::create(window));
+ Glib::RefPtr<Gdk::GC> 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<synfig::ValueNode_Animated*>(base_value);
+
+ synfig::ValueNode_DynamicList *parent_value_node(0);
+ if(property_value_desc().get_value().parent_is_value_node())
+ parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(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()<adjustment->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<Gdk::GC> 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<Time> drawredafter;
+
+ Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
+ for(; i != end; ++i)
+ {
+ //find the coordinate in the drawable space...
+ Time t_orig = i->get_time();
+ if(!t_orig.is_valid()) continue;
+ Time t = t_orig - time_offset;
+ if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;
+
+ //if it found it... (might want to change comparison, and optimize
+ // sel_times.find to not produce an overall nlogn solution)
+
+ bool selected=false;
+ //not dragging... just draw as per normal
+ //if move dragging draw offset
+ //if copy dragging draw both...
+
+ if(valselected && sel_times.find(t_orig) != sel_times.end())
+ {
+ if(dragging) //skip if we're dragging because we'll render it later
+ {
+ if(mode & COPY_MASK) // draw both blue and red moved
+ {
+ drawredafter.push_back(t + diff.round(cfps));
+ gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
+ }else if(mode & DELETE_MASK) //it's just red...
+ {
+ gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+ selected=true;
+ }else //move - draw the red on top of the others...
+ {
+ drawredafter.push_back(t + diff.round(cfps));
+ continue;
+ }
+ }else
+ {
+ gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+ selected=true;
+ }
+ }else
+ {
+ gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
+ }
+
+ //synfig::info("Displaying time: %.3f s",(float)t);
+ const int x = (int)((t-lower)*area.get_width()/(upper-lower));
+
+ //should draw me a grey filled circle...
+ Gdk::Rectangle area2(
+ area.get_x() - area.get_height()/2 + x + 1,
+ area.get_y() + 1,
+ area.get_height()-2,
+ area.get_height()-2
+ );
+ render_time_point_to_window(window,area2,*i - time_offset,selected);
+
+ /*window->draw_arc(gc,true,
+ area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+ area.get_height()/2, area.get_height()*3/4,
+ 0, 64*360);
+
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ window->draw_arc(gc,false,
+ area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+ area.get_height()/2, area.get_height()*3/4,
+ 0, 64*360);
+ */
+ }
+
+ {
+ vector<Time>::iterator i = drawredafter.begin(), end = drawredafter.end();
+ for(; i != end; ++i)
+ {
+ //find the coordinate in the drawable space...
+ Time t = *i;
+
+ if(!t.is_valid())
+ continue;
+
+ //synfig::info("Displaying time: %.3f s",(float)t);
+ const int x = (int)((t-lower)*area.get_width()/(upper-lower));
+
+ //should draw me a grey filled circle...
+
+ Gdk::Rectangle area2(
+ area.get_x() - area.get_height()/2 + x + 1,
+ area.get_y() + 1,
+ area.get_height()-2,
+ area.get_height()-2
+ );
+ render_time_point_to_window(window,area2,*i,true);
+/* gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+ window->draw_arc(gc,true,
+ area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+ area.get_height()/2, area.get_height()*3/4,
+ 0, 64*360);
+
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ window->draw_arc(gc,false,
+ area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+ area.get_height()/2, area.get_height()*3/4,
+ 0, 64*360);
+*/
+ }
+ }
+ }
+ }
+
+ /* THIS IS NOW HANDLED ENTIRELY BY THE TIMEPOINT SYSTEM
+ // This this is an animated value node, then render the waypoints
+ if(value_node)
+ {
+ //now render the actual waypoints
+ synfig::ValueNode_Animated::WaypointList::iterator iter;
+ for(
+ iter=value_node->waypoint_list().begin();
+ iter!=value_node->waypoint_list().end();
+ iter++
+ )
+ {
+ if(!iter->get_time().is_valid())
+ continue;
+ int x;
+ bool selected=false;
+ if(is_selected(*iter))
+ {
+ Time t(iter->get_time());
+
+
+ if(dragging)
+ t=(t+selected_time-drag_time).round(get_canvas()->rend_desc().get_frame_rate());
+
+ x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(t-adjustment->get_lower()));
+ shadow=Gtk::SHADOW_IN;
+ selected=true;
+ }
+ else
+ {
+ x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower()));
+ shadow=Gtk::SHADOW_OUT;
+ selected=false;
+ }
+
+
+ widget.get_style()->paint_diamond(
+ Glib::RefPtr<Gdk::Window>::cast_static(window),
+ state,
+ shadow,
+ area,
+ widget,
+ "solid",
+ area.get_x()+x-area.get_height()/4,
+ area.get_y()+area.get_height()/4,
+ area.get_height()/2,
+ area.get_height()/2
+ );
+ }
+ }
+ */
+ Gdk::Rectangle area(area_);
+ // If the parent of this value node is a dynamic list, then
+ // render the on and off times
+ if(parent_value_node)
+ {
+ const int index(property_value_desc().get_value().get_index());
+ const synfig::ValueNode_DynamicList::ListEntry& list_entry(parent_value_node->list[index]);
+ const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(list_entry.timing_info);
+ synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter,next;
+
+ bool is_off(false);
+ if(!activepoint_list.empty())
+ is_off=!activepoint_list.front().state;
+
+ int xstart(0);
+
+ int x=0,prevx=0;
+ for(next=activepoint_list.begin(),iter=next++;iter!=activepoint_list.end();iter=next++)
+ {
+ x=((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->time-adjustment->get_lower())));
+ if(x<0)x=0;
+ if(x>area.get_width())x=area.get_width();
+
+ bool status_at_time=0;
+ if(next!=activepoint_list.end())
+ {
+ status_at_time=!list_entry.status_at_time((iter->time+next->time)/2.0);
+ }
+ else
+ status_at_time=!list_entry.status_at_time(Time::end());
+
+ if(!is_off && status_at_time)
+ {
+ xstart=x;
+ is_off=true;
+ }
+ else
+ if(is_off && !status_at_time)
+ {
+ window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
+ is_off=false;
+ }
+
+ /*
+ if(!is_off && iter!=activepoint_list.end() && next->state==false && iter->state==false)
+ {
+ xstart=x;
+ is_off=true;
+ }
+ else if(is_off && next!=activepoint_list.end() && iter->state==false && next->state==true)
+ {
+ window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
+ is_off=false;
+ }
+ else if(is_off && iter!=activepoint_list.end() && iter->state==true)
+ {
+ window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), prevx-xstart, area.get_height());
+ is_off=false;
+ }
+ */
+
+
+
+ if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
+ {
+ int w(1);
+ if(selected==*iter)
+ w=3;
+ gc->set_rgb_fg_color(activepoint_color[iter->state]);
+ window->draw_rectangle(gc, true, area.get_x()+x-w/2, area.get_y(), w, area.get_height());
+ }
+ prevx=x;
+ }
+ if(is_off)
+ {
+ window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), area.get_width()-xstart, area.get_height());
+ }
+ }
+
+ // Render a line that defines the current tick in time
+ {
+ gc->set_rgb_fg_color(curr_time_color);
+
+ const int x((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(adjustment->get_value()-adjustment->get_lower())));
+
+ if(adjustment->get_value()>=adjustment->get_lower() && adjustment->get_value()<adjustment->get_upper())
+ window->draw_rectangle(gc, true, area.get_x()+x, area.get_y(), 1, area.get_height());
+ }
+}
+
+synfig::ValueNode_Animated::WaypointList::iterator
+CellRenderer_TimeTrack::find_waypoint(const synfig::Time& /*t*/,const synfig::Time& scope)
+{
+ synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
+
+ Time nearest(Time::end());
+
+ synfig::ValueNode_Animated::WaypointList::iterator iter,ret;
+
+ if(value_node)
+ {
+ for(
+ iter=value_node->waypoint_list().begin();
+ iter!=value_node->waypoint_list().end();
+ iter++
+ )
+ {
+ Time val=abs(iter->get_time()-selected_time);
+ if(val<nearest)
+ {
+ nearest=val;
+ ret=iter;
+ }
+ }
+
+ if(nearest!=Time::end() && nearest<scope)
+ {
+ return ret;
+ }
+ }
+ throw int();
+}
+
+bool
+CellRenderer_TimeTrack::activate_vfunc(
+ GdkEvent* event,
+ Gtk::Widget& /*widget*/,
+ const Glib::ustring& treepath,
+ const Gdk::Rectangle& /*background_area*/,
+ const Gdk::Rectangle& cell_area,
+ Gtk::CellRendererState /*flags*/)
+{
+ path=treepath;
+ synfig::ValueNode_Animated::WaypointList::iterator iter;
+ Time nearest=1000000000;
+ Gtk::Adjustment *adjustment=get_adjustment();
+
+ // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
+
+ synfig::Canvas::Handle canvas(get_canvas());
+
+ synfig::ValueNode_DynamicList *parent_value_node(0);
+ if(property_value_desc().get_value().parent_is_value_node())
+ parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
+
+ Time deltatime = 0;
+ Time curr_time;
+ switch(event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+
+ mode = NONE;
+ {
+ Gdk::ModifierType mod;
+ Gdk::Event(event).get_state(mod);
+ mode = mod;
+ }
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ default:
+ curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+ {
+ Gdk::ModifierType mod;
+ Gdk::Event(event).get_state(mod);
+ mode = mod;
+ }
+ break;
+ }
+ actual_time = curr_time;
+ if(canvas)
+ curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
+ selected_time=curr_time;
+
+ Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());
+
+ switch(event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+
+ //Deal with time point selection, but only if they aren't involved in the insanity...
+ if(/*!value_node && */event->button.button == 1)
+ {
+ Time stime;
+
+ /*! UI specification:
+
+ When nothing is selected, clicking on a point in either normal mode or
+ additive mode will select the time point closest to the click.
+ Subtractive click will do nothing
+
+ When things are already selected, clicking on a selected point does
+ nothing (in both normal and add mode). Add mode clicking on an unselected
+ point adds it to the set. Normal clicking on an unselected point will
+ select only that one time point. Subtractive clicking on any point
+ will remove it from the the set if it is included.
+ */
+
+ synfigapp::ValueDesc valdesc = property_value_desc().get_value();
+ const Node::time_set *tset = get_times_from_vdesc(valdesc);
+ const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
+
+ bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
+ bool selectmode = mode & SELECT_MASK;
+
+ //NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
+ //we want to jump to the value desc if we're not currently on it
+ // but only if we want to add the point
+ if(clickfound && !(sel_value == valdesc))
+ {
+ sel_value = valdesc;
+ sel_times.clear();
+ }
+
+ //now that we've made sure we're selecting the correct value, deal with the already selected points
+ set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
+ bool found = foundi != sel_times.end();
+
+ //remove all other points from our list... (only select the one we need)
+ if(!selectmode && !found)
+ {
+ sel_times.clear();
+ }
+
+ if(found && selectmode) //remove a single already selected point
+ {
+ sel_times.erase(foundi);
+ }else if(clickfound) //otherwise look at adding it
+ {
+ //for replace the list was cleared earlier, and for add it wasn't so it works
+ sel_times.insert(stime);
+ }
+ }
+
+ selection=false;
+ try
+ {
+ iter=find_waypoint(selected_time,pixel_width*cell_area.get_height()/2);
+ selected_waypoint=iter;
+ selected=*iter;
+
+ selection=true;
+ }
+ catch(int)
+ {
+ selection=false;
+ selected=synfig::UniqueID::nil();
+ }
+
+ if((!sel_times.empty() || selection) && event->button.button==1)
+ {
+ dragging=true;
+ drag_time=selected_time;
+ actual_dragtime=actual_time;
+ }
+ //selected_time=iter->time;
+
+ /*
+ // Activepoint Selection
+ if(parent_value_node)
+ {
+ const int index(property_value_desc().get_value().get_index());
+ const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(parent_value_node->list[index].timing_info);
+ synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter;
+
+ for(iter=activepoint_list.begin();iter!=activepoint_list.end();++iter)
+ {
+ Time val=abs(iter->time-selected_time);
+ if(val<nearest)
+ {
+ nearest=val;
+ selected=*iter;
+ selection=true;
+ }
+ }
+ // Perhaps I should signal if we selected this activepoint?
+ }*/
+
+ if(event->button.button==3)
+ {
+ Time stime;
+ synfigapp::ValueDesc valdesc = property_value_desc().get_value();
+ const Node::time_set *tset = get_times_from_vdesc(valdesc);
+ synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
+
+ bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
+
+ etl::handle<synfig::Node> node;
+ if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
+ valdesc.get_value(stime).get_type()==ValueBase::TYPE_CANVAS)
+ {
+ node=Canvas::Handle(valdesc.get_value(stime).get(Canvas::Handle()));
+ }
+ else //if(valdesc.is_value_node())
+ {
+ node=valdesc.get_value_node();
+ }
+
+ if(clickfound && node)
+ signal_waypoint_clicked_cellrenderer()(node, stime, time_offset, 2);
+ }
+
+ break;
+ case GDK_MOTION_NOTIFY:
+ //if(selection && dragging)
+ // selected_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+ return true;
+
+ break;
+ case GDK_BUTTON_RELEASE:
+ {
+ //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+ dragging=false;
+
+ /*if(event->button.button==3 && selection)
+ {
+ signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
+ return true;
+ }
+ */
+
+ //Time point stuff...
+ if(event->button.button == 1)
+ {
+ bool delmode = (mode & DELETE_MASK) && !(mode & COPY_MASK);
+ deltatime = actual_time - actual_dragtime;
+ if(sel_times.size() != 0 && (delmode || !deltatime.is_equal(Time(0))))
+ {
+ synfigapp::Action::ParamList param_list;
+ param_list.add("canvas",canvas_interface()->get_canvas());
+ param_list.add("canvas_interface",canvas_interface());
+
+ if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
+ sel_value.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
+ {
+ param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
+ }else
+ {
+ param_list.add("addvaluedesc",sel_value);
+ }
+
+ set<Time> newset;
+ std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
+ for(; i != end; ++i)
+ {
+ param_list.add("addtime",*i);
+
+ newset.insert((*i + deltatime).round(get_canvas()->rend_desc().get_frame_rate()));
+ }
+
+ if(!delmode)
+ param_list.add("deltatime",deltatime);
+ // param_list.add("time",canvas_interface()->get_time());
+
+ if(mode & COPY_MASK) //copy
+ {
+ etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+ ->process_action("TimepointsCopy", param_list);
+ }else if(delmode) //DELETE
+ {
+ etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+ ->process_action("TimepointsDelete", param_list);
+ }else //MOVE
+ {
+ etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+ ->process_action("TimepointsMove", param_list);
+ }
+
+ //now replace all the selected with the new selected
+ sel_times = newset;
+ }
+ }
+
+
+
+ /*if(value_node && selection)
+ {
+ if(selected_time==drag_time && event->button.button!=3)
+ signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
+ else
+ if(event->button.button==1)
+ {
+ synfig::Waypoint waypoint(*selected_waypoint);
+ Time newtime((waypoint.get_time()+(selected_time-drag_time)).round(canvas->rend_desc().get_frame_rate()));
+ if(waypoint.get_time()!=newtime)
+ {
+ waypoint.set_time(newtime);
+ signal_waypoint_changed_(waypoint,value_node);
+ }
+ }
+ }*/
+
+ //if(selection)
+ // selected_time=iter->time;
+ //selected_time=iter->get_time();
+ return true;
+ }
+ default:
+ //std::cerr<<"unknown event type "<<event->type<<std::endl;
+ return false;
+ break;
+ }
+
+
+
+ return false;
+}
+
+
+
+// The following three functions don't get documented correctly by
+// doxygen 1.5.[23] because of a bug with any function whose name
+// begins with 'property'. Fixed in doxygen 1.5.4 apparently. See
+// http://bugzilla.gnome.org/show_bug.cgi?id=471185 .
+Glib::PropertyProxy<synfigapp::ValueDesc>
+CellRenderer_TimeTrack::property_value_desc()
+{
+ return Glib::PropertyProxy<synfigapp::ValueDesc>(this,"value_desc");
+}
+
+Glib::PropertyProxy<synfig::Canvas::Handle>
+CellRenderer_TimeTrack::property_canvas()
+{
+ return Glib::PropertyProxy<synfig::Canvas::Handle>(this,"canvas");
+}
+
+Glib::PropertyProxy<Gtk::Adjustment* >
+CellRenderer_TimeTrack::property_adjustment()
+{
+ return Glib::PropertyProxy<Gtk::Adjustment* >(this,"adjustment");
+}
+
+void
+CellRenderer_TimeTrack::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
+{
+ canvas_interface_ = h;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file cellrenderer_timetrack.h
+** \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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
+#define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/progressbar.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/scrollbar.h>
+#include <gtkmm/cellrenderer.h>
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/menu.h>
+
+
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfig/string.h>
+#include <synfig/time.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 Widget_ValueBase;
+
+/*! \class CellRenderer_TimeTrack
+** \brief A cell renderer that displays the waypoints for Animated ValueNodes.
+*/
+class CellRenderer_TimeTrack :
+ public Gtk::CellRenderer
+{
+
+ /*
+ -- ** -- P R I V A T E D A T A ---------------------------------------------
+ */
+
+private:
+ //! Time adjustment window
+ Gtk::Adjustment adjustment_;
+
+ //! Signal for when the user clicks on a waypoint
+ sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> signal_waypoint_clicked_cellrenderer_;
+
+ sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
+
+ //! Iterator for selected waypoint. (Should this be an UniqueID instead?)
+ synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
+
+ synfig::UniqueID selected;
+
+ //! selected information for time... (will work for way points etc...)
+ //TODO: make multiple... on both time and value select...
+ std::set<synfig::Time> sel_times;
+ synfigapp::ValueDesc sel_value;
+ synfig::Time actual_time;
+ synfig::Time actual_dragtime;
+ int mode;
+
+ //! ???
+ synfig::Time selected_time;
+
+ //! The path to the current item in the tree model
+ Glib::ustring path;
+
+ //! ???
+ bool selection;
+
+ bool dragging;
+
+ synfig::Time drag_time;
+
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+ /*
+ -- ** -- P R O P E R T I E S -------------------------------------------------
+ */
+
+private:
+
+ //! ValueBase Desc
+ Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
+
+ //! Canvas
+ Glib::Property<synfig::Canvas::Handle> property_canvas_;
+
+ //! ??? \see adjustment_
+ Glib::Property<Gtk::Adjustment* > property_adjustment_;
+
+ //! \writeme
+ Glib::Property<bool> property_enable_timing_info_;
+
+ /*
+ -- ** -- P R O P E R T Y I N T E R F A C E S -------------------------------
+ */
+
+public:
+
+ Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
+
+ Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
+
+ Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
+
+ /*
+ -- ** -- S I G N A L I N T E R F A C E S -----------------------------------
+ */
+
+public:
+
+ sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> &signal_waypoint_clicked_cellrenderer()
+ {return signal_waypoint_clicked_cellrenderer_; }
+
+ sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
+ {return signal_waypoint_changed_; }
+
+ /*
+ -- ** -- P U B L I C M E T H O D S -----------------------------------------
+ */
+
+public:
+
+ CellRenderer_TimeTrack();
+ ~CellRenderer_TimeTrack();
+
+ void set_adjustment(Gtk::Adjustment &x);
+ Gtk::Adjustment *get_adjustment();
+ const Gtk::Adjustment *get_adjustment()const;
+
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface()const {return canvas_interface_;}
+ void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
+
+ synfig::Canvas::Handle get_canvas()const;
+
+ bool is_selected(const synfig::Waypoint& waypoint)const;
+
+ synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
+
+ virtual void
+ render_vfunc(
+ const Glib::RefPtr<Gdk::Drawable>& window,
+ Gtk::Widget& widget,
+ const Gdk::Rectangle& background_area,
+ const Gdk::Rectangle& ca,
+ const Gdk::Rectangle& expose_area,
+ Gtk::CellRendererState flags);
+
+ virtual bool
+ activate_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_TimeTrack
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file cellrenderer_value.cpp
+** \brief Template File
+**
+** $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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include <ETL/stringf>
+#include <gtkmm/celleditable.h>
+#include <gtkmm/editable.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/eventbox.h>
+#include <gtk/gtkentry.h> /* see XXX below */
+
+#include "app.h"
+#include "widgets/widget_value.h"
+#include "widgets/widget_vector.h"
+#include "widgets/widget_filename.h"
+#include "widgets/widget_enum.h"
+#include "widgets/widget_color.h"
+#include "widgets/widget_canvaschooser.h"
+#include "widgets/widget_time.h"
+
+#include "cellrenderer_gradient.h"
+#include "cellrenderer_value.h"
+
+#include "widgets/widget_gradient.h"
+#include "dialogs/dialog_gradient.h"
+#include "dialogs/dialog_color.h"
+#include <gtkmm/textview.h>
+
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace etl;
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#define DIGITS 15
+
+/* === G L O B A L S ======================================================= */
+
+class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
+{
+ Glib::ustring path;
+ Widget_ValueBase *valuewidget;
+ bool edit_done_called;
+ Gtk::Widget *parent;
+public:
+ ValueBase_Entry():
+ Glib::ObjectBase (typeid(ValueBase_Entry)),
+ Gtk::EventBox (),
+ Gtk::CellEditable ()
+ {
+ parent=0;
+ edit_done_called=false;
+/*
+ Gtk::HBox *const hbox = new Gtk::HBox(false, 0);
+ add(*Gtk::manage(hbox));
+
+ Gtk::Entry *entry_ = new Gtk::Entry();
+ entry_->set_text("bleh");
+ hbox->pack_start(*Gtk::manage(entry_), Gtk::PACK_EXPAND_WIDGET);
+ entry_->set_has_frame(false);
+ entry_->gobj()->is_cell_renderer = true; // XXX
+
+*/
+ valuewidget=manage(new class Widget_ValueBase());
+ valuewidget->inside_cellrenderer();
+ add(*valuewidget);
+ valuewidget->show();
+
+ //set_flags(Gtk::CAN_FOCUS);
+ //set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
+
+ /*
+ set_events(//(Gdk::ALL_EVENTS_MASK)
+ ~( Gdk::EXPOSURE_MASK
+ | Gdk::ENTER_NOTIFY_MASK
+ | Gdk::LEAVE_NOTIFY_MASK
+ | Gdk::FOCUS_CHANGE_MASK
+ | Gdk::STRUCTURE_MASK
+ | Gdk::PROPERTY_CHANGE_MASK
+ | Gdk::VISIBILITY_NOTIFY_MASK
+ | Gdk::PROXIMITY_IN_MASK
+ | Gdk::PROXIMITY_OUT_MASK
+ | Gdk::SUBSTRUCTURE_MASK
+ )
+ );
+ */
+ //signal_editing_done().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
+ //signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
+
+ show_all_children();
+
+ //signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
+ }
+ ~ValueBase_Entry()
+ {
+ }
+
+ void on_editing_done()
+ {
+ hide();
+ if(parent)parent->grab_focus();
+ if(!edit_done_called)
+ {
+ edit_done_called=true;
+ Gtk::CellEditable::on_editing_done();
+ }
+ else
+ {
+ synfig::error("on_editing_done(): Called twice!");
+ }
+ }
+ void set_parent(Gtk::Widget*x) { parent=x; }
+ void on_remove_widget()
+ {
+ hide();
+ edit_done_called=true;
+ if(parent)parent->grab_focus();
+ Gtk::CellEditable::on_remove_widget();
+ }
+ void start_editing_vfunc(GdkEvent */*event*/)
+ {
+ valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
+ show();
+ //valuewidget->grab_focus();
+ //get_window()->set_focus(*valuewidget);
+ }
+ bool on_event(GdkEvent *event)
+ {
+ if(event->any.type==GDK_BUTTON_PRESS ||
+ event->any.type==GDK_2BUTTON_PRESS ||
+ event->any.type==GDK_KEY_PRESS ||
+ event->any.type==GDK_KEY_RELEASE ||
+ event->any.type==GDK_SCROLL ||
+ event->any.type==GDK_3BUTTON_PRESS)
+ return true;
+ return Gtk::EventBox::on_event(event);
+ }
+ void on_grab_focus()
+ {
+ Gtk::EventBox::on_grab_focus();
+ if(valuewidget)
+ valuewidget->grab_focus();
+ }
+ void set_path(const Glib::ustring &p)
+ {
+ path=p;
+ }
+ void set_value(const synfig::ValueBase &data)
+ {
+ if(valuewidget)
+ valuewidget->set_value(data);
+ //valuewidget->grab_focus();
+ }
+ void set_canvas(const etl::handle<synfig::Canvas> &data)
+ {
+ assert(data);
+ if(valuewidget)
+ valuewidget->set_canvas(data);
+ }
+ void set_param_desc(const synfig::ParamDesc &data)
+ {
+ if(valuewidget)
+ valuewidget->set_param_desc(data);
+ }
+
+ const synfig::ValueBase &get_value()
+ {
+ if(valuewidget)
+ return valuewidget->get_value();
+
+ warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
+ return *(new synfig::ValueBase());
+ }
+
+ const Glib::ustring &get_path()
+ {
+ return path;
+ }
+
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+bool get_paragraph(synfig::String& text)
+{
+ Gtk::Dialog dialog(
+ _("Paragraph"), // Title
+ true, // Modal
+ true // use_separator
+ );
+ Gtk::Label label(_("Enter Paragraph Text Here:"));
+ label.show();
+ dialog.get_vbox()->pack_start(label);
+
+
+ Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
+ text_buffer->set_text(text);
+
+ Gtk::TextView text_view(text_buffer);
+ text_view.show();
+ dialog.get_vbox()->pack_start(text_view);
+
+/*
+ Gtk::Entry entry;
+ entry.set_text(text);
+ entry.show();
+ entry.set_activates_default(true);
+ dialog.get_vbox()->pack_start(entry);
+*/
+
+ dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
+ dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
+ dialog.set_default_response(Gtk::RESPONSE_OK);
+
+ //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
+
+ dialog.show();
+
+ if(dialog.run()!=Gtk::RESPONSE_OK)
+ return false;
+
+ text=text_buffer->get_text();
+
+ return true;
+}
+
+/* === M E T H O D S ======================================================= */
+
+CellRenderer_ValueBase::CellRenderer_ValueBase():
+ Glib::ObjectBase (typeid(CellRenderer_ValueBase)),
+ Gtk::CellRendererText (),
+ property_value_ (*this,"value",synfig::ValueBase()),
+ property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
+ property_param_desc_(*this,"param_desc",synfig::ParamDesc())
+{
+ CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
+ value_entry=new ValueBase_Entry();
+ value_entry->hide();
+
+ Pango::AttrList attr_list;
+ {
+ Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
+ pango_size.set_start_index(0);
+ pango_size.set_end_index(64);
+ attr_list.change(pango_size);
+ }
+ property_attributes()=attr_list;
+
+ property_foreground()=Glib::ustring("#7f7f7f");
+ property_inconsistent()=false;
+}
+
+CellRenderer_ValueBase::~CellRenderer_ValueBase()
+{
+ if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+ synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
+}
+
+void
+CellRenderer_ValueBase::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
+{
+ ValueBase old_value=property_value_.get_value();
+ ValueBase value;
+
+ if(old_value.get_type()==ValueBase::TYPE_TIME)
+ {
+ value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
+ }
+ else
+ value=ValueBase((String)str);
+
+ if(old_value!=value)
+ signal_edited_(path,value);
+}
+
+void
+CellRenderer_ValueBase::render_vfunc(
+ const Glib::RefPtr<Gdk::Drawable>& window,
+ Gtk::Widget& widget,
+ const Gdk::Rectangle& background_area,
+ const Gdk::Rectangle& ca,
+ const Gdk::Rectangle& expose_area,
+ Gtk::CellRendererState flags)
+{
+ if(!window)
+ return;
+// const unsigned int cell_xpad = property_xpad();
+// const unsigned int cell_ypad = property_ypad();
+
+ //int x_offset = 0, y_offset = 0;
+// int width = ca.get_width();
+ int height = ca.get_height();
+// get_size(widget, ca, x_offset, y_offset, width, height);
+
+// width -= cell_xpad * 2;
+// height -= cell_ypad * 2;
+
+// if(width <= 0 || height <= 0)
+// return;
+
+ 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;
+
+ ValueBase data=property_value_.get_value();
+
+ switch(data.get_type())
+ {
+ case ValueBase::TYPE_REAL:
+ if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
+ {
+ Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
+ x.convert(App::distance_system,get_canvas()->rend_desc());
+ property_text()=(Glib::ustring)x.get_string(6).c_str();
+ }
+ else
+ property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
+ break;
+ case ValueBase::TYPE_TIME:
+ property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
+ break;
+ case ValueBase::TYPE_ANGLE:
+ property_text()=(Glib::ustring)strprintf("%.2f DEG",(Real)Angle::deg(data.get(Angle())).get());
+ break;
+ case ValueBase::TYPE_INTEGER:
+ if(((synfig::ParamDesc)property_param_desc_).get_hint()!="enum")
+ {
+ property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
+ }
+ else
+ {
+ property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
+ std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
+ std::list<synfig::ParamDesc::EnumData>::iterator iter;
+
+ for(iter=enum_list.begin();iter!=enum_list.end();iter++)
+ if(iter->value==data.get(int()))
+ {
+ // don't show the key_board s_hortcut under_scores
+ String local_name = iter->local_name;
+ String::size_type pos = local_name.find_first_of('_');
+ if (pos != String::npos)
+ property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
+ else
+ property_text() = local_name;
+ break;
+ }
+ }
+
+ break;
+ case ValueBase::TYPE_VECTOR:
+ {
+ Vector vector=data.get(Vector());
+ Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
+ x.convert(App::distance_system,get_canvas()->rend_desc());
+ y.convert(App::distance_system,get_canvas()->rend_desc());
+ property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
+ }
+ break;
+
+ case ValueBase::TYPE_STRING:
+
+ if(data.get_type()==ValueBase::TYPE_STRING)
+ {
+ if(!data.get(synfig::String()).empty())
+ property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
+ else
+ property_text()=Glib::ustring("<empty>");
+ }
+ break;
+ case ValueBase::TYPE_CANVAS:
+ if(data.get(etl::handle<synfig::Canvas>()))
+ {
+ if(data.get(etl::handle<synfig::Canvas>())->is_inline())
+ property_text()=_("<Inline Canvas>");
+ else
+ property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
+ }
+ else
+ property_text()="<No Image Selected>";
+ break;
+ case ValueBase::TYPE_COLOR:
+ {
+ render_color_to_window(window,ca,data.get(Color()));
+ return;
+ }
+ break;
+ case ValueBase::TYPE_BOOL:
+ {
+ widget.get_style()->paint_check(
+ Glib::RefPtr<Gdk::Window>::cast_static(window), state,
+ data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
+ ca, widget, "cellcheck",
+ ca.get_x()/* + x_offset + cell_xpad*/,
+ ca.get_y()/* + y_offset + cell_ypad*/,
+ height-1,height-1);
+ return;
+ }
+ break;
+ case ValueBase::TYPE_NIL:
+ //property_text()=(Glib::ustring)" ";
+ return;
+ break;
+ case ValueBase::TYPE_SEGMENT:
+ property_text()=(Glib::ustring)_("Segment");
+ break;
+ case ValueBase::TYPE_GRADIENT:
+ render_gradient_to_window(window,ca,data.get(Gradient()));
+ return;
+ break;
+ case ValueBase::TYPE_LIST:
+ property_text()=(Glib::ustring)_("List");
+ break;
+ case ValueBase::TYPE_BLINEPOINT:
+ property_text()=(Glib::ustring)_("BLine Point");
+ break;
+ default:
+ property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
+ break;
+ }
+ CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
+}
+
+
+/*
+bool
+CellRenderer_ValueBase::activate_vfunc( GdkEvent* event,
+ Gtk::Widget& widget,
+ const Glib::ustring& path,
+ const Gdk::Rectangle& background_area,
+ const Gdk::Rectangle& cell_area,
+ Gtk::CellRendererState flags)
+{
+ ValueBase data=(ValueBase)property_value_.get_value();
+
+ switch(data.type)
+ {
+ case ValueBase::TYPE_BOOL:
+ if(property_editable())
+ signal_edited_(path,ValueBase(!data.get(bool())));
+ return true;
+ case ValueBase::TYPE_STRING:
+ return CellRendererText::activate_vfunc(event,widget,path,background_area,cell_area,flags);
+ }
+ return false;
+}
+*/
+
+void
+CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring path)
+{
+ ValueBase old_value(property_value_.get_value());
+ ValueBase value(gradient);
+ if(old_value!=value)
+ signal_edited_(path,value);
+}
+
+void
+CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
+{
+ ValueBase old_value(property_value_.get_value());
+ ValueBase value(color);
+ if(old_value!=value)
+ signal_edited_(path,value);
+}
+
+Gtk::CellEditable*
+CellRenderer_ValueBase::start_editing_vfunc(
+ GdkEvent* event __attribute__ ((unused)),
+ Gtk::Widget& widget,
+ const Glib::ustring& path,
+ const Gdk::Rectangle& background_area __attribute__ ((unused)),
+ const Gdk::Rectangle& cell_area __attribute__ ((unused)),
+ Gtk::CellRendererState flags __attribute__ ((unused)))
+{
+ edit_value_done_called = false;
+ // If we aren't editable, then there is nothing to do
+ if(!property_editable())
+ return 0;
+
+ ValueBase data=property_value_.get_value();
+
+ switch(data.get_type())
+ {
+ case ValueBase::TYPE_BOOL:
+ signal_edited_(path,ValueBase(!data.get(bool())));
+ return NULL;
+ //case ValueBase::TYPE_TIME:
+ // property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
+ // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+
+ case ValueBase::TYPE_GRADIENT:
+ App::dialog_gradient->reset();
+ App::dialog_gradient->set_gradient(data.get(Gradient()));
+ App::dialog_gradient->signal_edited().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::gradient_edited),
+ path
+ )
+ );
+ App::dialog_gradient->set_default_button_set_sensitive(true);
+ App::dialog_gradient->present();
+
+ return NULL;
+
+ case ValueBase::TYPE_COLOR:
+ App::dialog_color->reset();
+ App::dialog_color->set_color(data.get(Color()));
+ App::dialog_color->signal_edited().connect(
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::color_edited),
+ path
+ )
+ );
+ App::dialog_color->present();
+
+ return NULL;
+ case ValueBase::TYPE_STRING:
+ if(get_param_desc().get_hint()=="paragraph")
+ {
+ synfig::String string;
+ string=data.get(string);
+ if(get_paragraph(string))
+ signal_edited_(path,ValueBase(string));
+ return NULL;
+ }
+ // if(get_param_desc().get_hint()!="filename")
+ // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+ default:
+ {
+ assert(get_canvas());
+ //delete value_entry;
+ value_entry=manage(new ValueBase_Entry());
+ value_entry->set_path(path);
+ value_entry->set_canvas(get_canvas());
+ value_entry->set_param_desc(get_param_desc());
+ value_entry->set_value(data);
+ value_entry->set_parent(&widget);
+ value_entry->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_ValueBase::on_value_editing_done));
+ return value_entry;
+ }
+ }
+ return NULL;
+}
+
+void
+CellRenderer_ValueBase::on_value_editing_done()
+{
+ if (edit_value_done_called)
+ {
+ synfig::error("on_value_editing_done(): Called twice!");
+ return;
+ }
+
+ edit_value_done_called = true;
+
+ if(value_entry)
+ {
+ ValueBase old_value(property_value_.get_value());
+ ValueBase value(value_entry->get_value());
+
+ if(old_value!=value)
+ signal_edited_(value_entry->get_path(),value);
+
+ //delete value_entry;
+ //value_entry=0;
+ }
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file cellrenderer_value.h
+** \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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
+#define __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/cellrenderer.h>
+#include <gtkmm/checkbutton.h>
+
+#include <gtkmm/colorselection.h>
+#include <gtkmm/optionmenu.h>
+
+//#include <synfig/synfig.h>
+#include <synfig/paramdesc.h>
+#include <synfig/value.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 Widget_Color;
+class Widget_CanvasChooser;
+class Widget_Enum;
+class Widget_Filename;
+class Widget_Vector;
+class Widget_Time;
+
+class ValueBase_Entry;
+
+class CellRenderer_ValueBase : public Gtk::CellRendererText
+{
+ sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+ sigc::signal<void, const Glib::ustring&, synfig::ValueBase> signal_edited_;
+
+ Glib::Property<synfig::ValueBase> property_value_;
+ Glib::Property<etl::handle<synfig::Canvas> > property_canvas_;
+ Glib::Property<synfig::ParamDesc> property_param_desc_;
+
+ void string_edited_(const Glib::ustring&,const Glib::ustring&);
+
+ void gradient_edited(synfig::Gradient gradient, Glib::ustring path);
+ void color_edited(synfig::Color color, Glib::ustring path);
+
+ bool edit_value_done_called;
+public:
+ sigc::signal<void, const Glib::ustring&> &signal_secondary_click()
+ {return signal_secondary_click_; }
+
+ sigc::signal<void, const Glib::ustring&, synfig::ValueBase> &signal_edited()
+ {return signal_edited_; }
+
+ Glib::PropertyProxy<synfig::ValueBase> property_value() { return property_value_.get_proxy();}
+ Glib::PropertyProxy<etl::handle<synfig::Canvas> > property_canvas() { return property_canvas_.get_proxy();}
+ Glib::PropertyProxy<synfig::ParamDesc> property_param_desc() { return property_param_desc_.get_proxy(); }
+ Glib::PropertyProxy<bool> property_inconsistent() { return property_foreground_set(); }
+
+ etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
+ synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
+
+ CellRenderer_ValueBase();
+ ~CellRenderer_ValueBase();
+
+ ValueBase_Entry *value_entry;
+
+ void on_value_editing_done();
+
+ virtual void
+ render_vfunc(
+ const Glib::RefPtr<Gdk::Drawable>& 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_ValueBase
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
+++ /dev/null
-/* === 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 <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#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<Gdk::Drawable>& 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;
-}
+++ /dev/null
-/* === 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 <gtkmm/entry.h>
-#include <gtkmm/cellrenderertext.h>
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-
-#include <synfig/gradient.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class CellRenderer_Gradient : public Gtk::CellRendererText
-{
- sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
- sigc::signal<void, const Glib::ustring&, synfig::Gradient> signal_edited_;
-
- Glib::Property<synfig::Gradient> property_gradient_;
-
-public:
- sigc::signal<void, const Glib::ustring&, synfig::Gradient> &signal_edited()
- {return signal_edited_; }
-
- Glib::PropertyProxy<synfig::Gradient> property_gradient() { return property_gradient_.get_proxy();}
-
- CellRenderer_Gradient();
- ~CellRenderer_Gradient();
-
-protected:
-
- virtual void
- render_vfunc(
- const Glib::RefPtr<Gdk::Drawable>& 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
+++ /dev/null
-/* === 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 <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#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<Gdk::Drawable>& 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
-}
+++ /dev/null
-/* === 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 <gtkmm/entry.h>
-#include <gtkmm/cellrenderertext.h>
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-
-#include <synfig/time.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class CellRenderer_Time : public Gtk::CellRendererText
-{
- sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
- sigc::signal<void, const Glib::ustring&, synfig::Time> signal_edited_;
-
- Glib::Property<synfig::Time> property_time_;
- Glib::Property<synfig::Time> property_fps_;
-
- void string_edited_(const Glib::ustring&,const Glib::ustring&);
-
- void on_value_editing_done();
-
-public:
- sigc::signal<void, const Glib::ustring&, synfig::Time> &signal_edited()
- {return signal_edited_; }
-
- Glib::PropertyProxy<synfig::Time> property_time() { return property_time_.get_proxy();}
- Glib::PropertyProxy<synfig::Time> property_fps() { return property_fps_.get_proxy();}
-
- CellRenderer_Time();
- ~CellRenderer_Time();
-
-protected:
-
- virtual void
- render_vfunc(
- const Glib::RefPtr<Gdk::Drawable>& 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
+++ /dev/null
-/* === 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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include "cellrenderer_timetrack.h"
-#include <gtk/gtk.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/combo.h>
-#include <ETL/stringf>
-#include "widgets/widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widgets/widget_time.h"
-#include "widgets/widget_timeslider.h"
-
-#include <synfigapp/canvasinterface.h>
-#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<CellRenderer_TimeTrack*>(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<ValueNode_DynamicList *>(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<Gdk::Drawable>& 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<Gdk::GC> gc(Gdk::GC::create(window));
- Glib::RefPtr<Gdk::GC> 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<synfig::ValueNode_Animated*>(base_value);
-
- synfig::ValueNode_DynamicList *parent_value_node(0);
- if(property_value_desc().get_value().parent_is_value_node())
- parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(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()<adjustment->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<Gdk::GC> 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<Time> drawredafter;
-
- Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
- for(; i != end; ++i)
- {
- //find the coordinate in the drawable space...
- Time t_orig = i->get_time();
- if(!t_orig.is_valid()) continue;
- Time t = t_orig - time_offset;
- if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;
-
- //if it found it... (might want to change comparison, and optimize
- // sel_times.find to not produce an overall nlogn solution)
-
- bool selected=false;
- //not dragging... just draw as per normal
- //if move dragging draw offset
- //if copy dragging draw both...
-
- if(valselected && sel_times.find(t_orig) != sel_times.end())
- {
- if(dragging) //skip if we're dragging because we'll render it later
- {
- if(mode & COPY_MASK) // draw both blue and red moved
- {
- drawredafter.push_back(t + diff.round(cfps));
- gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
- }else if(mode & DELETE_MASK) //it's just red...
- {
- gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
- selected=true;
- }else //move - draw the red on top of the others...
- {
- drawredafter.push_back(t + diff.round(cfps));
- continue;
- }
- }else
- {
- gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
- selected=true;
- }
- }else
- {
- gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
- }
-
- //synfig::info("Displaying time: %.3f s",(float)t);
- const int x = (int)((t-lower)*area.get_width()/(upper-lower));
-
- //should draw me a grey filled circle...
- Gdk::Rectangle area2(
- area.get_x() - area.get_height()/2 + x + 1,
- area.get_y() + 1,
- area.get_height()-2,
- area.get_height()-2
- );
- render_time_point_to_window(window,area2,*i - time_offset,selected);
-
- /*window->draw_arc(gc,true,
- area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
- area.get_height()/2, area.get_height()*3/4,
- 0, 64*360);
-
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- window->draw_arc(gc,false,
- area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
- area.get_height()/2, area.get_height()*3/4,
- 0, 64*360);
- */
- }
-
- {
- vector<Time>::iterator i = drawredafter.begin(), end = drawredafter.end();
- for(; i != end; ++i)
- {
- //find the coordinate in the drawable space...
- Time t = *i;
-
- if(!t.is_valid())
- continue;
-
- //synfig::info("Displaying time: %.3f s",(float)t);
- const int x = (int)((t-lower)*area.get_width()/(upper-lower));
-
- //should draw me a grey filled circle...
-
- Gdk::Rectangle area2(
- area.get_x() - area.get_height()/2 + x + 1,
- area.get_y() + 1,
- area.get_height()-2,
- area.get_height()-2
- );
- render_time_point_to_window(window,area2,*i,true);
-/* gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
- window->draw_arc(gc,true,
- area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
- area.get_height()/2, area.get_height()*3/4,
- 0, 64*360);
-
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- window->draw_arc(gc,false,
- area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
- area.get_height()/2, area.get_height()*3/4,
- 0, 64*360);
-*/
- }
- }
- }
- }
-
- /* THIS IS NOW HANDLED ENTIRELY BY THE TIMEPOINT SYSTEM
- // This this is an animated value node, then render the waypoints
- if(value_node)
- {
- //now render the actual waypoints
- synfig::ValueNode_Animated::WaypointList::iterator iter;
- for(
- iter=value_node->waypoint_list().begin();
- iter!=value_node->waypoint_list().end();
- iter++
- )
- {
- if(!iter->get_time().is_valid())
- continue;
- int x;
- bool selected=false;
- if(is_selected(*iter))
- {
- Time t(iter->get_time());
-
-
- if(dragging)
- t=(t+selected_time-drag_time).round(get_canvas()->rend_desc().get_frame_rate());
-
- x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(t-adjustment->get_lower()));
- shadow=Gtk::SHADOW_IN;
- selected=true;
- }
- else
- {
- x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower()));
- shadow=Gtk::SHADOW_OUT;
- selected=false;
- }
-
-
- widget.get_style()->paint_diamond(
- Glib::RefPtr<Gdk::Window>::cast_static(window),
- state,
- shadow,
- area,
- widget,
- "solid",
- area.get_x()+x-area.get_height()/4,
- area.get_y()+area.get_height()/4,
- area.get_height()/2,
- area.get_height()/2
- );
- }
- }
- */
- Gdk::Rectangle area(area_);
- // If the parent of this value node is a dynamic list, then
- // render the on and off times
- if(parent_value_node)
- {
- const int index(property_value_desc().get_value().get_index());
- const synfig::ValueNode_DynamicList::ListEntry& list_entry(parent_value_node->list[index]);
- const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(list_entry.timing_info);
- synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter,next;
-
- bool is_off(false);
- if(!activepoint_list.empty())
- is_off=!activepoint_list.front().state;
-
- int xstart(0);
-
- int x=0,prevx=0;
- for(next=activepoint_list.begin(),iter=next++;iter!=activepoint_list.end();iter=next++)
- {
- x=((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->time-adjustment->get_lower())));
- if(x<0)x=0;
- if(x>area.get_width())x=area.get_width();
-
- bool status_at_time=0;
- if(next!=activepoint_list.end())
- {
- status_at_time=!list_entry.status_at_time((iter->time+next->time)/2.0);
- }
- else
- status_at_time=!list_entry.status_at_time(Time::end());
-
- if(!is_off && status_at_time)
- {
- xstart=x;
- is_off=true;
- }
- else
- if(is_off && !status_at_time)
- {
- window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
- is_off=false;
- }
-
- /*
- if(!is_off && iter!=activepoint_list.end() && next->state==false && iter->state==false)
- {
- xstart=x;
- is_off=true;
- }
- else if(is_off && next!=activepoint_list.end() && iter->state==false && next->state==true)
- {
- window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
- is_off=false;
- }
- else if(is_off && iter!=activepoint_list.end() && iter->state==true)
- {
- window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), prevx-xstart, area.get_height());
- is_off=false;
- }
- */
-
-
-
- if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
- {
- int w(1);
- if(selected==*iter)
- w=3;
- gc->set_rgb_fg_color(activepoint_color[iter->state]);
- window->draw_rectangle(gc, true, area.get_x()+x-w/2, area.get_y(), w, area.get_height());
- }
- prevx=x;
- }
- if(is_off)
- {
- window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), area.get_width()-xstart, area.get_height());
- }
- }
-
- // Render a line that defines the current tick in time
- {
- gc->set_rgb_fg_color(curr_time_color);
-
- const int x((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(adjustment->get_value()-adjustment->get_lower())));
-
- if(adjustment->get_value()>=adjustment->get_lower() && adjustment->get_value()<adjustment->get_upper())
- window->draw_rectangle(gc, true, area.get_x()+x, area.get_y(), 1, area.get_height());
- }
-}
-
-synfig::ValueNode_Animated::WaypointList::iterator
-CellRenderer_TimeTrack::find_waypoint(const synfig::Time& /*t*/,const synfig::Time& scope)
-{
- synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
-
- Time nearest(Time::end());
-
- synfig::ValueNode_Animated::WaypointList::iterator iter,ret;
-
- if(value_node)
- {
- for(
- iter=value_node->waypoint_list().begin();
- iter!=value_node->waypoint_list().end();
- iter++
- )
- {
- Time val=abs(iter->get_time()-selected_time);
- if(val<nearest)
- {
- nearest=val;
- ret=iter;
- }
- }
-
- if(nearest!=Time::end() && nearest<scope)
- {
- return ret;
- }
- }
- throw int();
-}
-
-bool
-CellRenderer_TimeTrack::activate_vfunc(
- GdkEvent* event,
- Gtk::Widget& /*widget*/,
- const Glib::ustring& treepath,
- const Gdk::Rectangle& /*background_area*/,
- const Gdk::Rectangle& cell_area,
- Gtk::CellRendererState /*flags*/)
-{
- path=treepath;
- synfig::ValueNode_Animated::WaypointList::iterator iter;
- Time nearest=1000000000;
- Gtk::Adjustment *adjustment=get_adjustment();
-
- // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
-
- synfig::Canvas::Handle canvas(get_canvas());
-
- synfig::ValueNode_DynamicList *parent_value_node(0);
- if(property_value_desc().get_value().parent_is_value_node())
- parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
-
- Time deltatime = 0;
- Time curr_time;
- switch(event->type)
- {
- case GDK_MOTION_NOTIFY:
- curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-
- mode = NONE;
- {
- Gdk::ModifierType mod;
- Gdk::Event(event).get_state(mod);
- mode = mod;
- }
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- default:
- curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
- {
- Gdk::ModifierType mod;
- Gdk::Event(event).get_state(mod);
- mode = mod;
- }
- break;
- }
- actual_time = curr_time;
- if(canvas)
- curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
- selected_time=curr_time;
-
- Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());
-
- switch(event->type)
- {
- case GDK_BUTTON_PRESS:
- //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-
- //Deal with time point selection, but only if they aren't involved in the insanity...
- if(/*!value_node && */event->button.button == 1)
- {
- Time stime;
-
- /*! UI specification:
-
- When nothing is selected, clicking on a point in either normal mode or
- additive mode will select the time point closest to the click.
- Subtractive click will do nothing
-
- When things are already selected, clicking on a selected point does
- nothing (in both normal and add mode). Add mode clicking on an unselected
- point adds it to the set. Normal clicking on an unselected point will
- select only that one time point. Subtractive clicking on any point
- will remove it from the the set if it is included.
- */
-
- synfigapp::ValueDesc valdesc = property_value_desc().get_value();
- const Node::time_set *tset = get_times_from_vdesc(valdesc);
- const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
-
- bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
- bool selectmode = mode & SELECT_MASK;
-
- //NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
- //we want to jump to the value desc if we're not currently on it
- // but only if we want to add the point
- if(clickfound && !(sel_value == valdesc))
- {
- sel_value = valdesc;
- sel_times.clear();
- }
-
- //now that we've made sure we're selecting the correct value, deal with the already selected points
- set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
- bool found = foundi != sel_times.end();
-
- //remove all other points from our list... (only select the one we need)
- if(!selectmode && !found)
- {
- sel_times.clear();
- }
-
- if(found && selectmode) //remove a single already selected point
- {
- sel_times.erase(foundi);
- }else if(clickfound) //otherwise look at adding it
- {
- //for replace the list was cleared earlier, and for add it wasn't so it works
- sel_times.insert(stime);
- }
- }
-
- selection=false;
- try
- {
- iter=find_waypoint(selected_time,pixel_width*cell_area.get_height()/2);
- selected_waypoint=iter;
- selected=*iter;
-
- selection=true;
- }
- catch(int)
- {
- selection=false;
- selected=synfig::UniqueID::nil();
- }
-
- if((!sel_times.empty() || selection) && event->button.button==1)
- {
- dragging=true;
- drag_time=selected_time;
- actual_dragtime=actual_time;
- }
- //selected_time=iter->time;
-
- /*
- // Activepoint Selection
- if(parent_value_node)
- {
- const int index(property_value_desc().get_value().get_index());
- const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(parent_value_node->list[index].timing_info);
- synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter;
-
- for(iter=activepoint_list.begin();iter!=activepoint_list.end();++iter)
- {
- Time val=abs(iter->time-selected_time);
- if(val<nearest)
- {
- nearest=val;
- selected=*iter;
- selection=true;
- }
- }
- // Perhaps I should signal if we selected this activepoint?
- }*/
-
- if(event->button.button==3)
- {
- Time stime;
- synfigapp::ValueDesc valdesc = property_value_desc().get_value();
- const Node::time_set *tset = get_times_from_vdesc(valdesc);
- synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
-
- bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
-
- etl::handle<synfig::Node> node;
- if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
- valdesc.get_value(stime).get_type()==ValueBase::TYPE_CANVAS)
- {
- node=Canvas::Handle(valdesc.get_value(stime).get(Canvas::Handle()));
- }
- else //if(valdesc.is_value_node())
- {
- node=valdesc.get_value_node();
- }
-
- if(clickfound && node)
- signal_waypoint_clicked_cellrenderer()(node, stime, time_offset, 2);
- }
-
- break;
- case GDK_MOTION_NOTIFY:
- //if(selection && dragging)
- // selected_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
- return true;
-
- break;
- case GDK_BUTTON_RELEASE:
- {
- //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
- dragging=false;
-
- /*if(event->button.button==3 && selection)
- {
- signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
- return true;
- }
- */
-
- //Time point stuff...
- if(event->button.button == 1)
- {
- bool delmode = (mode & DELETE_MASK) && !(mode & COPY_MASK);
- deltatime = actual_time - actual_dragtime;
- if(sel_times.size() != 0 && (delmode || !deltatime.is_equal(Time(0))))
- {
- synfigapp::Action::ParamList param_list;
- param_list.add("canvas",canvas_interface()->get_canvas());
- param_list.add("canvas_interface",canvas_interface());
-
- if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
- sel_value.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
- {
- param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
- }else
- {
- param_list.add("addvaluedesc",sel_value);
- }
-
- set<Time> newset;
- std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
- for(; i != end; ++i)
- {
- param_list.add("addtime",*i);
-
- newset.insert((*i + deltatime).round(get_canvas()->rend_desc().get_frame_rate()));
- }
-
- if(!delmode)
- param_list.add("deltatime",deltatime);
- // param_list.add("time",canvas_interface()->get_time());
-
- if(mode & COPY_MASK) //copy
- {
- etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
- ->process_action("TimepointsCopy", param_list);
- }else if(delmode) //DELETE
- {
- etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
- ->process_action("TimepointsDelete", param_list);
- }else //MOVE
- {
- etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
- ->process_action("TimepointsMove", param_list);
- }
-
- //now replace all the selected with the new selected
- sel_times = newset;
- }
- }
-
-
-
- /*if(value_node && selection)
- {
- if(selected_time==drag_time && event->button.button!=3)
- signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
- else
- if(event->button.button==1)
- {
- synfig::Waypoint waypoint(*selected_waypoint);
- Time newtime((waypoint.get_time()+(selected_time-drag_time)).round(canvas->rend_desc().get_frame_rate()));
- if(waypoint.get_time()!=newtime)
- {
- waypoint.set_time(newtime);
- signal_waypoint_changed_(waypoint,value_node);
- }
- }
- }*/
-
- //if(selection)
- // selected_time=iter->time;
- //selected_time=iter->get_time();
- return true;
- }
- default:
- //std::cerr<<"unknown event type "<<event->type<<std::endl;
- return false;
- break;
- }
-
-
-
- return false;
-}
-
-
-
-// The following three functions don't get documented correctly by
-// doxygen 1.5.[23] because of a bug with any function whose name
-// begins with 'property'. Fixed in doxygen 1.5.4 apparently. See
-// http://bugzilla.gnome.org/show_bug.cgi?id=471185 .
-Glib::PropertyProxy<synfigapp::ValueDesc>
-CellRenderer_TimeTrack::property_value_desc()
-{
- return Glib::PropertyProxy<synfigapp::ValueDesc>(this,"value_desc");
-}
-
-Glib::PropertyProxy<synfig::Canvas::Handle>
-CellRenderer_TimeTrack::property_canvas()
-{
- return Glib::PropertyProxy<synfig::Canvas::Handle>(this,"canvas");
-}
-
-Glib::PropertyProxy<Gtk::Adjustment* >
-CellRenderer_TimeTrack::property_adjustment()
-{
- return Glib::PropertyProxy<Gtk::Adjustment* >(this,"adjustment");
-}
-
-void
-CellRenderer_TimeTrack::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
-{
- canvas_interface_ = h;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file cellrenderer_timetrack.h
-** \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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
-#define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/progressbar.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/scrollbar.h>
-#include <gtkmm/cellrenderer.h>
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/menu.h>
-
-
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include <synfig/valuenode_animated.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfig/string.h>
-#include <synfig/time.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 Widget_ValueBase;
-
-/*! \class CellRenderer_TimeTrack
-** \brief A cell renderer that displays the waypoints for Animated ValueNodes.
-*/
-class CellRenderer_TimeTrack :
- public Gtk::CellRenderer
-{
-
- /*
- -- ** -- P R I V A T E D A T A ---------------------------------------------
- */
-
-private:
- //! Time adjustment window
- Gtk::Adjustment adjustment_;
-
- //! Signal for when the user clicks on a waypoint
- sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> signal_waypoint_clicked_cellrenderer_;
-
- sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
-
- //! Iterator for selected waypoint. (Should this be an UniqueID instead?)
- synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
-
- synfig::UniqueID selected;
-
- //! selected information for time... (will work for way points etc...)
- //TODO: make multiple... on both time and value select...
- std::set<synfig::Time> sel_times;
- synfigapp::ValueDesc sel_value;
- synfig::Time actual_time;
- synfig::Time actual_dragtime;
- int mode;
-
- //! ???
- synfig::Time selected_time;
-
- //! The path to the current item in the tree model
- Glib::ustring path;
-
- //! ???
- bool selection;
-
- bool dragging;
-
- synfig::Time drag_time;
-
- etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
- /*
- -- ** -- P R O P E R T I E S -------------------------------------------------
- */
-
-private:
-
- //! ValueBase Desc
- Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
-
- //! Canvas
- Glib::Property<synfig::Canvas::Handle> property_canvas_;
-
- //! ??? \see adjustment_
- Glib::Property<Gtk::Adjustment* > property_adjustment_;
-
- //! \writeme
- Glib::Property<bool> property_enable_timing_info_;
-
- /*
- -- ** -- P R O P E R T Y I N T E R F A C E S -------------------------------
- */
-
-public:
-
- Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
-
- Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
-
- Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
-
- /*
- -- ** -- S I G N A L I N T E R F A C E S -----------------------------------
- */
-
-public:
-
- sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> &signal_waypoint_clicked_cellrenderer()
- {return signal_waypoint_clicked_cellrenderer_; }
-
- sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
- {return signal_waypoint_changed_; }
-
- /*
- -- ** -- P U B L I C M E T H O D S -----------------------------------------
- */
-
-public:
-
- CellRenderer_TimeTrack();
- ~CellRenderer_TimeTrack();
-
- void set_adjustment(Gtk::Adjustment &x);
- Gtk::Adjustment *get_adjustment();
- const Gtk::Adjustment *get_adjustment()const;
-
- etl::loose_handle<synfigapp::CanvasInterface> canvas_interface()const {return canvas_interface_;}
- void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
-
- synfig::Canvas::Handle get_canvas()const;
-
- bool is_selected(const synfig::Waypoint& waypoint)const;
-
- synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
-
- virtual void
- render_vfunc(
- const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& ca,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags);
-
- virtual bool
- activate_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_TimeTrack
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file cellrenderer_value.cpp
-** \brief Template File
-**
-** $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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include <ETL/stringf>
-#include <gtkmm/celleditable.h>
-#include <gtkmm/editable.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/eventbox.h>
-#include <gtk/gtkentry.h> /* see XXX below */
-
-#include "app.h"
-#include "widgets/widget_value.h"
-#include "widgets/widget_vector.h"
-#include "widgets/widget_filename.h"
-#include "widgets/widget_enum.h"
-#include "widgets/widget_color.h"
-#include "widgets/widget_canvaschooser.h"
-#include "widgets/widget_time.h"
-
-#include "cellrenderer_gradient.h"
-#include "cellrenderer_value.h"
-
-#include "widgets/widget_gradient.h"
-#include "dialogs/dialog_gradient.h"
-#include "dialogs/dialog_color.h"
-#include <gtkmm/textview.h>
-
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace etl;
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#define DIGITS 15
-
-/* === G L O B A L S ======================================================= */
-
-class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
-{
- Glib::ustring path;
- Widget_ValueBase *valuewidget;
- bool edit_done_called;
- Gtk::Widget *parent;
-public:
- ValueBase_Entry():
- Glib::ObjectBase (typeid(ValueBase_Entry)),
- Gtk::EventBox (),
- Gtk::CellEditable ()
- {
- parent=0;
- edit_done_called=false;
-/*
- Gtk::HBox *const hbox = new Gtk::HBox(false, 0);
- add(*Gtk::manage(hbox));
-
- Gtk::Entry *entry_ = new Gtk::Entry();
- entry_->set_text("bleh");
- hbox->pack_start(*Gtk::manage(entry_), Gtk::PACK_EXPAND_WIDGET);
- entry_->set_has_frame(false);
- entry_->gobj()->is_cell_renderer = true; // XXX
-
-*/
- valuewidget=manage(new class Widget_ValueBase());
- valuewidget->inside_cellrenderer();
- add(*valuewidget);
- valuewidget->show();
-
- //set_flags(Gtk::CAN_FOCUS);
- //set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
-
- /*
- set_events(//(Gdk::ALL_EVENTS_MASK)
- ~( Gdk::EXPOSURE_MASK
- | Gdk::ENTER_NOTIFY_MASK
- | Gdk::LEAVE_NOTIFY_MASK
- | Gdk::FOCUS_CHANGE_MASK
- | Gdk::STRUCTURE_MASK
- | Gdk::PROPERTY_CHANGE_MASK
- | Gdk::VISIBILITY_NOTIFY_MASK
- | Gdk::PROXIMITY_IN_MASK
- | Gdk::PROXIMITY_OUT_MASK
- | Gdk::SUBSTRUCTURE_MASK
- )
- );
- */
- //signal_editing_done().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
- //signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
-
- show_all_children();
-
- //signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
- }
- ~ValueBase_Entry()
- {
- }
-
- void on_editing_done()
- {
- hide();
- if(parent)parent->grab_focus();
- if(!edit_done_called)
- {
- edit_done_called=true;
- Gtk::CellEditable::on_editing_done();
- }
- else
- {
- synfig::error("on_editing_done(): Called twice!");
- }
- }
- void set_parent(Gtk::Widget*x) { parent=x; }
- void on_remove_widget()
- {
- hide();
- edit_done_called=true;
- if(parent)parent->grab_focus();
- Gtk::CellEditable::on_remove_widget();
- }
- void start_editing_vfunc(GdkEvent */*event*/)
- {
- valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
- show();
- //valuewidget->grab_focus();
- //get_window()->set_focus(*valuewidget);
- }
- bool on_event(GdkEvent *event)
- {
- if(event->any.type==GDK_BUTTON_PRESS ||
- event->any.type==GDK_2BUTTON_PRESS ||
- event->any.type==GDK_KEY_PRESS ||
- event->any.type==GDK_KEY_RELEASE ||
- event->any.type==GDK_SCROLL ||
- event->any.type==GDK_3BUTTON_PRESS)
- return true;
- return Gtk::EventBox::on_event(event);
- }
- void on_grab_focus()
- {
- Gtk::EventBox::on_grab_focus();
- if(valuewidget)
- valuewidget->grab_focus();
- }
- void set_path(const Glib::ustring &p)
- {
- path=p;
- }
- void set_value(const synfig::ValueBase &data)
- {
- if(valuewidget)
- valuewidget->set_value(data);
- //valuewidget->grab_focus();
- }
- void set_canvas(const etl::handle<synfig::Canvas> &data)
- {
- assert(data);
- if(valuewidget)
- valuewidget->set_canvas(data);
- }
- void set_param_desc(const synfig::ParamDesc &data)
- {
- if(valuewidget)
- valuewidget->set_param_desc(data);
- }
-
- const synfig::ValueBase &get_value()
- {
- if(valuewidget)
- return valuewidget->get_value();
-
- warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
- return *(new synfig::ValueBase());
- }
-
- const Glib::ustring &get_path()
- {
- return path;
- }
-
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-bool get_paragraph(synfig::String& text)
-{
- Gtk::Dialog dialog(
- _("Paragraph"), // Title
- true, // Modal
- true // use_separator
- );
- Gtk::Label label(_("Enter Paragraph Text Here:"));
- label.show();
- dialog.get_vbox()->pack_start(label);
-
-
- Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
- text_buffer->set_text(text);
-
- Gtk::TextView text_view(text_buffer);
- text_view.show();
- dialog.get_vbox()->pack_start(text_view);
-
-/*
- Gtk::Entry entry;
- entry.set_text(text);
- entry.show();
- entry.set_activates_default(true);
- dialog.get_vbox()->pack_start(entry);
-*/
-
- dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
- dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
- dialog.set_default_response(Gtk::RESPONSE_OK);
-
- //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-
- dialog.show();
-
- if(dialog.run()!=Gtk::RESPONSE_OK)
- return false;
-
- text=text_buffer->get_text();
-
- return true;
-}
-
-/* === M E T H O D S ======================================================= */
-
-CellRenderer_ValueBase::CellRenderer_ValueBase():
- Glib::ObjectBase (typeid(CellRenderer_ValueBase)),
- Gtk::CellRendererText (),
- property_value_ (*this,"value",synfig::ValueBase()),
- property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
- property_param_desc_(*this,"param_desc",synfig::ParamDesc())
-{
- CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
- value_entry=new ValueBase_Entry();
- value_entry->hide();
-
- Pango::AttrList attr_list;
- {
- Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
- pango_size.set_start_index(0);
- pango_size.set_end_index(64);
- attr_list.change(pango_size);
- }
- property_attributes()=attr_list;
-
- property_foreground()=Glib::ustring("#7f7f7f");
- property_inconsistent()=false;
-}
-
-CellRenderer_ValueBase::~CellRenderer_ValueBase()
-{
- if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
- synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
-}
-
-void
-CellRenderer_ValueBase::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
-{
- ValueBase old_value=property_value_.get_value();
- ValueBase value;
-
- if(old_value.get_type()==ValueBase::TYPE_TIME)
- {
- value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
- }
- else
- value=ValueBase((String)str);
-
- if(old_value!=value)
- signal_edited_(path,value);
-}
-
-void
-CellRenderer_ValueBase::render_vfunc(
- const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& ca,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags)
-{
- if(!window)
- return;
-// const unsigned int cell_xpad = property_xpad();
-// const unsigned int cell_ypad = property_ypad();
-
- //int x_offset = 0, y_offset = 0;
-// int width = ca.get_width();
- int height = ca.get_height();
-// get_size(widget, ca, x_offset, y_offset, width, height);
-
-// width -= cell_xpad * 2;
-// height -= cell_ypad * 2;
-
-// if(width <= 0 || height <= 0)
-// return;
-
- 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;
-
- ValueBase data=property_value_.get_value();
-
- switch(data.get_type())
- {
- case ValueBase::TYPE_REAL:
- if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
- {
- Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
- x.convert(App::distance_system,get_canvas()->rend_desc());
- property_text()=(Glib::ustring)x.get_string(6).c_str();
- }
- else
- property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
- break;
- case ValueBase::TYPE_TIME:
- property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
- break;
- case ValueBase::TYPE_ANGLE:
- property_text()=(Glib::ustring)strprintf("%.2f DEG",(Real)Angle::deg(data.get(Angle())).get());
- break;
- case ValueBase::TYPE_INTEGER:
- if(((synfig::ParamDesc)property_param_desc_).get_hint()!="enum")
- {
- property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
- }
- else
- {
- property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
- std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
- std::list<synfig::ParamDesc::EnumData>::iterator iter;
-
- for(iter=enum_list.begin();iter!=enum_list.end();iter++)
- if(iter->value==data.get(int()))
- {
- // don't show the key_board s_hortcut under_scores
- String local_name = iter->local_name;
- String::size_type pos = local_name.find_first_of('_');
- if (pos != String::npos)
- property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
- else
- property_text() = local_name;
- break;
- }
- }
-
- break;
- case ValueBase::TYPE_VECTOR:
- {
- Vector vector=data.get(Vector());
- Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
- x.convert(App::distance_system,get_canvas()->rend_desc());
- y.convert(App::distance_system,get_canvas()->rend_desc());
- property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
- }
- break;
-
- case ValueBase::TYPE_STRING:
-
- if(data.get_type()==ValueBase::TYPE_STRING)
- {
- if(!data.get(synfig::String()).empty())
- property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
- else
- property_text()=Glib::ustring("<empty>");
- }
- break;
- case ValueBase::TYPE_CANVAS:
- if(data.get(etl::handle<synfig::Canvas>()))
- {
- if(data.get(etl::handle<synfig::Canvas>())->is_inline())
- property_text()=_("<Inline Canvas>");
- else
- property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
- }
- else
- property_text()="<No Image Selected>";
- break;
- case ValueBase::TYPE_COLOR:
- {
- render_color_to_window(window,ca,data.get(Color()));
- return;
- }
- break;
- case ValueBase::TYPE_BOOL:
- {
- widget.get_style()->paint_check(
- Glib::RefPtr<Gdk::Window>::cast_static(window), state,
- data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
- ca, widget, "cellcheck",
- ca.get_x()/* + x_offset + cell_xpad*/,
- ca.get_y()/* + y_offset + cell_ypad*/,
- height-1,height-1);
- return;
- }
- break;
- case ValueBase::TYPE_NIL:
- //property_text()=(Glib::ustring)" ";
- return;
- break;
- case ValueBase::TYPE_SEGMENT:
- property_text()=(Glib::ustring)_("Segment");
- break;
- case ValueBase::TYPE_GRADIENT:
- render_gradient_to_window(window,ca,data.get(Gradient()));
- return;
- break;
- case ValueBase::TYPE_LIST:
- property_text()=(Glib::ustring)_("List");
- break;
- case ValueBase::TYPE_BLINEPOINT:
- property_text()=(Glib::ustring)_("BLine Point");
- break;
- default:
- property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
- break;
- }
- CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
-}
-
-
-/*
-bool
-CellRenderer_ValueBase::activate_vfunc( GdkEvent* event,
- Gtk::Widget& widget,
- const Glib::ustring& path,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- Gtk::CellRendererState flags)
-{
- ValueBase data=(ValueBase)property_value_.get_value();
-
- switch(data.type)
- {
- case ValueBase::TYPE_BOOL:
- if(property_editable())
- signal_edited_(path,ValueBase(!data.get(bool())));
- return true;
- case ValueBase::TYPE_STRING:
- return CellRendererText::activate_vfunc(event,widget,path,background_area,cell_area,flags);
- }
- return false;
-}
-*/
-
-void
-CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring path)
-{
- ValueBase old_value(property_value_.get_value());
- ValueBase value(gradient);
- if(old_value!=value)
- signal_edited_(path,value);
-}
-
-void
-CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
-{
- ValueBase old_value(property_value_.get_value());
- ValueBase value(color);
- if(old_value!=value)
- signal_edited_(path,value);
-}
-
-Gtk::CellEditable*
-CellRenderer_ValueBase::start_editing_vfunc(
- GdkEvent* event __attribute__ ((unused)),
- Gtk::Widget& widget,
- const Glib::ustring& path,
- const Gdk::Rectangle& background_area __attribute__ ((unused)),
- const Gdk::Rectangle& cell_area __attribute__ ((unused)),
- Gtk::CellRendererState flags __attribute__ ((unused)))
-{
- edit_value_done_called = false;
- // If we aren't editable, then there is nothing to do
- if(!property_editable())
- return 0;
-
- ValueBase data=property_value_.get_value();
-
- switch(data.get_type())
- {
- case ValueBase::TYPE_BOOL:
- signal_edited_(path,ValueBase(!data.get(bool())));
- return NULL;
- //case ValueBase::TYPE_TIME:
- // property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
- // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-
- case ValueBase::TYPE_GRADIENT:
- App::dialog_gradient->reset();
- App::dialog_gradient->set_gradient(data.get(Gradient()));
- App::dialog_gradient->signal_edited().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::gradient_edited),
- path
- )
- );
- App::dialog_gradient->set_default_button_set_sensitive(true);
- App::dialog_gradient->present();
-
- return NULL;
-
- case ValueBase::TYPE_COLOR:
- App::dialog_color->reset();
- App::dialog_color->set_color(data.get(Color()));
- App::dialog_color->signal_edited().connect(
- sigc::bind(
- sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::color_edited),
- path
- )
- );
- App::dialog_color->present();
-
- return NULL;
- case ValueBase::TYPE_STRING:
- if(get_param_desc().get_hint()=="paragraph")
- {
- synfig::String string;
- string=data.get(string);
- if(get_paragraph(string))
- signal_edited_(path,ValueBase(string));
- return NULL;
- }
- // if(get_param_desc().get_hint()!="filename")
- // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
- default:
- {
- assert(get_canvas());
- //delete value_entry;
- value_entry=manage(new ValueBase_Entry());
- value_entry->set_path(path);
- value_entry->set_canvas(get_canvas());
- value_entry->set_param_desc(get_param_desc());
- value_entry->set_value(data);
- value_entry->set_parent(&widget);
- value_entry->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_ValueBase::on_value_editing_done));
- return value_entry;
- }
- }
- return NULL;
-}
-
-void
-CellRenderer_ValueBase::on_value_editing_done()
-{
- if (edit_value_done_called)
- {
- synfig::error("on_value_editing_done(): Called twice!");
- return;
- }
-
- edit_value_done_called = true;
-
- if(value_entry)
- {
- ValueBase old_value(property_value_.get_value());
- ValueBase value(value_entry->get_value());
-
- if(old_value!=value)
- signal_edited_(value_entry->get_path(),value);
-
- //delete value_entry;
- //value_entry=0;
- }
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file cellrenderer_value.h
-** \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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
-#define __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/cellrenderer.h>
-#include <gtkmm/checkbutton.h>
-
-#include <gtkmm/colorselection.h>
-#include <gtkmm/optionmenu.h>
-
-//#include <synfig/synfig.h>
-#include <synfig/paramdesc.h>
-#include <synfig/value.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 Widget_Color;
-class Widget_CanvasChooser;
-class Widget_Enum;
-class Widget_Filename;
-class Widget_Vector;
-class Widget_Time;
-
-class ValueBase_Entry;
-
-class CellRenderer_ValueBase : public Gtk::CellRendererText
-{
- sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
- sigc::signal<void, const Glib::ustring&, synfig::ValueBase> signal_edited_;
-
- Glib::Property<synfig::ValueBase> property_value_;
- Glib::Property<etl::handle<synfig::Canvas> > property_canvas_;
- Glib::Property<synfig::ParamDesc> property_param_desc_;
-
- void string_edited_(const Glib::ustring&,const Glib::ustring&);
-
- void gradient_edited(synfig::Gradient gradient, Glib::ustring path);
- void color_edited(synfig::Color color, Glib::ustring path);
-
- bool edit_value_done_called;
-public:
- sigc::signal<void, const Glib::ustring&> &signal_secondary_click()
- {return signal_secondary_click_; }
-
- sigc::signal<void, const Glib::ustring&, synfig::ValueBase> &signal_edited()
- {return signal_edited_; }
-
- Glib::PropertyProxy<synfig::ValueBase> property_value() { return property_value_.get_proxy();}
- Glib::PropertyProxy<etl::handle<synfig::Canvas> > property_canvas() { return property_canvas_.get_proxy();}
- Glib::PropertyProxy<synfig::ParamDesc> property_param_desc() { return property_param_desc_.get_proxy(); }
- Glib::PropertyProxy<bool> property_inconsistent() { return property_foreground_set(); }
-
- etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
- synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
-
- CellRenderer_ValueBase();
- ~CellRenderer_ValueBase();
-
- ValueBase_Entry *value_entry;
-
- void on_value_editing_done();
-
- virtual void
- render_vfunc(
- const Glib::RefPtr<Gdk::Drawable>& 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_ValueBase
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
#include <synfig/valuenode_animated.h>
#include <gtkmm/button.h>
#include <synfigapp/instance.h>
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
+#include "cellrenderer/cellrenderer_value.h"
+#include "cellrenderer/cellrenderer_timetrack.h"
#include <ETL/clock>
#include "general.h"
#endif
#include "trees/childrentree.h"
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
+#include "cellrenderer/cellrenderer_value.h"
+#include "cellrenderer/cellrenderer_timetrack.h"
#include <synfigapp/action.h>
#include <synfigapp/instance.h>
#include <gtkmm/scrolledwindow.h>
{
children_tree_store_=children_tree_store;
tree_view.set_model(children_tree_store_);
- cellrenderer_time_track->set_canvas_interface(children_tree_store_->canvas_interface()); // am I smart people? (cellrenderer_timetrack.h:176)
+ cellrenderer_time_track->set_canvas_interface(children_tree_store_->canvas_interface()); // am I smart people? (cellrenderer/cellrenderer_timetrack.h:176)
children_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::ChildrenTree::on_dirty_preview));
}
#endif
#include "trees/keyframetree.h"
-#include "cellrenderer_time.h"
+#include "cellrenderer/cellrenderer_time.h"
#include <gtkmm/treemodelsort.h>
#include <ETL/misc>
#include "layertree.h"
#include "layerparamtreestore.h"
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
+#include "cellrenderer/cellrenderer_value.h"
+#include "cellrenderer/cellrenderer_timetrack.h"
#include <synfigapp/action.h>
#include <synfigapp/instance.h>
#include <gtkmm/scrolledwindow.h>
//#include <gtkmm/treestore.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
-//#include <gtkmm/cellrenderer.h>
+//#include <gtkmm/cellrenderer/cellrenderer.h>
#include <gtkmm/checkbutton.h>
//#include <gtkmm/colorselection.h>