WIDGET_HH = \
- widget_canvaschooser.h \
- widget_color.h \
- widget_coloredit.h \
- widget_compselect.h \
- widget_curves.h \
- widget_defaults.h \
- widget_distance.h \
- widget_enum.h \
- widget_filename.h \
- widget_gradient.h \
- widget_sound.h \
- widget_time.h \
- widget_timeslider.h \
- widget_value.h \
- widget_vector.h \
- widget_waypoint.h \
- widget_waypointmodel.h \
- widget_keyframe_list.h
+ widgets/widget_canvaschooser.h \
+ widgets/widget_color.h \
+ widgets/widget_coloredit.h \
+ widgets/widget_compselect.h \
+ widgets/widget_curves.h \
+ widgets/widget_defaults.h \
+ widgets/widget_distance.h \
+ widgets/widget_enum.h \
+ widgets/widget_filename.h \
+ widgets/widget_gradient.h \
+ widgets/widget_sound.h \
+ widgets/widget_time.h \
+ widgets/widget_timeslider.h \
+ widgets/widget_value.h \
+ widgets/widget_vector.h \
+ widgets/widget_waypoint.h \
+ widgets/widget_waypointmodel.h \
+ widgets/widget_keyframe_list.h
WIDGET_CC = \
- widget_canvaschooser.cpp \
- widget_color.cpp \
- widget_coloredit.cpp \
- widget_compselect.cpp \
- widget_curves.cpp \
- widget_defaults.cpp \
- widget_distance.cpp \
- widget_enum.cpp \
- widget_filename.cpp \
- widget_gradient.cpp \
- widget_sound.cpp \
- widget_time.cpp \
- widget_timeslider.cpp \
- widget_value.cpp \
- widget_vector.cpp \
- widget_waypoint.cpp \
- widget_waypointmodel.cpp \
- widget_keyframe_list.cpp
+ widgets/widget_canvaschooser.cpp \
+ widgets/widget_color.cpp \
+ widgets/widget_coloredit.cpp \
+ widgets/widget_compselect.cpp \
+ widgets/widget_curves.cpp \
+ widgets/widget_defaults.cpp \
+ widgets/widget_distance.cpp \
+ widgets/widget_enum.cpp \
+ widgets/widget_filename.cpp \
+ widgets/widget_gradient.cpp \
+ widgets/widget_sound.cpp \
+ widgets/widget_time.cpp \
+ widgets/widget_timeslider.cpp \
+ widgets/widget_value.cpp \
+ widgets/widget_vector.cpp \
+ widgets/widget_waypoint.cpp \
+ widgets/widget_waypointmodel.cpp \
+ widgets/widget_keyframe_list.cpp
STATE_HH = \
#include "devicetracker.h"
#include "dialog_tooloptions.h"
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include "autorecover.h"
#include "preview.h"
#include "audiocontainer.h"
-#include "widget_timeslider.h"
+#include "widgets/widget_timeslider.h"
#include "keyframedial.h"
#include <synfigapp/main.h>
#include "framedial.h"
#include "toggleducksdial.h"
#include "resolutiondial.h"
-#include "widget_keyframe_list.h"
+#include "widgets/widget_keyframe_list.h"
#include "duckmatic.h"
#include <gtkmm/scale.h>
#include <gtkmm/entry.h>
#include <gtkmm/button.h>
#include "cellrenderer_gradient.h"
-#include "widget_gradient.h"
+#include "widgets/widget_gradient.h"
#include "app.h"
#include "general.h"
#include <gtkmm/button.h>
#include "cellrenderer_time.h"
#include "app.h"
-#include "widget_time.h"
+#include "widgets/widget_time.h"
#include "general.h"
#include <gtkmm/spinbutton.h>
#include <gtkmm/combo.h>
#include <ETL/stringf>
-#include "widget_value.h"
+#include "widgets/widget_value.h"
#include "app.h"
#include <gtkmm/menu.h>
#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_timeslider.h"
+#include "widgets/widget_time.h"
+#include "widgets/widget_timeslider.h"
#include <synfigapp/canvasinterface.h>
#include "instance.h"
#include <gtk/gtkentry.h> /* see XXX below */
#include "app.h"
-#include "widget_value.h"
-#include "widget_vector.h"
-#include "widget_filename.h"
-#include "widget_enum.h"
-#include "widget_color.h"
-#include "widget_canvaschooser.h"
-#include "widget_time.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 "widget_gradient.h"
+#include "widgets/widget_gradient.h"
#include "dialogs/dialog_gradient.h"
#include "dialogs/dialog_color.h"
#include <gtkmm/textview.h>
#include "childrentreestore.h"
#include <synfig/valuenode_animated.h>
-#include "widget_value.h"
+#include "widgets/widget_value.h"
/* === M A C R O S ========================================================= */
#include <gtkmm/table.h>
#include <gtkmm/entry.h>
#include <gtkmm/tooltips.h>
-#include "widget_value.h"
-#include "widget_vector.h"
+#include "widgets/widget_value.h"
+#include "widgets/widget_vector.h"
/* === M A C R O S ========================================================= */
#endif
#include "dialogs/dialog_color.h"
-#include "widget_color.h"
+#include "widgets/widget_color.h"
#include <synfig/general.h>
#include <synfigapp/main.h>
#include <gtkmm/button.h>
#include <gtkmm/tooltips.h>
#include <sigc++/functors/slot.h>
-#include "widget_coloredit.h"
+#include "widgets/widget_coloredit.h"
#include "dialogsettings.h"
/* === M A C R O S ========================================================= */
#endif
#include "dialogs/dialog_gradient.h"
-#include "widget_gradient.h"
+#include "widgets/widget_gradient.h"
#include <gtkmm/frame.h>
#include <gtkmm/table.h>
#include <gtkmm/label.h>
#include <synfigapp/canvasinterface.h>
#include <synfigapp/value_desc.h>
#include <synfigapp/main.h>
-#include "widget_color.h"
+#include "widgets/widget_color.h"
#include <gtkmm/spinbutton.h>
#include "app.h"
#include <synfig/gamma.h>
#include <synfig/time.h>
-#include "widget_gradient.h"
-#include "widget_coloredit.h"
+#include "widgets/widget_gradient.h"
+#include "widgets/widget_coloredit.h"
#include <synfigapp/value_desc.h>
#include <synfig/time.h>
#include "dialogs/dialog_keyframe.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/button.h>
-#include "widget_waypointmodel.h"
+#include "widgets/widget_waypointmodel.h"
#include <synfigapp/action.h>
#include <synfigapp/instance.h>
#include <gui/dialogsettings.h>
#include "preview.h"
-#include <gui/widget_time.h>
+#include <gui/widgets/widget_time.h>
/* === M A C R O S ========================================================= */
#include <gtkmm/table.h>
#include <gtkmm/frame.h>
#include <gtkmm/notebook.h>
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include "autorecover.h"
#include <ETL/stringf>
#include <gtkmm/drawingarea.h>
#include <gtkmm/optionmenu.h>
#include <gtkmm/checkbutton.h>
-#include <gui/widget_time.h>
+#include <gui/widgets/widget_time.h>
#include <gtkmm/tooltips.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/spinbutton.h>
/* === H E A D E R S ======================================================= */
#include "dockdialog.h"
-#include "widget_filename.h"
-#include "widget_time.h"
+#include "widgets/widget_filename.h"
+#include "widgets/widget_time.h"
#include <synfigapp/canvasinterface.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/combo.h>
#include <ETL/stringf>
-#include "widget_value.h"
+#include "widgets/widget_value.h"
#include "app.h"
#include <gtkmm/menu.h>
#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypoint.h"
+#include "widgets/widget_time.h"
+#include "widgets/widget_waypoint.h"
#include "general.h"
#include "canvasview.h"
#include "layerparamtreestore.h"
#include "workarea.h"
-#include "widget_curves.h"
+#include "widgets/widget_curves.h"
#include "layerparamtreestore.h"
#include <gtkmm/table.h>
#include <gtkmm/scrollbar.h>
-#include "widget_timeslider.h"
+#include "widgets/widget_timeslider.h"
#include "general.h"
#include "dock_canvasspecific.h"
#include "sigc++/signal.h"
-#include "widget_distance.h"
+#include "widgets/widget_distance.h"
/* === M A C R O S ========================================================= */
#include "canvasview.h"
#include "dock_canvasspecific.h"
-#include "widget_distance.h"
+#include "widgets/widget_distance.h"
#include <ETL/smart_ptr>
#include "canvasview.h"
#include "layerparamtreestore.h"
#include "workarea.h"
-#include "widget_timeslider.h"
-#include "widget_keyframe_list.h"
+#include "widgets/widget_timeslider.h"
+#include "widgets/widget_keyframe_list.h"
#include "layerparamtreestore.h"
#include "general.h"
#include <synfig/timepointcollect.h>
#include "dockbook.h"
#include "dockmanager.h"
#include "toolbox.h"
-#include "widget_compselect.h"
+#include "widgets/widget_compselect.h"
#include <synfig/general.h>
#include <synfig/uniqueid.h>
#include <gtkmm/table.h>
//#include <sigc++/hide.h>
#include <synfig/valuenode_composite.h>
#include <synfig/valuenode_duplicate.h>
-#include "widget_waypointmodel.h"
+#include "widgets/widget_waypointmodel.h"
#include <gtkmm/actiongroup.h>
#include "iconcontroller.h"
#include "workarea.h"
#include "layerparamtreestore.h"
#include <synfig/valuenode_animated.h>
-#include "widget_value.h"
+#include "widgets/widget_value.h"
/* === M A C R O S ========================================================= */
#endif
#include "dock_paledit.h"
-#include "../../widget_color.h"
+#include "../../widgets/widget_color.h"
#include <gtkmm/frame.h>
#include <gtkmm/table.h>
#include <gtkmm/label.h>
#include <synfig/general.h>
#include <synfigapp/canvasinterface.h>
#include <synfigapp/value_desc.h>
-#include "../../widget_color.h"
+#include "../../widgets/widget_color.h"
#include <gtkmm/spinbutton.h>
#include <gtkmm/menu.h>
#include <synfigapp/main.h>
#include <synfig/gamma.h>
#include <synfig/time.h>
-#include "../../widget_coloredit.h"
+#include "../../widgets/widget_coloredit.h"
#include <synfigapp/value_desc.h>
#include <synfig/time.h>
#include <synfig/renddesc.h>
#include <synfig/canvas.h>
-#include "widget_sound.h"
+#include "widgets/widget_sound.h"
#include <vector>
#include <gtkmm/adjustment.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/notebook.h>
-#include "widget_vector.h"
-#include "widget_time.h"
+#include "widgets/widget_vector.h"
+#include "widgets/widget_time.h"
/* === M A C R O S ========================================================= */
#include "duckmatic.h"
#include <ETL/bezier>
#include <ETL/misc>
-#include "widget_color.h"
+#include "widgets/widget_color.h"
#include <synfig/distance.h>
#include "app.h"
#include "dialog_tooloptions.h"
#include <gtkmm/optionmenu.h>
#include "duck.h"
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include <synfigapp/main.h>
#include "general.h"
#include <gtkmm/optionmenu.h>
#include "duck.h"
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include <synfigapp/main.h>
#include "general.h"
#include "dialog_tooloptions.h"
#include <gtkmm/optionmenu.h>
#include "duck.h"
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include <synfigapp/main.h>
#include "general.h"
#include "dialog_tooloptions.h"
#include <gtkmm/optionmenu.h>
#include "duck.h"
-#include "widget_enum.h"
+#include "widgets/widget_enum.h"
#include <synfigapp/main.h>
#include "general.h"
#include "dockmanager.h"
#include "dockdialog.h"
-#include "widget_defaults.h"
+#include "widgets/widget_defaults.h"
#include <synfigapp/main.h>
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_canvaschooser.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 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 "widget_canvaschooser.h"
-#include <gtkmm/menu.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 ======================================================= */
-
-Widget_CanvasChooser::Widget_CanvasChooser()
-{
-}
-
-Widget_CanvasChooser::~Widget_CanvasChooser()
-{
-}
-
-void
-Widget_CanvasChooser::set_parent_canvas(synfig::Canvas::Handle x)
-{
- assert(x);
- parent_canvas=x;
-}
-
-void
-Widget_CanvasChooser::set_value_(synfig::Canvas::Handle data)
-{
- set_value(data);
- activate();
-}
-
-void
-Widget_CanvasChooser::set_value(synfig::Canvas::Handle data)
-{
- assert(parent_canvas);
- canvas=data;
-
- canvas_menu=manage(new class Gtk::Menu());
-
- synfig::Canvas::Children::iterator iter;
- synfig::Canvas::Children &children(parent_canvas->children());
- String label;
-
- if(canvas)
- {
- label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
- canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
- }
-
- for(iter=children.begin();iter!=children.end();iter++)
- if(*iter!=canvas)
- {
- label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
- canvas_menu->items().push_back(
- Gtk::Menu_Helpers::MenuElem(
- label,
- sigc::bind(
- sigc::mem_fun(
- *this,
- &Widget_CanvasChooser::set_value_
- ),
- *iter
- )
- )
- );
- }
- canvas_menu->items().push_back(
- Gtk::Menu_Helpers::MenuElem(
- _("Other..."),
- sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
- )
- );
- set_menu(*canvas_menu);
-
- if(canvas)
- set_history(0);
-}
-
-const etl::handle<synfig::Canvas> &
-Widget_CanvasChooser::get_value()
-{
- return canvas;
-}
-
-void
-Widget_CanvasChooser::chooser_menu()
-{
- String canvas_name;
-
- if (!App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name))
- {
- // the user hit 'cancel', so set the parameter back to its previous value
- set_value_(canvas);
- return;
- }
-
- if (canvas_name == "")
- {
- App::dialog_error_blocking(_("Error"),_("No canvas name was specified"));
- set_value_(canvas);
- return;
- }
-
- Canvas::Handle new_canvas;
- try
- {
- String warnings;
- new_canvas=parent_canvas->find_canvas(canvas_name, warnings);
- set_value_(new_canvas);
- }
- catch(std::runtime_error x)
- {
- App::dialog_error_blocking(_("Error:Exception Thrown"),String(_("Error selecting canvas:\n\n")) + x.what());
- set_value_(canvas);
- }
- catch(...)
- {
- App::dialog_error_blocking(_("Error"),_("Unknown Exception"));
- set_value_(canvas);
- }
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_canvaschooser.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_WIDGET_CANVASCHOOSER_H
-#define __SYNFIG_STUDIO_WIDGET_CANVASCHOOSER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/canvas.h>
-#include <gtkmm/optionmenu.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 Menu; };
-
-namespace studio {
-
-class Widget_CanvasChooser : public Gtk::OptionMenu
-{
- Gtk::Menu *canvas_menu;
- synfig::Canvas::Handle parent_canvas;
-
- synfig::Canvas::Handle canvas;
- void set_value_(synfig::Canvas::Handle data);
-public:
-
- Widget_CanvasChooser();
- ~Widget_CanvasChooser();
-
- void set_parent_canvas(synfig::Canvas::Handle x);
- void set_value(synfig::Canvas::Handle data);
- const synfig::Canvas::Handle &get_value();
-private:
- void chooser_menu();
-}; // END of class Widget_CanvasChooser
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_color.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 "widget_color.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.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 ================================================= */
-
-Gdk::Color
-studio::colorconv_synfig2gdk(const synfig::Color &c_)
-{
- const synfig::Color c(c_.clamped());
- Gdk::Color ret;
- ret.set_rgb(
- 256*App::gamma.r_F32_to_U8(c.get_r()),
- 256*App::gamma.g_F32_to_U8(c.get_g()),
- 256*App::gamma.b_F32_to_U8(c.get_b())
- );
- return ret;
-}
-
-void
-studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
-{
- const int height(ca.get_height());
- const int width(ca.get_width());
-
- const int square_size(height/2);
-
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-
- if(color.get_alpha()!=1.0)
- {
- // In this case we need to render the alpha squares
-
- const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
- const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
-
- Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
- Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
-
- bool toggle(false);
- for(int i=0;i<width;i+=square_size)
- {
- const int square_width(min(square_size,width-i));
-
- if(toggle)
- {
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
- gc->set_rgb_fg_color(gdk_c2);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
- toggle=false;
- }
- else
- {
- gc->set_rgb_fg_color(gdk_c2);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
- toggle=true;
- }
- }
- }
- else
- {
- // In this case we have a solid color to use
- Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
-
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
- }
- gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
- window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
-}
-
-/* === C L A S S E S ======================================================= */
-
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Color::Widget_Color()
-{
- color=Color(0,0,0,0);
- set_size_request(-1,16);
-
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Color::redraw));
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-
-}
-
-Widget_Color::~Widget_Color()
-{
-}
-
-void
-Widget_Color::set_value(const synfig::Color &data)
-{
- assert(data.is_valid());
- color=data;
- queue_draw();
-}
-
-const synfig::Color &
-Widget_Color::get_value()
-{
- assert(color.is_valid());
- return color;
-}
-
-bool
-Widget_Color::on_event(GdkEvent *event)
-{
- switch(event->type)
- {
- case GDK_BUTTON_PRESS:
- if(event->button.button==1)
- {
- signal_activate_();
- return true;
- }
- if(event->button.button==2)
- {
- signal_middle_click_();
- return true;
- }
- if(event->button.button==3)
- {
- signal_right_click_();
- return true;
- }
- break;
-
- default:
- break;
- }
- return false;
-}
-
-bool
-Widget_Color::redraw(GdkEventExpose */*bleh*/)
-{
- //Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
- const int h(get_height());
- const int w(get_width());
-
- render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),color);
-
- return true;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_color.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_WIDGET_COLOR_H
-#define __SYNFIG_STUDIO_WIDGET_COLOR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <synfig/color.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 {
-
-
-Gdk::Color colorconv_synfig2gdk(const synfig::Color &c);
-
-void render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color);
-
-class Widget_Color : public Gtk::DrawingArea
-{
- synfig::Color color;
-
- sigc::signal<void> signal_activate_;
- sigc::signal<void> signal_middle_click_;
- sigc::signal<void> signal_right_click_;
-
-protected:
-
-public:
- sigc::signal<void>& signal_activate() { return signal_activate_; }
- sigc::signal<void>& signal_clicked() { return signal_activate_; }
- sigc::signal<void>& signal_middle_click() { return signal_middle_click_; }
- sigc::signal<void>& signal_right_click() { return signal_right_click_; }
-
- void set_value(const synfig::Color &data);
- const synfig::Color &get_value();
- Widget_Color();
- ~Widget_Color();
-private:
- bool redraw(GdkEventExpose*bleh);
- bool on_event(GdkEvent *event);
-
-}; // END of class Widget_Color
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_coloredit.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
-** Copyright (c) 2008 Paul Wise
-**
-** 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 "widget_coloredit.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.h>
-#include <pangomm/attributes.h>
-#include <pangomm/attrlist.h>
-#include <algorithm>
-#include <gtkmm/notebook.h>
-#include <gtkmm/box.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 ========================================================= */
-
-#define SPINBUTTON_WIDTH 100
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === C L A S S E S ======================================================= */
-
-ColorSlider::ColorSlider(const ColorSlider::Type &x):
- type(x)
-{
- signal_expose_event().connect(sigc::mem_fun(*this, &ColorSlider::redraw));
- set_size_request(-1,12);
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- add_events(Gdk::BUTTON1_MOTION_MASK);
-}
-
-void
-ColorSlider::set_type(Type x) { type=x; queue_draw(); }
-
-void
-ColorSlider::set_color(synfig::Color x) { color_=x; queue_draw(); }
-
-void
-ColorSlider::slider_color_TYPE_R(synfig::Color &color, float amount) { color.set_r(amount); }
-void
-ColorSlider::slider_color_TYPE_G(synfig::Color &color, float amount) { color.set_g(amount); }
-void
-ColorSlider::slider_color_TYPE_B(synfig::Color &color, float amount) { color.set_b(amount); }
-void
-ColorSlider::slider_color_TYPE_Y(synfig::Color &color, float amount) { color.set_y(amount); }
-void
-ColorSlider::slider_color_TYPE_U(synfig::Color &color, float amount) { color.set_u(amount-0.5f); }
-void
-ColorSlider::slider_color_TYPE_V(synfig::Color &color, float amount) { color.set_v(amount-0.5f); }
-void
-ColorSlider::slider_color_TYPE_HUE(synfig::Color &color, float amount) { color.set_uv_angle(Angle::rot(amount)); }
-void
-ColorSlider::slider_color_TYPE_SAT(synfig::Color &color, float amount) { color.set_s(amount*0.5f); }
-void
-ColorSlider::slider_color_TYPE_A(synfig::Color &color, float amount) { color.set_a(amount); }
-
-void
-ColorSlider::adjust_color(Type type, synfig::Color &color, float amount)
-{
- static const slider_color_func jump_table[int(TYPE_END)] =
- {
- slider_color_TYPE_R,
- slider_color_TYPE_G,
- slider_color_TYPE_B,
- slider_color_TYPE_Y,
- slider_color_TYPE_U,
- slider_color_TYPE_V,
- slider_color_TYPE_HUE,
- slider_color_TYPE_SAT,
- slider_color_TYPE_A,
- };
- jump_table[int(type)](color,amount);
-}
-
-bool
-ColorSlider::redraw(GdkEventExpose */*bleh*/)
-{
- Color color(color_);
-
- static const slider_color_func jump_table[int(TYPE_END)] =
- {
- slider_color_TYPE_R,
- slider_color_TYPE_G,
- slider_color_TYPE_B,
- slider_color_TYPE_Y,
- slider_color_TYPE_U,
- slider_color_TYPE_V,
- slider_color_TYPE_HUE,
- slider_color_TYPE_SAT,
- slider_color_TYPE_A,
- };
-
- slider_color_func color_func(jump_table[int(type)]);
-
- float amount;
- switch(type)
- {
- case TYPE_R: amount=color.get_r(); break;
- case TYPE_G: amount=color.get_g(); break;
- case TYPE_B: amount=color.get_b(); break;
- case TYPE_Y: amount=color.get_y(); break;
- case TYPE_U: amount=color.get_u()+0.5; break;
- case TYPE_V: amount=color.get_v()+0.5; break;
- case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
- case TYPE_SAT: amount=color.get_s()*2.0; break;
- case TYPE_A: amount=color.get_a(); break;
- default: amount=0; break;
- }
- if(use_colorspace_gamma() && (type<TYPE_U))
- amount=gamma_in(amount);
-
- const int height(get_height());
- const int width(get_width());
-
- Gdk::Rectangle ca(0,0,width,height);
-
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
- const Color bg1(0.75, 0.75, 0.75);
- const Color bg2(0.5, 0.5, 0.5);
- int i;
- for(i=width-1;i>=0;i--)
- {
- color_func(color,
- (use_colorspace_gamma() && type<TYPE_U)
- ? gamma_out(float(i)/float(width))
- : (float(i)/float(width)));
- const Color c1(Color::blend(color,bg1,1.0).clamped());
- const Color c2(Color::blend(color,bg2,1.0).clamped());
- assert(c1.is_valid());
- assert(c2.is_valid());
-
- if((i*2/height)&1)
- {
- gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
- gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
- }
- else
- {
- gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
- gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
- }
- }
-
- get_style()->paint_arrow(
- get_window(),
- Gtk::STATE_SELECTED,
- Gtk::SHADOW_OUT,
- ca,
- *this,
- " ",
- Gtk::ARROW_UP,
- 1,
- int(amount*width)-height/2,
- 0,
- height,
- height
- );
-
- gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
- get_window()->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- get_window()->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
- return true;
-}
-
-bool
-ColorSlider::on_event(GdkEvent *event)
-{
- const int width(get_width());
- float x = 0;
- if( GDK_SCROLL == event->type ){
- Color color(color_);
- float amount;
- switch(type)
- {
- case TYPE_R: amount=color.get_r(); break;
- case TYPE_G: amount=color.get_g(); break;
- case TYPE_B: amount=color.get_b(); break;
- case TYPE_Y: amount=color.get_y(); break;
- case TYPE_U: amount=color.get_u()+0.5; break;
- case TYPE_V: amount=color.get_v()+0.5; break;
- case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
- case TYPE_SAT: amount=color.get_s()*2.0; break;
- case TYPE_A: amount=color.get_a(); break;
- default: amount=0; break;
- }
- if(use_colorspace_gamma() && (type<TYPE_U))
- amount=gamma_in(amount);
- x = amount*width;
- switch(event->scroll.direction){
- case GDK_SCROLL_UP:
- case GDK_SCROLL_RIGHT:
- x+=1.0;
- break;
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_LEFT:
- x-=1.0;
- break;
- }
- } else {
- x = float(event->button.x);
- }
-
- float pos(x/width);
- if(pos<0 || x<=0)pos=0;
- if(pos>1)pos=1;
-
- if(use_colorspace_gamma() && (type<TYPE_U))
- pos=gamma_out(pos);
- if(pos<0 || event->button.x<=0)pos=0;
- if(pos>1)pos=1;
-
- switch(event->type)
- {
- case GDK_SCROLL:
- signal_slider_moved_(type,pos);
- queue_draw();
- signal_activated_();
- return true;
-
- case GDK_BUTTON_RELEASE:
- signal_activated_();
- return true;
-
- case GDK_BUTTON_PRESS:
- case GDK_MOTION_NOTIFY:
-// adjust_color(type,color_,pos);
- signal_slider_moved_(type,pos);
- queue_draw();
- return true;
- break;
- default:
- break;
- }
- return false;
-}
-
-/* === M E T H O D S ======================================================= */
-
-Widget_ColorEdit::Widget_ColorEdit():
- R_adjustment(0,-10000000,10000000,1,10,0),
- G_adjustment(0,-10000000,10000000,1,10,0),
- B_adjustment(0,-10000000,10000000,1,10,0),
- A_adjustment(0,-10000000,10000000,1,10,0)
-{
- notebook=manage(new Gtk::Notebook);
-
- Gtk::Table* rgb_table(manage(new Gtk::Table()));
- Gtk::Table* yuv_table(manage(new Gtk::Table()));
- Gtk::Table* main_table(this);
-
- {
- Gtk::VBox* rgb_box(manage(new Gtk::VBox()));
- Gtk::VBox* yuv_box(manage(new Gtk::VBox()));
- rgb_box->pack_start(*rgb_table,false,false);
- yuv_box->pack_start(*yuv_table,false,false);
- notebook->append_page(*rgb_box,_("RGB"));
- notebook->append_page(*yuv_box,_("YUV"));
- }
-
- color=Color(0,0,0,0);
-
- set_size_request(200,-1);
- hold_signals=true;
-
- Gtk::Label *label;
-
- R_adjustment.set_lower(-10000000);
- G_adjustment.set_lower(-10000000);
- B_adjustment.set_lower(-10000000);
- A_adjustment.set_lower(-10000000);
-
- clamp_=true;
-
- Pango::AttrList attr_list;
- Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
- pango_size.set_start_index(0);
- pango_size.set_end_index(64);
- attr_list.change(pango_size);
-
- widget_color.set_size_request(-1,16);
- attach(widget_color, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- attach(*notebook, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-#define SLIDER_ROW(i,n,l) \
- slider_##n=manage(new ColorSlider(ColorSlider::TYPE_##n)); \
- slider_##n->signal_slider_moved().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_slider_moved)); \
- /*slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::activated));*/ \
- slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed)); \
- label=manage(new class Gtk::Label(l,0.0,0.5)); \
- label->set_use_markup(false); \
- label->set_use_underline(false); \
- label->set_attributes(attr_list); \
- table->attach(*label, 0, 1, 1+2*i, 2+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); \
- table->attach(*slider_##n, 0, 1, 2+2*i, 3+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
-
-#define ATTACH_SPIN_BUTTON(i,n) \
- spinbutton_##n=manage(new class Gtk::SpinButton(n##_adjustment,1,0)); \
- spinbutton_##n->set_update_policy(Gtk::UPDATE_ALWAYS); \
- spinbutton_##n->set_size_request(SPINBUTTON_WIDTH,-1); \
- spinbutton_##n->show(); \
- table->attach(*spinbutton_##n, 1, 2, 1+2*i, 3+2*i, Gtk::SHRINK, Gtk::EXPAND, 2, 0)
-
- {
- Gtk::Table* table(rgb_table);
- SLIDER_ROW(0,R,_("Red"));
- ATTACH_SPIN_BUTTON(0,R);
- SLIDER_ROW(1,G,_("Green"));
- ATTACH_SPIN_BUTTON(1,G);
- SLIDER_ROW(2,B,_("Blue"));
- ATTACH_SPIN_BUTTON(2,B);
-
- hex_color_label = manage(new Gtk::Label(_("HTML code"), 0.0, 0.5));
- hex_color_label->set_use_markup(false);
- hex_color_label->set_use_underline(false);
- hex_color_label->set_attributes(attr_list);
- table->attach(*hex_color_label, 0, 1, 7, 8, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
- hex_color = manage(new Gtk::Entry());
- hex_color->set_width_chars(8);
- hex_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_hex_edited));
- table->attach(*hex_color, 0, 1, 8, 9, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
- }
- {
- Gtk::Table* table(yuv_table);
- SLIDER_ROW(0,Y,_("Luma"));
- SLIDER_ROW(1,HUE,_("Hue"));
- SLIDER_ROW(2,SAT,_("Saturation"));
- SLIDER_ROW(3,U,_("U"));
- SLIDER_ROW(4,V,_("V"));
- }
- {
- Gtk::Table* table(main_table);
- SLIDER_ROW(1,A,_("Alpha"));
- ATTACH_SPIN_BUTTON(1,A);
- }
-
-#undef SLIDER_ROW
-#undef ATTACH_SPIN_BUTTON
-
- spinbutton_R->signal_activate().connect(sigc::mem_fun(*spinbutton_G,&Gtk::SpinButton::grab_focus));
- spinbutton_G->signal_activate().connect(sigc::mem_fun(*spinbutton_B,&Gtk::SpinButton::grab_focus));
- spinbutton_B->signal_activate().connect(sigc::mem_fun(*spinbutton_A,&Gtk::SpinButton::grab_focus));
- spinbutton_A->signal_activate().connect(sigc::mem_fun(*spinbutton_R,&Gtk::SpinButton::grab_focus));
-
- R_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
- G_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
- B_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
- A_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
-
- show_all_children();
-
- set_digits(1);
- set_value(color);
-
- hold_signals=false;
-}
-
-Widget_ColorEdit::~Widget_ColorEdit()
-{
-}
-
-void
-Widget_ColorEdit::on_slider_moved(ColorSlider::Type type, float amount)
-{
- Color color(get_value_raw());
-
- assert(color.is_valid());
- ColorSlider::adjust_color(type,color,amount);
- assert(color.is_valid());
-
- // If a non-primary colorslider is adjusted,
- // we want to make sure that we clamp
- if(type>ColorSlider::TYPE_B && (color.get_r()<0 ||color.get_g()<0 ||color.get_b()<0))
- clamp_=true;
-
- /*
- if(type==ColorSlider::TYPE_R && color.get_r()<0)clamp_=false;
- if(type==ColorSlider::TYPE_G && color.get_g()<0)clamp_=false;
- if(type==ColorSlider::TYPE_B && color.get_b()<0)clamp_=false;
- */
- clamp_=false;
-
- set_value(color);
- assert(color.is_valid());
-}
-
-void
-Widget_ColorEdit::on_hex_edited()
-{
- Color color(get_value_raw());
- String s = hex_color->get_text();
- color.set_hex(s);
- set_value(color);
- signal_value_changed_();
-}
-
-void
-Widget_ColorEdit::on_value_changed()
-{
- if(hold_signals)
- return;
-
- const Color color(get_value_raw());
- assert(color.is_valid());
- slider_R->set_color(color);
- slider_G->set_color(color);
- slider_B->set_color(color);
- slider_Y->set_color(color);
- slider_U->set_color(color);
- slider_V->set_color(color);
- slider_HUE->set_color(color);
- slider_SAT->set_color(color);
- slider_A->set_color(color);
- hex_color->set_text(color.get_hex());
- widget_color.set_value(color);
-
- activate();
- signal_value_changed_();
-}
-
-void
-Widget_ColorEdit::set_has_frame(bool x)
-{
- spinbutton_R->set_has_frame(x);
- spinbutton_G->set_has_frame(x);
- spinbutton_B->set_has_frame(x);
- spinbutton_A->set_has_frame(x);
- spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
-}
-
-void
-Widget_ColorEdit::set_digits(int x)
-{
- spinbutton_R->set_digits(x);
- spinbutton_G->set_digits(x);
- spinbutton_B->set_digits(x);
- spinbutton_A->set_digits(x);
- spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
- spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
-}
-
-void
-Widget_ColorEdit::set_value(const synfig::Color &data)
-{
- assert(data.is_valid());
- hold_signals=true;
- clamp_=false;
-
- color=data;
-
- if(use_colorspace_gamma())
- {
- R_adjustment.set_value(gamma_in(color.get_r())*100);
- G_adjustment.set_value(gamma_in(color.get_g())*100);
- B_adjustment.set_value(gamma_in(color.get_b())*100);
- }
- else
- {
- R_adjustment.set_value(color.get_r()*100);
- G_adjustment.set_value(color.get_g()*100);
- B_adjustment.set_value(color.get_b()*100);
- }
- A_adjustment.set_value(color.get_a()*100);
-
- slider_R->set_color(color);
- slider_G->set_color(color);
- slider_B->set_color(color);
- slider_Y->set_color(color);
- slider_U->set_color(color);
- slider_V->set_color(color);
- slider_HUE->set_color(color);
- slider_SAT->set_color(color);
- slider_A->set_color(color);
- hex_color->set_text(color.get_hex());
- widget_color.set_value(color);
-
- hold_signals=false;
-}
-
-synfig::Color
-Widget_ColorEdit::get_value_raw()
-{
- Color color;
- if(use_colorspace_gamma())
- {
- color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
- color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
- color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
- }
- else
- {
- color.set_r(R_adjustment.get_value()/100);
- color.set_g(G_adjustment.get_value()/100);
- color.set_b(B_adjustment.get_value()/100);
- }
- color.set_a(A_adjustment.get_value()/100);
- assert(color.is_valid());
-
- return color;
-}
-
-const synfig::Color &
-Widget_ColorEdit::get_value()
-{
- if(use_colorspace_gamma())
- {
- color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
- color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
- color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
- assert(color.is_valid());
- }
- else
- {
- color.set_r(R_adjustment.get_value()/100);
- color.set_g(G_adjustment.get_value()/100);
- color.set_b(B_adjustment.get_value()/100);
- assert(color.is_valid());
- }
- color.set_a(A_adjustment.get_value()/100);
- assert(color.is_valid());
-
- if(notebook->get_current_page()!=0)
- color=color.clamped();
-
- /*{
- // Clamp out negative values
- color.set_r(std::max(0.0f,(float)color.get_r()));
- color.set_g(std::max(0.0f,(float)color.get_g()));
- color.set_b(std::max(0.0f,(float)color.get_b()));
- }*/
-
- return color;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_coloredit.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_WIDGET_COLOREDIT_H
-#define __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <synfig/color.h>
-#include "widget_color.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 Notebook;
-};
-
-namespace studio {
-
-class ColorSlider : public Gtk::DrawingArea
-{
-public:
- enum Type
- {
- TYPE_R,
- TYPE_G,
- TYPE_B,
- TYPE_Y,
- TYPE_U,
- TYPE_V,
- TYPE_HUE,
- TYPE_SAT,
- TYPE_A,
-
- TYPE_END
- };
-
-private:
-
- sigc::signal<void,Type,float> signal_slider_moved_;
- sigc::signal<void> signal_activated_;
-
- Type type;
- synfig::Color color_;
-
-public:
-
- sigc::signal<void,Type,float>& signal_slider_moved() { return signal_slider_moved_; }
- sigc::signal<void>& signal_activated() { return signal_activated_; }
-
- Type
- get_type()const { return type; }
-
- const synfig::Color&
- get_color()const { return color_; }
-
-
- ColorSlider(const Type &x=TYPE_Y);
-
- void
- set_type(Type x);
-
- void
- set_color(synfig::Color x);
-
- static void adjust_color(Type type, synfig::Color &color, float amount);
-
-private:
- typedef void (*slider_color_func)(synfig::Color &,float);
-
- static void slider_color_TYPE_R(synfig::Color &color, float amount);
- static void slider_color_TYPE_G(synfig::Color &color, float amount);
- static void slider_color_TYPE_B(synfig::Color &color, float amount);
- static void slider_color_TYPE_Y(synfig::Color &color, float amount);
- static void slider_color_TYPE_U(synfig::Color &color, float amount);
- static void slider_color_TYPE_V(synfig::Color &color, float amount);
- static void slider_color_TYPE_HUE(synfig::Color &color, float amount);
- static void slider_color_TYPE_SAT(synfig::Color &color, float amount);
- static void slider_color_TYPE_A(synfig::Color &color, float amount);
-
-
- bool
- redraw(GdkEventExpose*bleh);
- bool on_event(GdkEvent *event);
-}; // END of class ColorSlider
-
-
-class Widget_ColorEdit : public Gtk::Table
-{
- sigc::signal<void> signal_activated_;
- sigc::signal<void> signal_value_changed_;
-
- ColorSlider *slider_R;
- ColorSlider *slider_G;
- ColorSlider *slider_B;
- Gtk::Label *hex_color_label;
- Gtk::Entry *hex_color;
-
- ColorSlider *slider_A;
- ColorSlider *slider_Y;
- ColorSlider *slider_U;
- ColorSlider *slider_V;
- ColorSlider *slider_SAT;
- ColorSlider *slider_HUE;
-
- Widget_Color widget_color;
-
- bool hold_signals;
-
- bool clamp_;
-
- Gtk::SpinButton *spinbutton_R;
- Gtk::SpinButton *spinbutton_G;
- Gtk::SpinButton *spinbutton_B;
- Gtk::SpinButton *spinbutton_A;
-
- Gtk::Adjustment R_adjustment;
- Gtk::Adjustment G_adjustment;
- Gtk::Adjustment B_adjustment;
- Gtk::Adjustment A_adjustment;
-
- synfig::Color color;
-
- Gtk::Notebook* notebook;
-
-protected:
-
- void on_value_changed();
-
-public:
-
- sigc::signal<void>& signal_activated() { return signal_activated_; }
-
- sigc::signal<void>& signal_activate() { return signal_activated_; }
-
- void on_slider_moved(ColorSlider::Type type, float amount);
- void on_hex_edited();
-
- //Glib::SignalProxy0<void> signal_activate() { return spinbutton_A->signal_activate(); }
-
- sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
- void activated() { signal_activated_(); }
- void activate() { signal_activated_(); }
- void set_value(const synfig::Color &data);
- const synfig::Color &get_value();
- synfig::Color get_value_raw();
- void set_has_frame(bool x);
- void set_digits(int x);
- Widget_ColorEdit();
- ~Widget_ColorEdit();
-}; // END of class Widget_ColorEdit
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_compselect.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/menu.h>
-#include "widget_compselect.h"
-#include <ETL/stringf>
-#include <synfig/valuenode.h>
-#include "instance.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 ======================================================= */
-
-Widget_CompSelect::Widget_CompSelect()
-{
- App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::new_instance));
- App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::delete_instance));
- App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::set_selected_instance_signal));
-
- set_menu(instance_list_menu);
- refresh();
-}
-
-Widget_CompSelect::~Widget_CompSelect()
-{
-}
-
-void
-Widget_CompSelect::set_selected_instance_signal(etl::handle<studio::Instance> x)
-{
- set_selected_instance(x);
-}
-
-void
-Widget_CompSelect::set_selected_instance_(etl::handle<studio::Instance> instance)
-{
- if(studio::App::shutdown_in_progress)
- return;
-
- selected_instance=instance;
-}
-
-void
-Widget_CompSelect::set_selected_instance(etl::loose_handle<studio::Instance> x)
-{
- if(studio::App::shutdown_in_progress)
- return;
-
- // if it's already selected, don't select it again
- if (x==selected_instance)
- return;
-
- std::list<etl::handle<studio::Instance> >::iterator iter;
-
- if(x)
- {
- int i;
- for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++)
- ;
-
- assert(*iter==x);
-
- set_history(i);
- }
- else
- set_history(0);
-
- set_selected_instance_(x);
-}
-
-void
-Widget_CompSelect::new_instance(etl::handle<studio::Instance> instance)
-{
- if(studio::App::shutdown_in_progress)
- return;
-
- assert(instance);
-
- etl::loose_handle<studio::Instance> loose_instance(instance);
-
- instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Widget_CompSelect::refresh));
- instance->synfigapp::Instance::signal_filename_changed().connect(
- sigc::bind<etl::loose_handle<studio::Instance> >(
- sigc::mem_fun(*this,&Widget_CompSelect::set_selected_instance),
- loose_instance
- )
- );
-
- {
- std::string name=basename(instance->get_file_name());
-
- instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
- sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),loose_instance) ));
- }
-
-}
-
-void
-Widget_CompSelect::delete_instance(etl::handle<studio::Instance> instance)
-{
- refresh();
-
- if(selected_instance==instance)
- {
- set_selected_instance(0);
- set_history(0);
- }
-}
-
-void
-Widget_CompSelect::refresh()
-{
- remove_menu();
-
- if(!instance_list_menu.items().empty())
- instance_list_menu.items().clear();
-
- if(studio::App::shutdown_in_progress)
- return;
-
- std::list<etl::handle<studio::Instance> >::iterator iter;
- for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
- {
- std::string name=basename((*iter)->get_file_name());
-
- instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
- sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),*iter) ));
- }
- set_menu(instance_list_menu);
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_compselect.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_WIDGET_COMPSELECT_H
-#define __SYNFIG_STUDIO_WIDGET_COMPSELECT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/menu.h>
-#include "app.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 Menu; };
-
-namespace studio {
-
-class Widget_CompSelect : public Gtk::OptionMenu
-{
- Gtk::Menu instance_list_menu;
-
-
- etl::loose_handle<studio::Instance> selected_instance;
- void set_selected_instance_(etl::handle<studio::Instance> x);
-
- void new_instance(etl::handle<studio::Instance> x);
-
- void delete_instance(etl::handle<studio::Instance> x);
-
- void set_selected_instance(etl::loose_handle<studio::Instance> x);
-
- void set_selected_instance_signal(etl::handle<studio::Instance> x);
-
-public:
-
- Widget_CompSelect();
- ~Widget_CompSelect();
-
- etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
-
- void refresh();
-}; // END of class Widget_CompSelect
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_curves.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2008 Gerco Ballintijn
-**
-** 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 "widget_curves.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.h>
-#include <map>
-#include <vector>
-#include <ETL/misc>
-#include <sigc++/object.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 ================================================= */
-
-/*
-void
-studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
-{
- const int height(ca.get_height());
- const int width(ca.get_width());
-
- const int square_size(height/2);
-
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-
- if(color.get_alpha()!=1.0)
- {
- // In this case we need to render the alpha squares
-
- const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
- const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
-
- Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
- Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
-
- bool toggle(false);
- for(int i=0;i<width;i+=square_size)
- {
- const int square_width(min(square_size,width-i));
-
- if(toggle)
- {
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
- gc->set_rgb_fg_color(gdk_c2);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
- toggle=false;
- }
- else
- {
- gc->set_rgb_fg_color(gdk_c2);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
- toggle=true;
- }
- }
- }
- else
- {
- // In this case we have a solid color to use
- Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
-
- gc->set_rgb_fg_color(gdk_c1);
- window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
- }
- gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
- window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
-}
-*/
-
-/* === C L A S S E S ======================================================= */
-
-
-
-struct studio::Widget_Curves::Channel
-{
- synfig::String name;
- Gdk::Color color;
- std::map<synfig::Real,synfig::Real> values;
-};
-
-struct studio::Widget_Curves::CurveStruct : sigc::trackable
-{
- synfigapp::ValueDesc value_desc;
- std::vector<Channel> channels;
-
- CurveStruct(const synfigapp::ValueDesc& x):
- value_desc(x)
- {
- switch(value_desc.get_value_type())
- {
- case ValueBase::TYPE_REAL:
- channels.push_back(Channel());
- channels.back().name="real";
- channels.back().color=Gdk::Color("#007f7f");
- break;
- case ValueBase::TYPE_TIME:
- channels.push_back(Channel());
- channels.back().name="time";
- channels.back().color=Gdk::Color("#7f7f00");
- break;
- case ValueBase::TYPE_INTEGER:
- channels.push_back(Channel());
- channels.back().name="int";
- channels.back().color=Gdk::Color("#7f0000");
- break;
- case ValueBase::TYPE_BOOL:
- channels.push_back(Channel());
- channels.back().name="bool";
- channels.back().color=Gdk::Color("#ff7f00");
- break;
- case ValueBase::TYPE_ANGLE:
- channels.push_back(Channel());
- channels.back().name="theta";
- channels.back().color=Gdk::Color("#004f4f");
- break;
- case ValueBase::TYPE_COLOR:
- channels.push_back(Channel());
- channels.back().name="red";
- channels.back().color=Gdk::Color("#7f0000");
- channels.push_back(Channel());
- channels.back().name="green";
- channels.back().color=Gdk::Color("#007f00");
- channels.push_back(Channel());
- channels.back().name="blue";
- channels.back().color=Gdk::Color("#00007f");
- channels.push_back(Channel());
- channels.back().name="alpha";
- channels.back().color=Gdk::Color("#000000");
- break;
- case ValueBase::TYPE_VECTOR:
- channels.push_back(Channel());
- channels.back().name="x";
- channels.back().color=Gdk::Color("#7f007f");
- channels.push_back(Channel());
- channels.back().name="y";
- channels.back().color=Gdk::Color("#007f7f");
- break;
- case ValueBase::TYPE_BLINEPOINT:
- channels.push_back(Channel());
- channels.back().name="v.x";
- channels.back().color=Gdk::Color("#ff7f00");
- channels.push_back(Channel());
- channels.back().name="v.y";
- channels.back().color=Gdk::Color("#7f3f00");
-
- channels.push_back(Channel());
- channels.back().name="width";
- channels.back().color=Gdk::Color("#000000");
-
- channels.push_back(Channel());
- channels.back().name="origin";
- channels.back().color=Gdk::Color("#ffffff");
-
- channels.push_back(Channel());
- channels.back().name="tsplit";
- channels.back().color=Gdk::Color("#ff00ff");
-
- channels.push_back(Channel());
- channels.back().name="t1.x";
- channels.back().color=Gdk::Color("#ff0000");
- channels.push_back(Channel());
- channels.back().name="t1.y";
- channels.back().color=Gdk::Color("#7f0000");
-
- channels.push_back(Channel());
- channels.back().name="t2.x";
- channels.back().color=Gdk::Color("#ffff00");
- channels.push_back(Channel());
- channels.back().name="t2.y";
- channels.back().color=Gdk::Color("#7f7f00");
- break;
- default:
- throw synfig::Exception::BadType("Bad type for curves");
- }
- }
-
- void clear_all_values()
- {
- std::vector<Channel>::iterator iter;
- for(iter=channels.begin();iter!=channels.end();++iter)
- iter->values.clear();
- }
-
- synfig::Real get_value(int chan, synfig::Real time, synfig::Real tolerance)
- {
- std::map<synfig::Real,synfig::Real>::iterator iter;
-
- // First check to see if we have a value
- // that is "close enough" to the time
- // we are looking for
- iter=channels[chan].values.lower_bound(time);
- if(iter!=channels[chan].values.end() && iter->first-time<=tolerance)
- return -iter->second;
-
- // Since that didn't work, we now need
- // to go ahead and figure out what the
- // actual value is at that time.
- ValueBase value(value_desc.get_value(time));
- switch(value.get_type())
- {
- case ValueBase::TYPE_REAL:
- channels[0].values[time]=value.get(Real());
- break;
- case ValueBase::TYPE_TIME:
- channels[0].values[time]=value.get(Time());
- break;
- case ValueBase::TYPE_INTEGER:
- channels[0].values[time]=value.get(int());
- break;
- case ValueBase::TYPE_BOOL:
- channels[0].values[time]=value.get(bool());
- break;
- case ValueBase::TYPE_ANGLE:
- channels[0].values[time]=Angle::rad(value.get(Angle())).get();
- break;
- case ValueBase::TYPE_COLOR:
- channels[0].values[time]=value.get(Color()).get_r();
- channels[1].values[time]=value.get(Color()).get_g();
- channels[2].values[time]=value.get(Color()).get_b();
- channels[3].values[time]=value.get(Color()).get_a();
- break;
- case ValueBase::TYPE_VECTOR:
- channels[0].values[time]=value.get(Vector())[0];
- channels[1].values[time]=value.get(Vector())[1];
- break;
- case ValueBase::TYPE_BLINEPOINT:
- channels[0].values[time]=value.get(BLinePoint()).get_vertex()[0];
- channels[1].values[time]=value.get(BLinePoint()).get_vertex()[1];
- channels[2].values[time]=value.get(BLinePoint()).get_width();
- channels[3].values[time]=value.get(BLinePoint()).get_origin();
- channels[4].values[time]=value.get(BLinePoint()).get_split_tangent_flag();
- channels[5].values[time]=value.get(BLinePoint()).get_tangent1()[0];
- channels[6].values[time]=value.get(BLinePoint()).get_tangent1()[1];
- channels[7].values[time]=value.get(BLinePoint()).get_tangent2()[0];
- channels[8].values[time]=value.get(BLinePoint()).get_tangent2()[1];
- break;
- default:
- return 0;
- }
-
- return -channels[chan].values[time];
- }
-
- static bool is_not_supported(const synfigapp::ValueDesc& x)
- {
- return x.get_value_type() == ValueBase::TYPE_STRING
- || x.get_value_type() == ValueBase::TYPE_CANVAS
- || x.get_value_type() == ValueBase::TYPE_GRADIENT
- || x.get_value_type() == ValueBase::TYPE_LIST
- || x.get_value_type() == ValueBase::TYPE_SEGMENT;
- }
-};
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Curves::Widget_Curves():
- range_adjustment_(new Gtk::Adjustment(-1,-2,2,0.1,0.1,2))
-{
- set_size_request(64,64);
-
- range_adjustment_->signal_changed().connect(
- sigc::mem_fun(
- *this,
- &Widget_Curves::queue_draw
- )
- );
- range_adjustment_->signal_value_changed().connect(
- sigc::mem_fun(
- *this,
- &Widget_Curves::queue_draw
- )
- );
- //set_vadjustment(*range_adjustment_);
-
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Curves::redraw));
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-
-}
-
-Widget_Curves::~Widget_Curves()
-{
-}
-
-void
-Widget_Curves::set_time_adjustment(Gtk::Adjustment&x)
-{
- time_adjustment_=&x;
- time_adjustment_->signal_changed().connect(
- sigc::mem_fun(
- *this,
- &Widget_Curves::queue_draw
- )
- );
- time_adjustment_->signal_value_changed().connect(
- sigc::mem_fun(
- *this,
- &Widget_Curves::queue_draw
- )
- );
- //set_hadjustment(*time_adjustment_);
-}
-
-void
-Widget_Curves::clear()
-{
- curve_list_.clear();
-}
-
-void
-Widget_Curves::refresh()
-{
- std::list<CurveStruct>::iterator curve_iter;
- for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
- {
- curve_iter->clear_all_values();
- }
- queue_draw();
-}
-
-void
-Widget_Curves::set_value_descs(std::list<synfigapp::ValueDesc> value_descs)
-{
- curve_list_.clear();
-
- std::list<synfigapp::ValueDesc>::iterator iter;
- for(iter=value_descs.begin();iter!=value_descs.end();++iter)
- {
- if (CurveStruct::is_not_supported(*iter))
- continue;
-
- try {
- curve_list_.push_back(*iter);
- if(iter->is_value_node())
- {
- iter->get_value_node()->signal_changed().connect(
- sigc::mem_fun(
- *this,
- &studio::Widget_Curves::refresh
- )
- );
- }
- if(iter->parent_is_value_node())
- {
- iter->get_parent_value_node()->signal_changed().connect(
- sigc::mem_fun(
- *this,
- &studio::Widget_Curves::refresh
- )
- );
- }
- if(iter->parent_is_layer_param())
- {
- iter->get_layer()->signal_changed().connect(
- sigc::mem_fun(
- *this,
- &studio::Widget_Curves::refresh
- )
- );
- }
- }catch(synfig::Exception::BadType)
- {
- continue;
- }
- }
- queue_draw();
-}
-
-bool
-Widget_Curves::on_event(GdkEvent *event)
-{
- switch(event->type)
- {
- case GDK_SCROLL:
- switch(event->scroll.direction)
- {
- case GDK_SCROLL_UP:
- range_adjustment_->set_page_size(range_adjustment_->get_page_size()/1.25);
- range_adjustment_->changed();
- break;
- case GDK_SCROLL_DOWN:
- range_adjustment_->set_page_size(range_adjustment_->get_page_size()*1.25);
- range_adjustment_->changed();
- break;
- default:
- break;
- }
- break;
- default:
- return Gtk::DrawingArea::on_event(event);
- break;
- }
-
- return true;
-
-/* switch(event->type)
- {
- case GDK_BUTTON_PRESS:
- if(event->button.button==1)
- {
- signal_activate_();
- return true;
- }
- if(event->button.button==3)
- {
- signal_secondary_();
- return true;
- }
- break;
-
- default:
- break;
- }
- return false;
-*/
-}
-
-bool
-Widget_Curves::redraw(GdkEventExpose */*bleh*/)
-{
- const int h(get_height());
- const int w(get_width());
- get_window()->clear();
-
- if(!time_adjustment_ || !range_adjustment_ || !h || !w)
- return false;
-
- if(!curve_list_.size())
- return false;
-
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
- const Real t_begin(time_adjustment_->get_lower());
- const Real t_end(time_adjustment_->get_upper());
- const Real dt((t_end-t_begin)/w);
-
- const Real r_bottom(range_adjustment_->get_value());
- const Real r_top(r_bottom+range_adjustment_->get_page_size());
- const Real dr((r_top-r_bottom)/h);
- Real r_max(-100000000);
- Real r_min(100000000);
-
- std::list<CurveStruct>::iterator curve_iter;
-
- vector<Gdk::Point> points[10];
-
- gc->set_function(Gdk::COPY);
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
- // Draw zero mark
- gc->set_rgb_fg_color(Gdk::Color("#4f4f4f"));
- get_window()->draw_rectangle(gc, false, 0, round_to_int((0-r_bottom)/dr), w, 0);
-
- // This try to find a valid vanvas to show the keyframes of those
- // valuenodes. If not canvas found then no keyframes marks are shown.
- synfig::Canvas::Handle canvas=0;
- for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
- {
- canvas=curve_iter->value_desc.get_canvas();
- if(canvas)
- break;
- }
-
- if(canvas)
- {
- // Draw vertical lines for the keyframes marks.
- 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)w/(t_end-t_begin)*(iter->get_time()-t_begin)));
- if(iter->get_time()>=t_begin && iter->get_time()<t_end)
- {
- gc->set_rgb_fg_color(Gdk::Color("#a07f7f")); // It should be user selectable
- get_window()->draw_rectangle(gc, true, x, 0, 1, h);
- }
- }
- }
-
- // Draw current time
- gc->set_rgb_fg_color(Gdk::Color("#0000ff")); // It should be user selectable
- get_window()->draw_rectangle(gc, false, round_to_int((time_adjustment_->get_value()-t_begin)/dt), 0, 0, h);
-
- // Draw curves for the valuenodes stored in the curve list
- for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
- {
- Real t;
- int i;
- int channels(curve_iter->channels.size());
- for(i=0;i<channels;i++)
- points[i].clear();
-
- for(i=0,t=t_begin;i<w;i++,t+=dt)
- {
- for(int chan=0;chan<channels;chan++)
- {
- Real x(curve_iter->get_value(chan,t,dt));
- r_max=max(r_max,x);
- r_min=min(r_min,x);
- points[chan].push_back(
- Gdk::Point(
- i,
- round_to_int(
- (
- x-r_bottom
- )/dr
- )
- )
- );
- }
- }
-
- for(int chan=0;chan<channels;chan++)
- {
- gc->set_rgb_fg_color(curve_iter->channels[chan].color);
-
- // Draw the curve
- get_window()->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points[chan]));
-
- Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-
- layout->set_text(curve_iter->channels[chan].name);
- get_window()->draw_layout(gc, 1, points[chan][0].get_y()+1, layout);
- }
- }
-
- if(!curve_list_.empty())
- {
- range_adjustment_->set_upper(r_max+range_adjustment_->get_page_size()/2);
- range_adjustment_->set_lower(r_min-range_adjustment_->get_page_size()/2);
- }
- get_window()->get_update_area();
-
- return true;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_curves.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_WIDGET_CURVES_H
-#define __SYNFIG_STUDIO_WIDGET_CURVES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/layout.h>
-#include <synfig/color.h>
-#include <synfigapp/value_desc.h>
-#include <list>
-
-/* === 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_Curves : public Gtk::DrawingArea
-{
- struct Channel;
- struct CurveStruct;
-
- Gtk::Adjustment* time_adjustment_;
- Gtk::Adjustment* range_adjustment_;
-
- std::list<CurveStruct> curve_list_;
-
-public:
-
- Widget_Curves();
- ~Widget_Curves();
-
- void set_value_descs(std::list<synfigapp::ValueDesc> value_descs);
- void clear();
- void refresh();
-
- Gtk::Adjustment& get_range_adjustment() { return *range_adjustment_; }
- Gtk::Adjustment& get_time_adjustment() { return *time_adjustment_; }
- void set_time_adjustment(Gtk::Adjustment&);
-
-private:
- bool redraw(GdkEventExpose*bleh);
- bool on_event(GdkEvent *event);
-
-}; // END of class Widget_Curves
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_defaults.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2008 Chris Moore
-** Copyright (c) 2008 Carlos López
-**
-** 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 "widget_defaults.h"
-#include "widget_color.h"
-#include "widget_gradient.h"
-#include "dialogs/dialog_color.h"
-#include "dialogs/dialog_gradient.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/scale.h>
-#include <synfig/exception.h>
-#include <synfigapp/main.h>
-#include "canvasview.h"
-#include "widget_distance.h"
-#include "widget_enum.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 ========================================================= */
-
-#define GRADIENT_HEIGHT 16
-#define DEFAULT_INCREMENT (0.25)
-#define DEFAULT_WIDTH (synfig::Distance(3,synfig::Distance::SYSTEM_POINTS))
-
-/* === G L O B A L S ======================================================= */
-
-class studio::Widget_Brush : public Gtk::DrawingArea
-{
-public:
- Widget_Brush()
- {
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Brush::redraw));
-
- set_size_request(24,24);
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- add_events(Gdk::BUTTON1_MOTION_MASK);
-
- synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
- synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
- synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
- studio::App::signal_instance_selected().connect(sigc::hide(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw)));
- }
-
- bool
- redraw(GdkEventExpose */*bleh*/)
- {
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
- const int h(get_height());
- const int w(get_width());
-
- float pixelsize(0);
- if(App::get_selected_canvas_view())
- {
- const RendDesc& rend_desc(App::get_selected_canvas_view()->get_canvas()->rend_desc());
- pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
- }
- else
- {
- RendDesc rend_desc;
- pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
- }
- // Fill in the fill color
- render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_fill_color());
-
-/*
- gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_fill_color()));
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
- get_window()->draw_rectangle(
- gc,
- true, // Fill?
- 0,0, // x,y
- w,h //w,h
- );
-*/
-
- // Draw in the circle
- gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_outline_color()));
- gc->set_function(Gdk::COPY);
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
- get_window()->draw_arc(
- gc,
- true,
- round_to_int(((float)w/2.0f)-pixelsize/2.0f),
- round_to_int(((float)h/2.0f)-pixelsize/2.0f),
- round_to_int(pixelsize+0.6),
- round_to_int(pixelsize+0.6),
- 0,
- 360*64
- );
-
- return true;
- }
-
- bool
- on_event(GdkEvent *event)
- {
-// const int x(static_cast<int>(event->button.x));
- const int y(static_cast<int>(event->button.y));
-
- const int h(get_height());
-// const int w(get_width());
-
- switch(event->type)
- {
- case GDK_MOTION_NOTIFY:
- break;
- case GDK_BUTTON_RELEASE:
- if(event->button.button==1) // Left click
- {
- Distance dist(synfigapp::Main::get_bline_width());
-
- if(y<h/2) // increase BLine size
- {
- dist+=DEFAULT_INCREMENT;
- }
- else // Decrease BLine size
- {
- dist-=DEFAULT_INCREMENT;
- }
- synfigapp::Main::set_bline_width(dist);
- return true;
- }
- if(event->button.button==3)
- {
- // right click on bline width
- synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
- return true;
- }
- break;
- case GDK_SCROLL:
- {
- Distance dist(synfigapp::Main::get_bline_width());
-
- switch(event->scroll.direction){
- case GDK_SCROLL_UP:
- case GDK_SCROLL_RIGHT:
- dist+=DEFAULT_INCREMENT;
- break;
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_LEFT:
- dist-=DEFAULT_INCREMENT;
- break;
- }
- synfigapp::Main::set_bline_width(dist);
- return true;
- }
- default:
- break;
- }
-
- return false;
- }
-
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Defaults::Widget_Defaults()
-{
- //set_size_request(48,48+GRADIENT_HEIGHT+16);
- //set_size_request(48,-1);
-
- {
- Gtk::Table* subtable(manage(new Gtk::Table()));
-
- // Outline Color
- widget_otln_color=manage(new Widget_Color());
- widget_otln_color->show();
- widget_otln_color->set_size_request(16,16);
- widget_otln_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_otln_color_clicked));
- subtable->attach(*widget_otln_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- tooltips_.set_tip(*widget_otln_color,_("Outline Color"));
-
- // Fill Color
- widget_fill_color=manage(new Widget_Color());
- widget_fill_color->show();
- widget_fill_color->set_size_request(16,16);
- widget_fill_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fill_color_clicked));
- subtable->attach(*widget_fill_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- tooltips_.set_tip(*widget_fill_color,_("Fill Color"));
-
- Gtk::Image* icon;
-
- // Swap button
- Gtk::Button* button_swap(manage(new Gtk::Button()));
- button_swap->show();
- button_swap->set_relief(Gtk::RELIEF_NONE);
- button_swap->set_border_width(0);
- icon=manage(new Gtk::Image(Gtk::StockID("synfig-swap_colors"),Gtk::IconSize(1)));
- icon->show();
- button_swap->add(*icon);
- //button_swap->get_child()->set_size_request(16/3,16/3);
- //button_swap->set_size_request(16/3,16/3);
- dynamic_cast<Gtk::Misc*>(button_swap->get_child())->set_padding(0,0);
- button_swap->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_swap_color_clicked));
- subtable->attach(*button_swap, 4, 7, 0, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- tooltips_.set_tip(*button_swap,_("Swap Fill and\nOutline Colors"));
-
- // Reset button
- Gtk::Button* button_reset(manage(new Gtk::Button()));
- button_reset->show();
- button_reset->set_relief(Gtk::RELIEF_NONE);
- button_reset->set_border_width(0);
- icon=manage(new Gtk::Image(Gtk::StockID("synfig-reset_colors"),Gtk::IconSize(1)));
- icon->show();
- button_reset->add(*icon);
- dynamic_cast<Gtk::Misc*>(button_reset->get_child())->set_padding(0,0);
- //button_reset->set_size_request(16/3,16/3);
- button_reset->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_reset_color_clicked));
- subtable->attach(*button_reset, 0, 3, 4, 7, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- tooltips_.set_tip(*button_reset,_("Reset Colors to Black and White"));
-
-
- attach(*subtable, 0, 1, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
- subtable->set_size_request(36,36);
- subtable->set_homogeneous(true);
- subtable->show();
- }
- widget_brush=manage(new Widget_Brush());
- widget_brush->show();
- widget_brush->set_size_request(36,36);
- attach(*widget_brush,1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
- tooltips_.set_tip(*widget_brush,_("Brush Preview"));
-
- widget_bline_width=manage(new Widget_Distance());
- widget_bline_width->show();
- bline_width_refresh();
- widget_bline_width->set_digits(2);
- widget_bline_width->set_range(0,10000000);
- widget_bline_width->set_size_request(24,-1);
- widget_bline_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_bline_width_changed));
- attach(*widget_bline_width,1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- tooltips_.set_tip(*widget_bline_width,_("Brush Size"));
-
-
- widget_blend_method=manage(new Widget_Enum());
- widget_blend_method->show();
- widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed));
- widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method"));
- attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
- tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
-
- widget_interpolation=manage(new Widget_Enum());
- widget_interpolation->show();
- widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
- widget_interpolation->set_param_desc(
- ParamDesc("interpolation")
- .set_hint("enum")
- .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
- .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
- .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
- .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
- );
- attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
- tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
-
- widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
- widget_opacity->show();
- widget_opacity->set_digits(2);
- widget_opacity->set_value_pos(Gtk::POS_LEFT);
- widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
- attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
- tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
-
- widget_gradient=manage(new Widget_Gradient());
- widget_gradient->show();
- widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
- widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
- attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
- tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
-
-
- // Signals
- synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
- synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
- synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
- synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_color_refresh));
- synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
- synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
- synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
-
- otln_color_refresh();
- fill_color_refresh();
- gradient_refresh();
- blend_method_refresh();
- opacity_refresh();
- interpolation_refresh();
-/*
- set_size_request(48,48+GRADIENT_HEIGHT);
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- add_events(Gdk::BUTTON1_MOTION_MASK);
-
- synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
- synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
- synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
- synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
-
- if(App::dialog_gradient)
- {
- App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
- App::dialog_gradient->reset();
- App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
- }
-
- if(App::dialog_color)
- {
- App::dialog_color->set_color(synfigapp::Main::get_outline_color());
- App::dialog_color->reset();
- App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
- }
-*/
-}
-
-Widget_Defaults::~Widget_Defaults()
-{
-}
-
-void
-Widget_Defaults::otln_color_refresh()
-{
- widget_otln_color->set_value(synfigapp::Main::get_outline_color());
-}
-
-void
-Widget_Defaults::fill_color_refresh()
-{
- widget_fill_color->set_value(synfigapp::Main::get_fill_color());
-}
-
-void
-Widget_Defaults::gradient_refresh()
-{
- widget_gradient->set_value(synfigapp::Main::get_gradient());
-}
-
-void
-Widget_Defaults::bline_width_refresh()
-{
- widget_bline_width->set_value(synfigapp::Main::get_bline_width());
-}
-
-void
-Widget_Defaults::blend_method_refresh()
-{
- widget_blend_method->set_value(synfigapp::Main::get_blend_method());
-}
-
-void
-Widget_Defaults::interpolation_refresh()
-{
- widget_interpolation->set_value(synfigapp::Main::get_interpolation());
-}
-
-void
-Widget_Defaults::opacity_refresh()
-{
- widget_opacity->set_value(synfigapp::Main::get_opacity());
-}
-
-void
-Widget_Defaults::on_opacity_changed()
-{
- synfigapp::Main::set_opacity(widget_opacity->get_value());
-}
-
-void
-Widget_Defaults::on_blend_method_changed()
-{
- synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
-}
-
-void
-Widget_Defaults::on_interpolation_changed()
-{
- synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
-}
-
-void
-Widget_Defaults::on_bline_width_changed()
-{
- synfigapp::Main::set_bline_width(widget_bline_width->get_value());
-}
-
-void
-Widget_Defaults::on_otln_color_clicked()
-{
- // Left click on outline color
- App::dialog_color->set_color(synfigapp::Main::get_outline_color());
- App::dialog_color->reset();
- App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
- App::dialog_color->present();
-}
-
-void
-Widget_Defaults::on_fill_color_clicked()
-{
- // Left click on fill color
- App::dialog_color->set_color(synfigapp::Main::get_fill_color());
- App::dialog_color->reset();
- App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_color));
- App::dialog_color->present();
-}
-
-void
-Widget_Defaults::on_swap_color_clicked()
-{
- synfigapp::Main::color_swap();
-}
-
-void
-Widget_Defaults::on_reset_color_clicked()
-{
- synfigapp::Main::set_fill_color(Color::white());
- synfigapp::Main::set_outline_color(Color::black());
-}
-
-void
-Widget_Defaults::on_gradient_clicked()
-{
- App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
- App::dialog_gradient->reset();
- App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
- App::dialog_gradient->set_default_button_set_sensitive(false);
- App::dialog_gradient->present();
-}
-
-/*
-bool
-Widget_Defaults::redraw(GdkEventExpose*bleh)
-{
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
- const int h(get_height());
- const int w(get_width());
- const int size=std::min(h-GRADIENT_HEIGHT,w);
-
- render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_fill_color());
- render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
- render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
-
-
-
-
-
- Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-
- gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
- layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
- layout->set_alignment(Pango::ALIGN_CENTER);
- layout->set_width(w/2);
- get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
-
- return true;
-}
-
-bool
-Widget_Defaults::on_event(GdkEvent *event)
-{
- const int x(static_cast<int>(event->button.x));
- const int y(static_cast<int>(event->button.y));
-
- const int h(get_height());
- const int w(get_width());
- const int size=std::min(h-GRADIENT_HEIGHT,w);
-
- switch(event->type)
- {
- case GDK_MOTION_NOTIFY:
- break;
- case GDK_BUTTON_PRESS:
-// if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
- break;
- case GDK_BUTTON_RELEASE:
- if(event->button.button==1)
- {
- if(y>size)
- {
- // Left click on gradient
- App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
- App::dialog_gradient->reset();
- App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
- App::dialog_gradient->present();
- return true;
- }
- if(x>0 && x<=size)
- {
- if(x<size*3/4 && y<size*3/4)
- {
- // Left click on outline coloe
- App::dialog_color->set_color(synfigapp::Main::get_outline_color());
- App::dialog_color->reset();
- App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
- App::dialog_color->present();
- return true;
- }
- if(x>size*3/4 && y>size/4)
- {
- // Left click on fill color
- App::dialog_color->set_color(synfigapp::Main::get_fill_color());
- App::dialog_color->reset();
- App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
- App::dialog_color->present();
- return true;
- }
- }
- if(x>size) // Left click on BLine Width
- {
- Distance dist(synfigapp::Main::get_bline_width());
-
- if(y<size/2) // increase BLine size
- {
- dist+=DEFAULT_INCREMENT;
- }
- else // Decrease BLine size
- {
- dist-=DEFAULT_INCREMENT;
- }
- synfigapp::Main::set_bline_width(dist);
- }
- }
- if(event->button.button==3)
- {
- if(y>size)
- {
- // right click on gradient
- synfigapp::Main::set_gradient_default_colors();
- return true;
- }
- else
- {
- if(x<size)
- {
- // right click on colors
- synfigapp::Main::color_swap();
- return true;
- }
-
- if(x>w/2)
- {
- // right click on bline width
- synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
- }
-
- }
- }
- break;
- case GDK_SCROLL:
- {
- Distance dist(synfigapp::Main::get_bline_width());
-
- if(event->scroll.direction==GDK_SCROLL_UP)
- {
- dist+=DEFAULT_INCREMENT;
- }
- else if(event->scroll.direction==GDK_SCROLL_DOWN)
- {
- dist-=DEFAULT_INCREMENT;
- }
- synfigapp::Main::set_bline_width(dist);
- }
- default:
- break;
- }
-
- return false;
-}
-*/
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_defaults.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_WIDGET_DEFAULTS_H
-#define __SYNFIG_STUDIO_WIDGET_DEFAULTS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/table.h>
-#include <synfig/gradient.h>
-#include "widget_gradient.h"
-#include <gtkmm/tooltips.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 HScale; }
-
-namespace studio {
-
-class Widget_Brush;
-class Widget_Color;
-class Widget_Distance;
-class Widget_Enum;
-
-class Widget_Defaults : public Gtk::Table
-{
- Widget_Brush *widget_brush;
- Widget_Color *widget_otln_color;
- Widget_Color *widget_fill_color;
- Widget_Distance *widget_bline_width;
- Widget_Gradient *widget_gradient;
- Widget_Enum *widget_blend_method;
- Widget_Enum *widget_interpolation;
- Gtk::HScale *widget_opacity;
-
- void otln_color_refresh();
- void fill_color_refresh();
- void gradient_refresh();
- void bline_width_refresh();
- void interpolation_refresh();
-
- void on_bline_width_changed();
- void on_otln_color_clicked();
- void on_fill_color_clicked();
- void on_swap_color_clicked();
- void on_reset_color_clicked();
- void on_gradient_clicked();
- void on_interpolation_changed();
-
- void blend_method_refresh();
- void on_blend_method_changed();
-
- void opacity_refresh();
- void on_opacity_changed();
-
- Gtk::Tooltips tooltips_;
-
-public:
-
- Widget_Defaults();
-
- ~Widget_Defaults();
-
-// bool redraw(GdkEventExpose*bleh=NULL);
-
-// bool on_event(GdkEvent *event);
-}; // END of class BlackLevelSelector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_distance.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 "widget_distance.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 ======================================================= */
-
-Widget_Distance::Widget_Distance():
- Gtk::SpinButton(0.05,5),
- distance_(1, Distance::SYSTEM_POINTS),
- adjustment(0,-100000000,100000000,1,1,0)
-{
- set_adjustment(adjustment);
- set_numeric(false);
-}
-
-Widget_Distance::~Widget_Distance()
-{
-}
-
-int
-Widget_Distance::on_input(double* new_value)
-{
- distance_=synfig::String(get_text());
- *new_value=distance_.get();
- return 1;
-}
-
-bool
-Widget_Distance::on_output()
-{
- try{
- distance_=get_adjustment()->get_value();
- set_text(distance_.get_string(get_digits()));
- } catch (...) { /* synfig::error("Widget_Distance::on_output(): Caught something..."); */ }
- return true;
-}
-
-void
-Widget_Distance::set_value(const synfig::Distance &data)
-{
- distance_=data;
- get_adjustment()->set_value(distance_.get());
-}
-
-synfig::Distance
-Widget_Distance::get_value() const
-{
- distance_=get_adjustment()->get_value();
- return distance_;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_distance.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_WIDGET_DISTANCE_H
-#define __SYNFIG_STUDIO_WIDGET_DISTANCE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <synfig/distance.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 Widget_Distance : public Gtk::SpinButton
-{
- //sigc::signal<void> signal_value_changed_;
-
- mutable synfig::Distance distance_;
-
- Gtk::Adjustment adjustment;
-
-protected:
-
- int on_input(double* new_value);
- bool on_output();
-
-public:
- //sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
- void set_value(const synfig::Distance &data);
- synfig::Distance get_value()const;
- Widget_Distance();
- ~Widget_Distance();
-}; // END of class Widget_Distance
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_enum.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/menu.h>
-#include "widget_enum.h"
-#include <ETL/stringf>
-#include <synfig/valuenode.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 ======================================================= */
-
-Widget_Enum::Widget_Enum()
-{
-}
-
-Widget_Enum::~Widget_Enum()
-{
-}
-
-void
-Widget_Enum::set_param_desc(const synfig::ParamDesc &x)
-{
- param_desc=x;
- //refresh();
-}
-
-void
-Widget_Enum::set_value_(int data)
-{
- set_value(data);
- activate();
-}
-
-void
-Widget_Enum::refresh()
-{
- enum_menu = manage(new class Gtk::Menu());
-
- std::list<synfig::ParamDesc::EnumData> enum_list=param_desc.get_enum_list();
- std::list<synfig::ParamDesc::EnumData>::iterator iter;
-
- String name=strprintf("(%d)",value);
-
- for(iter=enum_list.begin();iter!=enum_list.end();iter++)
- if(iter->value!=value)
- enum_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->local_name,
- sigc::bind(sigc::mem_fun(*this,&Widget_Enum::set_value_),iter->value)
- ));
- else
- name=iter->local_name;
-
- enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
-
- set_menu(*enum_menu);
-}
-
-void
-Widget_Enum::set_value(int data)
-{
- value=data;
-
- refresh();
-
- set_history(0);
-}
-
-int
-Widget_Enum::get_value() const
-{
- return value;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_enum.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_WIDGET_ENUM_H
-#define __SYNFIG_STUDIO_WIDGET_ENUM_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/layer.h>
-#include <gtkmm/optionmenu.h>
-#include <synfig/paramdesc.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 Menu; };
-
-namespace studio {
-
-class Widget_Enum : public Gtk::OptionMenu
-{
- Gtk::Menu *enum_menu;
- synfig::ParamDesc param_desc;
-
- int value;
- void set_value_(int data);
-public:
-
- Widget_Enum();
- ~Widget_Enum();
-
- void set_param_desc(const synfig::ParamDesc &x);
- void refresh();
-
- void set_value(int data);
- int get_value() const;
-}; // END of class Widget_Enum
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_filename.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 "widget_filename.h"
-#include "app.h"
-#include "canvasview.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 ======================================================= */
-
-Widget_Filename::Widget_Filename()
-{
- entry_filename=manage(new Gtk::Entry());
- label_find= manage(new Gtk::Label(_("Find")));
- button_choose=manage(new Gtk::Button());
- Pango::AttrList attr_list;
- {
- Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
- pango_size.set_start_index(0);
- pango_size.set_end_index(64);
- attr_list.change(pango_size);
- }
- label_find->set_attributes(attr_list);
- label_find->set_ellipsize(Pango::ELLIPSIZE_END);
- button_choose->add(*label_find);
-
- pack_start(*entry_filename);
- pack_start(*button_choose);
- entry_filename->show();
- button_choose->show();
- label_find->show();
-
- button_choose->signal_clicked().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_button_choose_pressed));
- //entry_filename->signal_value_changed().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
- entry_filename->signal_activate().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
-}
-
-Widget_Filename::~Widget_Filename()
-{
-}
-
-void
-Widget_Filename::set_has_frame(bool x)
-{
- entry_filename->set_has_frame(x);
-}
-
-
-void
-Widget_Filename::set_value(const std::string &data)
-{
- entry_filename->set_text(data);
-}
-
-string
-Widget_Filename::get_value() const
-{
- try
- {
- return entry_filename->get_text();
- }
- catch(...)
- {
- throw string("Caught unknown exception");
- }
-}
-
-void
-Widget_Filename::on_value_changed()
-{
- signal_value_changed()();
-}
-
-void
-Widget_Filename::on_button_choose_pressed()
-{
- string filename=entry_filename->get_text();
- if(filename.empty())
- filename=".";
- else
- filename = etl::absolute_path(
- etl::dirname(App::get_selected_canvas_view()->get_canvas()->get_file_name()) +
- ETL_DIRECTORY_SEPARATOR +
- filename);
- if(App::dialog_open_file(_("Choose File"), filename, MISC_DIR_PREFERENCE))
- entry_filename->set_text(filename);
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_filename.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_WIDGET_FILENAME_H
-#define __SYNFIG_STUDIO_WIDGET_FILENAME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/box.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/button.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 Widget_Filename : public Gtk::HBox
-{
- Gtk::Entry *entry_filename;
- Gtk::Button *button_choose;
- Gtk::Label *label_find;
-
- void on_button_choose_pressed();
-
- sigc::signal<void> signal_value_changed_;
-
-public:
- sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
- Glib::SignalProxy0<void> signal_activate() { return entry_filename->signal_activate(); }
-
- void on_value_changed();
-
- void set_value(const std::string &data);
- std::string get_value() const;
- void set_has_frame(bool x);
- Widget_Filename();
- ~Widget_Filename();
-}; // END of class Widget_Filename
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_gradient.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 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 "widget_gradient.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <synfig/exception.h>
-#include <ETL/misc>
-
-#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 ================================================= */
-
-void
-studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
-{
- int height = ca.get_height();
- int width = ca.get_width()-4;
-
- float sample_width(1.0f/(float)width);
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
- const Color bg1(0.25, 0.25, 0.25);
- const Color bg2(0.5, 0.5, 0.5);
- Gdk::Color gdk_c;
- int i;
- for(i=0;i<width;i++)
- {
- const Color c(gradient(float(i)/float(width),sample_width));
- const Color c1(Color::blend(c,bg1,1.0).clamped());
- const Color c2(Color::blend(c,bg2,1.0).clamped());
- gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
- gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
- gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
- gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
- gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
- gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
-
- if((i*2/height)&1)
- {
- gdk_c.set_rgb(r1,g1,b1);
- gc->set_rgb_fg_color(gdk_c);
- window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
-
- gdk_c.set_rgb(r2,g2,b2);
- gc->set_rgb_fg_color(gdk_c);
- window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
- }
- else
- {
- gdk_c.set_rgb(r2,g2,b2);
- gc->set_rgb_fg_color(gdk_c);
- window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
-
- gdk_c.set_rgb(r1,g1,b1);
- gc->set_rgb_fg_color(gdk_c);
- window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
- }
- }
- gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
- window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
- gc->set_rgb_fg_color(Gdk::Color("#000000"));
- window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
-}
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Gradient::Widget_Gradient():
- editable_(false)
-{
- set_size_request(-1,64);
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Gradient::redraw));
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- add_events(Gdk::BUTTON1_MOTION_MASK);
-
-}
-
-Widget_Gradient::~Widget_Gradient()
-{
-}
-
-#define CONTROL_HEIGHT 16
-bool
-Widget_Gradient::redraw(GdkEventExpose */*bleh*/)
-{
- const int h(get_height());
- const int w(get_width());
-
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
- Gdk::Rectangle area(0,0,w,h);
- if(!editable_)
- {
- render_gradient_to_window(get_window(),area,gradient_);
- return true;
- }
-
- render_gradient_to_window(get_window(),Gdk::Rectangle(0,0,w,h-CONTROL_HEIGHT),gradient_);
-
- gc->set_rgb_fg_color(Gdk::Color("#7f7f7f"));
- get_window()->draw_rectangle(gc, false, 0, h-CONTROL_HEIGHT, w, CONTROL_HEIGHT);
-
- Gradient::iterator iter,selected_iter;
- bool show_selected(false);
- for(iter=gradient_.begin();iter!=gradient_.end();iter++)
- {
- if(*iter!=selected_cpoint)
- get_style()->paint_arrow(
- get_window(),
- (*iter==selected_cpoint)?Gtk::STATE_SELECTED:Gtk::STATE_ACTIVE,
- Gtk::SHADOW_OUT,
- area,
- *this,
- " ",
- Gtk::ARROW_UP,
- 1,
- int(iter->pos*w)-CONTROL_HEIGHT/2+1,
- h-CONTROL_HEIGHT,
- CONTROL_HEIGHT,
- CONTROL_HEIGHT
- );
- else
- {
- selected_iter=iter;
- show_selected=true;
- }
- }
-
- // we do this so that we can be sure that
- // the selected marker is shown on top
- if(show_selected)
- {
- get_style()->paint_arrow(
- get_window(),
- Gtk::STATE_SELECTED,
- Gtk::SHADOW_OUT,
- area,
- *this,
- " ",
- Gtk::ARROW_UP,
- 1,
- round_to_int(selected_iter->pos*w)-CONTROL_HEIGHT/2+1,
- h-CONTROL_HEIGHT,
- CONTROL_HEIGHT,
- CONTROL_HEIGHT
- );
- }
-
- return true;
-}
-
-void
-Widget_Gradient::insert_cpoint(float x)
-{
- Gradient::CPoint new_cpoint;
- new_cpoint.pos=x;
- new_cpoint.color=gradient_(x);
- gradient_.push_back(new_cpoint);
- gradient_.sort();
- gradient_.sort();
- set_selected_cpoint(new_cpoint);
- queue_draw();
-}
-
-void
-Widget_Gradient::remove_cpoint(float x)
-{
- gradient_.erase(gradient_.proximity(x));
- signal_value_changed_();
- queue_draw();
-}
-
-void
-Widget_Gradient::popup_menu(float x)
-{
- Gtk::Menu* menu(manage(new Gtk::Menu()));
- menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-
- menu->items().clear();
-
- menu->items().push_back(
- Gtk::Menu_Helpers::MenuElem(
- _("Insert CPoint"),
- sigc::bind(
- sigc::mem_fun(*this,&studio::Widget_Gradient::insert_cpoint),
- x
- )
- )
- );
-
- if(!gradient_.empty())
- {
- menu->items().push_back(
- Gtk::Menu_Helpers::MenuElem(
- _("Remove CPoint"),
- sigc::bind(
- sigc::mem_fun(*this,&studio::Widget_Gradient::remove_cpoint),
- x
- )
- )
- );
- }
-
- menu->popup(0,0);
-}
-
-void
-Widget_Gradient::set_value(const synfig::Gradient& x)
-{
- gradient_=x;
- if(gradient_.size())
- set_selected_cpoint(*gradient_.proximity(0.0f));
- queue_draw();
-}
-
-void
-Widget_Gradient::set_selected_cpoint(const synfig::Gradient::CPoint &x)
-{
- selected_cpoint=x;
- signal_cpoint_selected_(selected_cpoint);
- queue_draw();
-}
-
-void
-Widget_Gradient::update_cpoint(const synfig::Gradient::CPoint &x)
-{
- try
- {
- Gradient::iterator iter(gradient_.find(x));
- iter->pos=x.pos;
- iter->color=x.color;
- gradient_.sort();
- queue_draw();
- }
- catch(synfig::Exception::NotFound)
- {
- // Yotta...
- }
-}
-
-bool
-Widget_Gradient::on_event(GdkEvent *event)
-{
- //if(editable_)
- {
- const int x(static_cast<int>(event->button.x));
- const int y(static_cast<int>(event->button.y));
-
- float pos((float)x/(float)get_width());
- if(pos<0.0f)pos=0.0f;
- if(pos>1.0f)pos=1.0f;
-
- switch(event->type)
- {
- case GDK_MOTION_NOTIFY:
- if(editable_ && y>get_height()-CONTROL_HEIGHT)
- {
- if(!gradient_.size()) return true;
- Gradient::iterator iter(gradient_.find(selected_cpoint));
- //! Use SHIFT to stack two CPoints together.
- if(event->button.state&GDK_SHIFT_MASK)
- {
- float begin(-100000000),end(100000000);
- Gradient::iterator before(iter),after(iter);
- after++;
- if(iter!=gradient_.begin())
- {
- before--;
- begin=before->pos;
- }
- if(after!=gradient_.end())
- {
- end=after->pos;
- }
-
- if(pos>end)
- pos=end;
- if(pos<begin)
- pos=begin;
-
- iter->pos=pos;
- }
- else
- {
- iter->pos=pos;
- gradient_.sort();
- }
-
-// signal_value_changed_();
- changed_=true;
- queue_draw();
- return true;
- }
- break;
- case GDK_BUTTON_PRESS:
- changed_=false;
- if(event->button.button==1)
- {
- if(editable_ && y>get_height()-CONTROL_HEIGHT)
- {
- set_selected_cpoint(*gradient_.proximity(pos));
- queue_draw();
- return true;
- }
- else
- {
- signal_clicked_();
- return true;
- }
- }
- else if(editable_ && event->button.button==3)
- {
- popup_menu(pos);
- return true;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if(editable_ && event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
- {
- set_selected_cpoint(*gradient_.proximity(pos));
- if(changed_)signal_value_changed_();
- return true;
- }
- default:
- break;
- }
- }
-
- return false;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_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_WIDGET_GRADIENT_H
-#define __SYNFIG_STUDIO_WIDGET_GRADIENT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.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 studio {
-
-void render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient);
-
-class Widget_Gradient : public Gtk::DrawingArea
-{
- sigc::signal<void> signal_value_changed_;
- sigc::signal<void> signal_clicked_;
-
- sigc::signal<void,synfig::Gradient::CPoint> signal_cpoint_selected_;
-
- synfig::Gradient gradient_;
-
- bool editable_;
-
- bool changed_;
-
- synfig::Gradient::CPoint selected_cpoint;
-
- void popup_menu(float x);
-
- void insert_cpoint(float x);
-
- void remove_cpoint(float x);
-
-public:
-
- Widget_Gradient();
-
- ~Widget_Gradient();
-
- sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
- sigc::signal<void>& signal_clicked() { return signal_clicked_; }
-
- sigc::signal<void,synfig::Gradient::CPoint>& signal_cpoint_selected() { return signal_cpoint_selected_; }
-
- void set_value(const synfig::Gradient& x);
-
- const synfig::Gradient& get_value()const { return gradient_; }
-
- void set_editable(bool x=true) { editable_=x; }
-
- bool get_editable()const { return editable_; }
-
-
-
- void set_selected_cpoint(const synfig::Gradient::CPoint &x);
-
- const synfig::Gradient::CPoint& get_selected_cpoint() { return selected_cpoint; }
-
- void update_cpoint(const synfig::Gradient::CPoint &x);
-
-
-
- bool redraw(GdkEventExpose*bleh=NULL);
-
- bool on_event(GdkEvent *event);
-}; // END of class BlackLevelSelector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_keyframe_list.cpp
-** \brief A custom widget to manage keyframes in the timeline.
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
-** Copyright (c) 2009 Carlos López
-**
-** 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 "widget_keyframe_list.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <synfig/exception.h>
-#include <ETL/misc>
-
-#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 ========================================================= */
-#define WIDGET_KEYFRAME_LIST_DEFAULT_FPS 24.0
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Keyframe_List::Widget_Keyframe_List():
- adj_default(0,0,2,1/WIDGET_KEYFRAME_LIST_DEFAULT_FPS,10/WIDGET_KEYFRAME_LIST_DEFAULT_FPS),
- kf_list_(&default_kf_list_),
- time_ratio("4f", WIDGET_KEYFRAME_LIST_DEFAULT_FPS)
-{
- adj_timescale=0;
- editable_=true;
- fps=WIDGET_KEYFRAME_LIST_DEFAULT_FPS;
- set_size_request(-1,64);
- //!This signal is called when the widget need to be redrawn
- signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Keyframe_List::redraw));
- //! The widget respond to mouse button press and release and to
- //! left button motion
- add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- add_events(Gdk::BUTTON1_MOTION_MASK /*| Gdk::BUTTON3_MOTION_MASK*/);
- add_events(Gdk::POINTER_MOTION_MASK);
- set_time_adjustment(&adj_default);
- queue_draw();
-}
-
-Widget_Keyframe_List::~Widget_Keyframe_List()
-{
-}
-
-bool
-Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/)
-{
-
- const int h(get_height());
- const int w(get_width());
-
- //!Boundaries of the drawing area in time units.
- synfig::Time top(adj_timescale->get_upper());
- synfig::Time bottom(adj_timescale->get_lower());
-
- //! The graphic context
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
- //! A rectangle that defines the drawing area.
- Gdk::Rectangle area(0,0,w,h);
-
- //! draw a background
- gc->set_rgb_fg_color(Gdk::Color("#9d9d9d"));
- get_window()->draw_rectangle(gc, true, 0, 0, w, h);
-
- if(!editable_)
- {
- return true; //needs fixing!
- }
- //!Returns if there are not keyframes to draw.
- if (kf_list_->empty()) return false;
-
- //!Loop all the keyframes
- synfig::KeyframeList::iterator iter,selected_iter;
- bool show_selected(false);
- for(iter=kf_list_->begin();iter!=kf_list_->end();iter++)
- {
- //!do not draw keyframes out of the widget boundaries
- if (iter->get_time()>top || iter->get_time()<bottom)
- continue;
- //! If the keyframe is not the selected one
- if(*iter!=selected_kf)
- {
- const int x((int)((float)(iter->get_time()-bottom) * (w/(top-bottom)) ) );
- get_style()->paint_arrow(get_window(), Gtk::STATE_NORMAL,
- Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
- x-h/2+1, 0, h, h );
- }
- else
- {
- selected_iter=iter;
- show_selected=true;
- }
- }
-
- // we do this so that we can be sure that
- // the selected keyframe is shown on top
- if(show_selected)
- {
- // If not dragging just show the selected keyframe
- if (!dragging_)
- {
- int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
- get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
- Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
- x-h/2+1, 0, h, h );
- }
- // If dragging then show the selected as insensitive and the
- // dragged as selected
- else
- {
- int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
- get_style()->paint_arrow(get_window(), Gtk::STATE_INSENSITIVE,
- Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
- x-h/2, 0, h, h );
- x=(int)((float)(dragging_kf_time-bottom) * (w/(top-bottom)) ) ;
- get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
- Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
- x-h/2+1, 0, h, h );
- }
- }
- return true;
-}
-
-
-void
-Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
-{
- kf_list_=x;
- set_selected_keyframe(selected_none);
- selected_=false;
- dragging_=false;
-}
-
-void
-Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
-{
- selected_kf=x;
- selected_=true;
- dragging_kf_time=selected_kf.get_time();
- //signal_keyframe_selected_(selected_kf);
- dragging_=false;
- queue_draw();
-}
-
-bool
-Widget_Keyframe_List::perform_move_kf(bool delta=false)
-{
- if(!selected_)
- return false;
- if(dragging_kf_time == selected_kf.get_time())
- return false; // change this checking if not sticked to integer frames
- Time selected_kf_time(selected_kf.get_time());
- Time prev, next;
- kf_list_->find_prev_next(selected_kf_time, prev, next);
- // Not possible to set delta to the first keyframe
- // perform normal movement
- // As suggested by Zelgadis it is better to not perform anything.
- if (prev==Time::begin() && delta==true)
- {
- synfig::info(_("Not possible to ALT-drag the first keyframe"));
- return false;
- }
- if(!delta)
- {
- synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
- if(!action)
- return false;
- selected_kf.set_time(dragging_kf_time);
- action->set_param("canvas",canvas_interface_->get_canvas());
- action->set_param("canvas_interface",canvas_interface_);
- action->set_param("keyframe",selected_kf);
- try
- {
- canvas_interface_->get_instance()->perform_action(action);
- }
- catch(...)
- {
- return false;
- }
- }
- else
- {
- Keyframe prev_kf(*kf_list_->find_prev(selected_kf_time));
- Time prev_kf_time(prev_kf.get_time());
- if (prev_kf_time >= dragging_kf_time) //Not allowed
- {
- synfig::warning(_("Delta set not allowed"));
- synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::prev_kf_time=%s", delta, prev_kf_time.get_string().c_str());
- synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::dragging_kf_time=%s", delta, dragging_kf_time.get_string().c_str());
- return false;
- }
- else
- {
- Time old_delta_time(selected_kf_time-prev_kf_time);
- Time new_delta_time(dragging_kf_time-prev_kf_time);
- Time change_delta(new_delta_time-old_delta_time);
- synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
- if(!action)
- return false;
- action->set_param("canvas",canvas_interface_->get_canvas());
- action->set_param("canvas_interface",canvas_interface_);
- action->set_param("keyframe",prev_kf);
- action->set_param("delta",change_delta);
- canvas_interface_->get_instance()->perform_action(action);
- }
- }
- queue_draw();
- return true;
-}
-
-bool
-Widget_Keyframe_List::on_event(GdkEvent *event)
-{
- const int x(static_cast<int>(event->button.x));
- //const int y(static_cast<int>(event->button.y));
- //!Boundaries of the drawing area in time units.
- synfig::Time top(adj_timescale->get_upper());
- synfig::Time bottom(adj_timescale->get_lower());
- //!pos is the [0,1] relative horizontal place on the widget
- float pos((float)x/(get_width()));
- if(pos<0.0f)pos=0.0f;
- if(pos>1.0f)pos=1.0f;
- //! The time where the event x is
- synfig::Time t((float)(bottom+pos*(top-bottom)));
- //Do not respond mouse events if the list is empty
- if(!kf_list_->size())
- return true;
-
- //! here the guts of the event
- switch(event->type)
- {
- case GDK_MOTION_NOTIFY:
- if(editable_)
- {
- // here is captured mouse motion
- // AND left or right mouse button pressed
- if (event->motion.state & (GDK_BUTTON1_MASK /*| GDK_BUTTON3_MASK*/))
- {
- // stick to integer frames. It can be optional in the future
- if(fps) t = floor(t*fps + 0.5)/fps;
- dragging_kf_time=t;
- dragging_=true;
- queue_draw();
- return true;
- }
- // here is captured mouse motion
- // AND NOT left or right mouse button pressed
- else
- {
- Glib::ustring ttip="";
- synfig::Time p_t,n_t;
- kf_list_->find_prev_next(t, p_t, n_t);
- if( (p_t==Time::begin() && n_t==Time::end())
- ||
- ((t-p_t)>time_ratio && (n_t-t)>time_ratio)
- )
- {
- ttip = _("Click and drag keyframes");
- }
- else if ((t-p_t)<(n_t-t))
- {
- synfig::Keyframe kf(*kf_list_->find_prev(t));
- synfig::String kf_name(kf.get_description().c_str());
- ttip = kf_name.c_str();
- }
- else
- {
- synfig::Keyframe kf(*kf_list_->find_next(t));
- synfig::String kf_name(kf.get_description().c_str());
- ttip = kf_name.c_str();
- }
- tooltips.set_tip(*this, ttip);
- dragging_=false;
- queue_draw();
- return true;
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- changed_=false;
- dragging_=false;
- if(event->button.button==1 /*|| event->button.button==3*/)
- {
- if(editable_)
- {
- synfig::Time prev_t,next_t;
- kf_list_->find_prev_next(t, prev_t, next_t);
- if( (prev_t==Time::begin() && next_t==Time::end())
- ||
- ((t-prev_t)>time_ratio && (next_t-t)>time_ratio)
- )
- {
- set_selected_keyframe(selected_none);
- selected_=false;
- queue_draw();
- }
- else if ((t-prev_t)<(next_t-t))
- {
- set_selected_keyframe(*(kf_list_->find_prev(t)));
- queue_draw();
- selected_=true;
- }
- else
- {
- set_selected_keyframe(*(kf_list_->find_next(t)));
- queue_draw();
- selected_=true;
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
- break;
- case GDK_BUTTON_RELEASE:
- if(editable_ && (event->button.button==1 /*|| event->button.button==3*/))
- {
- // stick to integer frames.
- if(fps) t = floor(t*fps + 0.5)/fps;
- bool stat=false;
- if(dragging_)
- {
- //if (event->button.button==3)
- if(event->button.state & GDK_MOD1_MASK)
- {
- stat=perform_move_kf(true);
- }
- else
- {
- stat=perform_move_kf(false);
- }
- }
- dragging_=false;
- return stat;
- }
- break;
- default:
- break;
- }
- return false;
-}
-
-
-void Widget_Keyframe_List::set_time_adjustment(Gtk::Adjustment *x)
-{
- //disconnect old connections
- time_value_change.disconnect();
- time_other_change.disconnect();
-
- //connect update function to new adjustment
- adj_timescale = x;
-
- if(x)
- {
- time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
- time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
- }
-}
-
-void
-Widget_Keyframe_List::set_fps(float d)
-{
- if(fps != d)
- {
- fps = d;
- //update everything since we need to redraw already
- queue_draw();
- }
-}
-
-void
-Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
-{
- canvas_interface_=h;
- // Store the values used fomr the canvas interface.
- if (canvas_interface_)
- {
- set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
- set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
- }
-}
-
-
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_keyframe_list.h
-** \brief A custom widget to manage keyframes in the timeline.
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2009 Carlos López
-**
-** 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_WIDGET_KEYFRAME_LIST_H
-#define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/tooltips.h>
-#include <synfig/keyframe.h>
-#include <sigc++/connection.h>
-#include <synfigapp/canvasinterface.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_Keyframe_List : public Gtk::DrawingArea
-{
- //! Tooltips class. It is deprecated since gtkmm 2.12
- //! replace with Tooltip class or use the own tooltip widget's members
- Gtk::Tooltips tooltips;
-
- //! The canvas interface being watched
- etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
- //! Time adjustment window
- Gtk::Adjustment adj_default;
- Gtk::Adjustment *adj_timescale;
-
- //!The list of keyframes to be drawn on the widget and moved with mouse
- synfig::KeyframeList default_kf_list_;
- mutable synfig::KeyframeList* kf_list_;
-
- //! The frames per second of the canvas
- float fps;
-
- //! Time radius to click a keyframe
- synfig::Time time_ratio;
-
- //!True if it is editable. Keyframes can be moved.
- bool editable_;
-
- //!True if a keyframe is being dragged.
- bool dragging_;
-
- //!True if a keyframe has been moved
- bool changed_;
-
- //!Holds the selected keyframe of the keyframe list
- synfig::Keyframe selected_kf;
- synfig::Keyframe selected_none;
- bool selected_;
-
- //!The time of the selected keyframe
- synfig::Time selected_kf_time;
-
- //!The time of the selected keyframe during draging
- synfig::Time dragging_kf_time;
-
- //!Connectors for handling the signals of the time adjustment
- sigc::connection time_value_change;
- sigc::connection time_other_change;
-
-public:
-
- //!Default constructor
- Widget_Keyframe_List();
-
- //!Destructror
- ~Widget_Keyframe_List();
-
- //!Loads a new keyframe list on the widget.
- void set_kf_list(synfig::KeyframeList* x);
-
- //!Member for private data.
- synfig::KeyframeList* get_kf_list()const { return kf_list_; }
-
- //!Member for private data
- void set_editable(bool x=true) { editable_=x; }
-
- //!Member for private data
- bool get_editable()const { return editable_; }
-
-
- //!Store the selected keyframe value
- void set_selected_keyframe(const synfig::Keyframe &x);
-
- //!Returns the selected keyframe
- const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
-
- //! Set the time adjustment and proper connects its change signals
- void set_time_adjustment(Gtk::Adjustment *x);
-
- //! Set the fps
- void set_fps(float x);
-
- //! Set the canvas interface
- void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
-
- //! Performs the keyframe movement. Returns true if it was sucessful
- //! @return true: if success otherwise false
- //! |delta=false: permorm normal move. true: perform delta movement
- bool perform_move_kf(bool delta);
-
-
-
-/* ======================= EVENTS HANDLERS ===========================*/
- //!Redraw event. Should draw all the keyframes + the selected + the dragged
- bool redraw(GdkEventExpose*bleh=NULL);
-
- //!Mouse event handler.
- bool on_event(GdkEvent *event);
-}; // END of class Keyframe_List
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_sound.cpp
-** \brief Widget Sound Implementation 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/adjustment.h>
-
-#include <synfig/general.h>
-#include <ETL/clock>
-
-#include "widget_sound.h"
-#include "audiocontainer.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-//using namespace synfig;
-
-using studio::AudioProfile;
-
-/* === 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 ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-studio::Widget_Sound::Widget_Sound()
-{
-}
-
-studio::Widget_Sound::~Widget_Sound()
-{
-}
-
-void studio::Widget_Sound::set_position(double t)
-{
- //synfig::info("Setting position to %.2lf s", t);
- if(adj_timescale && t != adj_timescale->get_value())
- {
- float upper = adj_timescale->get_upper();
- float lower = adj_timescale->get_lower();
- float framesize = upper - lower;
-
- if(t < lower)
- {
- lower -= ceil((lower-t)/framesize)*framesize;
- upper = lower + framesize;
- adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
- adj_timescale->set_value(t);
- adj_timescale->changed(); adj_timescale->value_changed();
- }else
- if(t > upper)
- {
- lower += ceil((t-upper)/framesize)*framesize;
- upper = lower + framesize;
- adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
- adj_timescale->set_value(t);
- adj_timescale->changed(); adj_timescale->value_changed();
- }else
- {
- adj_timescale->set_value(t);
- adj_timescale->value_changed();
- }
- }
-}
-
-double studio::Widget_Sound::get_position() const
-{
- if(adj_timescale)
- {
- return adj_timescale->get_value();
- }
- return 0;
-}
-
-bool studio::Widget_Sound::set_profile(etl::handle<AudioProfile> p)
-{
- clear();
-
- //set the profile
- audioprof = p;
-
- if(!audioprof)
- {
- clear();
- return false;
- }
-
- return true;
-}
-
-etl::handle<AudioProfile> studio::Widget_Sound::get_profile() const
-{
- return audioprof;
-}
-
-void studio::Widget_Sound::clear()
-{
- audioprof.detach();
-}
-
-void studio::Widget_Sound::draw()
-{
- on_expose_event();
-}
-
-bool studio::Widget_Sound::on_expose_event(GdkEventExpose */*heh*/)
-{
- if(!get_window()) return false;
-
- //clear the background to dark grey
- Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(get_window());
-
- if(!gc) return false;
-
- {
- Gdk::Rectangle r(0,0,get_width(),get_height());
- get_window()->begin_paint_rect(r);
- }
- Gdk::Color c("#3f3f3f");
- gc->set_rgb_fg_color(c);
- gc->set_background(c);
-
- int w = get_width();
- int baseline = get_height()/2;
- get_window()->draw_rectangle(gc,true,0,0,w,get_height());
-
- //set up the color to be blue
- c.set_rgb_p(0,0.5,1);
- gc->set_rgb_fg_color(c);
-
- //draw the base line
- get_window()->draw_line(gc,0,baseline,w,baseline);
-
- //redraw all the samples from begin to end, but only if we have samples to draw (or there is no space to draw)
-
- //synfig::warning("Ok rendered everything, now must render actual sound wave");
- if(!audioprof || !adj_timescale || !w)
- {
- get_window()->end_paint();
- return true;
- }
-
- //draw you fool!
- float framesize = adj_timescale->get_upper() - adj_timescale->get_lower();
- if(framesize)
- {
- float delta=0,cum=0;
-
- //position in sample space
- int begin=0,end=0;
- int cur=0,maxs=0,mins=0;
-
- int i=0; //pixel counter
-
- //etl::clock check; check.reset();
-
- float position = adj_timescale->get_value();
- float samplerate = audioprof->get_samplerate();
- int posi = 0;
- //enforce position inside of frame size
- {
- float offset = audioprof->get_offset();
-
- //clamp begin and end to framesize
- float beginf = adj_timescale->get_lower();
- float endf = adj_timescale->get_upper();
-
- posi = round_to_int((position-beginf)*w/framesize);
- //posi = (int)((position-beginf)*w/framesize);
-
- //calculate in sample space from seconds
- begin = round_to_int((beginf - offset)*samplerate);
- end = round_to_int((endf - offset)*samplerate);
- //begin = (int)((beginf - offset)*samplerate);
- //end = (int)((endf - offset)*samplerate);
- }
-
- delta = (end - begin)/(float)w; //samples per pixel
-
- /*synfig::warning("Rendering a framesize of %f secs from [%d,%d) samples to %d samples, took %f sec",
- framesize, begin, end, w, check());*/
-
- cur = begin;
- i = 0; cum = 0;
- for(int i=0;i<w;++i)
- {
- //get the maximum of the collected samples
- maxs = 0;
- mins = 0;
- for(;cum < delta; ++cum, ++cur)
- {
- maxs = std::max(maxs,(int)(*audioprof)[cur]);
- mins = std::min(mins,(int)(*audioprof)[cur]);
- }
- cum -= delta;
-
- //draw spike if not needed be
- if(maxs||mins)
- {
- int top = maxs * baseline / 64;
- int bot = mins * baseline / 64;
-
- get_window()->draw_line(gc,i,baseline+bot,i,baseline+top);
- }
- }
-
- //synfig::warning("Drawing audio line");
- c.set_rgb_p(1,0,0);
- gc->set_rgb_fg_color(c);
- get_window()->draw_line(gc,posi,0,posi,get_height());
- }
- get_window()->end_paint();
-
- return true;
-}
-
-//--- Handle the single clicking and dragging for scrubbing
-
-bool studio::Widget_Sound::on_motion_notify_event(GdkEventMotion* event)
-{
- Gdk::ModifierType mod = Gdk::ModifierType(event->state);
-
- //if we are scrubbing
- if(mod & Gdk::BUTTON1_MASK)
- {
- //Can't do this if we don't have a time frame (heheh...)
- if(!adj_timescale) return false;
-
- double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
-
- //find event position in time
- double t = beg + event->x * (end-beg) / get_width();
-
- //signal that we are scrubbing to this new value...
- signal_scrub()(t);
-
-
- // We should be able to just call
- // Widget_Timeslider::on_motion_notify_event(),
- // but that seems to cause the program to halt
- // for some reason. So for now, let's do the job ourselves
- //adj_timescale->set_value(t);
- //adj_timescale->changed();
- //return true;
- }
-
- return Widget_Timeslider::on_motion_notify_event(event);
-}
-
-bool studio::Widget_Sound::on_button_press_event(GdkEventButton *event)
-{
- //Assume button PRESS
-
- //if we are starting... using left click
- if(event->button == 1)
- {
- if(!adj_timescale) return false;
-
- double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
-
- //find event position in time
- double t = beg + event->x * (end-beg) / get_width();
-
- //signal the attached scrubbing devices...
- signal_start_scrubbing()(t);
-
- return true;
- }
-
- return Widget_Timeslider::on_button_press_event(event);
-}
-
-bool studio::Widget_Sound::on_button_release_event(GdkEventButton *event)
-{
- //Assume button RELEASE
-
- //if we are ending... using left click
- if(event->button == 1)
- {
- //signal the scrubbing device... to stop
- signal_stop_scrubbing()();
-
- return true;
- }
-
- return Widget_Timeslider::on_button_release_event(event);
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_sound.h
-** \brief Widget Sound 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_WIDGET_SOUND_H
-#define __SYNFIG_WIDGET_SOUND_H
-
-/* === H E A D E R S ======================================================= */
-#include <ETL/handle>
-
-#include <gtkmm/drawingarea.h>
-
-#include "widget_timeslider.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 AudioProfile;
-class AudioContainer;
-
-/* What can widget sound do?
- Options:
- 1. Just draw the sound
- 2. Scroll time and draw the sound
- 3. Play, stop, and scrub the sound... (full interaction...)
- 4. Provide hooks for scrubbing to work... (and possibly play and stop in the future)
-
- Going with 4 for now...
-*/
-class Widget_Sound : public Widget_Timeslider
-{
- etl::handle<AudioProfile> audioprof;
-
- //event override interface
- virtual bool on_expose_event(GdkEventExpose *heh = 0);
-
- //for scrubbing... (click is start, drag is scrub, and release is stop...)
- virtual bool on_motion_notify_event(GdkEventMotion* event);
- virtual bool on_button_press_event(GdkEventButton *event);
- virtual bool on_button_release_event(GdkEventButton *event);
-
- //Might want a signal setup for scrubbing... and here it is
- sigc::signal1<void,double> signal_start_scrubbing_;
- sigc::signal1<void,double> signal_scrub_;
- sigc::signal0<void> signal_stop_scrubbing_;
-
-public: //structors
- Widget_Sound();
- ~Widget_Sound();
-
-public: //accessors
- bool set_profile(etl::handle<AudioProfile> p);
- etl::handle<AudioProfile> get_profile() const;
-
- //for signal interface
- sigc::signal1<void,double> & signal_start_scrubbing() {return signal_start_scrubbing_;}
- sigc::signal1<void,double> & signal_scrub() {return signal_scrub_;}
- sigc::signal0<void> & signal_stop_scrubbing() {return signal_stop_scrubbing_;}
-
-public: //get set interface
- void set_position(double t);
- double get_position() const;
-
-public: //interface
- void draw();
-
- void clear();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_time.cpp
-** \brief Template File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2008 Chris Moore
-** Copyright (c) 2008 Paul Wise
-**
-** 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 "widget_time.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 ======================================================= */
-
-Widget_Time::Widget_Time():
- fps_(0),
- time_(0)
-{
- signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
- signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
-}
-
-Widget_Time::~Widget_Time()
-{
-}
-
-void
-Widget_Time::refresh_text()
-{
- set_text(time_.get_string(fps_,App::get_time_format()));
-}
-
-
-void
-Widget_Time::set_value(const synfig::Time &data)
-{
- time_=data;
- refresh_text();
-}
-
-synfig::Time
-Widget_Time::get_value() const
-{
- return time_;
-}
-
-void
-Widget_Time::set_fps(float x)
-{
- fps_=Time(x);
- refresh_text();
-}
-
-void
-Widget_Time::refresh_value()
-{
- try
- {
- Time newtime(get_text(),fps_);
- if(abs(newtime-time_)>=0.001)
- {
- time_=newtime;
- refresh_text();
- signal_value_changed()();
- }
- }
- catch(...)
- {
- throw string("Caught unknown exception");
- }
-}
-
-bool
-Widget_Time::on_event(GdkEvent* event)
-{
- const Time scroll_amount(0.25);
-
- switch(event->type)
- {
- case GDK_SCROLL:
- if(event->scroll.direction==GDK_SCROLL_DOWN || event->scroll.direction==GDK_SCROLL_LEFT)
- {
- time_-=scroll_amount;
- refresh_text();
- signal_value_changed()();
- }
- else if(event->scroll.direction==GDK_SCROLL_UP || event->scroll.direction==GDK_SCROLL_RIGHT)
- {
- time_+=scroll_amount;
- refresh_text();
- signal_value_changed()();
- }
- return true;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- if (!has_focus())
- grab_focus();
- break;
- default:
- break;
- }
-
- return Gtk::Entry::on_event(event);
-}
-
-bool
-Widget_Time::on_focus_out_event(GdkEventFocus* event)
-{
- refresh_value();
- refresh_text();
- return Gtk::Entry::on_focus_out_event(event);
-}
-
-bool
-Widget_Time::on_focus_in_event(GdkEventFocus* event)
-{
- // if defined, show the full time format "0h 0m 5s 0f" when the time widget gets focus
- if (getenv("SYNFIG_SHOW_FULL_TIME_ON_FOCUS"))
- set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
-
- return Gtk::Entry::on_focus_in_event(event);
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_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_WIDGET_TIME_H
-#define __SYNFIG_STUDIO_WIDGET_TIME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/entry.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 Widget_Time : public Gtk::Entry
-{
-
-
- sigc::signal<void> signal_value_changed_;
-
- float fps_;
-
- synfig::Time time_;
-
-protected:
- bool on_focus_out_event(GdkEventFocus* event);
-
- bool on_focus_in_event(GdkEventFocus* event);
-
- //void on_activate();
-
- void refresh_text();
-
- void refresh_value();
-
- bool on_event(GdkEvent* event);
-
-public:
- sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
-
-
- void set_value(const synfig::Time &data);
- synfig::Time get_value()const;
- void set_fps(float x);
- Widget_Time();
- ~Widget_Time();
-}; // END of class Widget_Time
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_timeslider.cpp
-** \brief Time Slider Widget Implementation File
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2004 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 "widget_timeslider.h"
-
-#include <ETL/misc>
-
-#include <cmath>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-using studio::Widget_Timeslider;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-const double zoominfactor = 0.75;
-const double zoomoutfactor = 1/zoominfactor;
-
-/* === P R O C E D U R E S ================================================= */
-
-Gdk::Color get_interp_color(synfig::Interpolation x)
-{
- switch(x)
- {
- case INTERPOLATION_TCB:
- return Gdk::Color("#00B000");
-
- break;
-
- case INTERPOLATION_LINEAR:
- return Gdk::Color("#B0B000");
- break;
-
- case INTERPOLATION_CONSTANT:
- return Gdk::Color("#C70000");
- break;
-
- case INTERPOLATION_HALT:
- return Gdk::Color("#00b0b0");
- break;
-
- case INTERPOLATION_MANUAL:
- return Gdk::Color("#B000B0");
- break;
-
- case INTERPOLATION_UNDEFINED: default:
- return Gdk::Color("#808080");
- break;
- }
-}
-
-static Gdk::Color
-color_darken(Gdk::Color x, float amount)
-{
- double red = x.get_red_p() * amount;
- double green = x.get_green_p() * amount;
- double blue = x.get_blue_p() * amount;
-
- x.set_rgb_p( red > 1 ? 1 : red,
- green > 1 ? 1 : green,
- blue > 1 ? 1 : blue);
-
- return x;
-}
-
-void
-studio::render_time_point_to_window(
- const Glib::RefPtr<Gdk::Drawable>& window,
- const Gdk::Rectangle& area,
- const synfig::TimePoint &tp,
- bool selected
-)
-{
- Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
- const Gdk::Color black("#000000");
-
- if(selected)
- gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
- else
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
- Gdk::Color color;
- std::vector<Gdk::Point> points;
-
-/*- BEFORE ------------------------------------- */
-
- color=get_interp_color(tp.get_before());
- color=color_darken(color,1.0f);
- if(selected)color=color_darken(color,1.3f);
- gc->set_rgb_fg_color(color);
-
- switch(tp.get_before())
- {
- case INTERPOLATION_TCB:
- window->draw_arc(
- gc,
- true,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height(),
- 64*90,
- 64*180
- );
- gc->set_rgb_fg_color(black);
- window->draw_arc(
- gc,
- false,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height(),
- 64*90,
- 64*180
- );
- break;
-
- case INTERPOLATION_HALT:
- window->draw_arc(
- gc,
- true,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height()*2,
- 64*90,
- 64*90
- );
- gc->set_rgb_fg_color(black);
- window->draw_arc(
- gc,
- false,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height()*2,
- 64*90,
- 64*90
- );
- break;
-
- case INTERPOLATION_LINEAR:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
-
- case INTERPOLATION_CONSTANT:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()+area.get_height()/2));
- points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
- points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
-
- case INTERPOLATION_UNDEFINED: default:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()));
- points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3));
- points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
- }
-
-/*- AFTER -------------------------------------- */
-
- color=get_interp_color(tp.get_after());
- color=color_darken(color,0.8f);
- if(selected)color=color_darken(color,1.3f);
- gc->set_rgb_fg_color(color);
-
- switch(tp.get_after())
- {
- case INTERPOLATION_TCB:
- window->draw_arc(
- gc,
- true,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height(),
- 64*270,
- 64*180
- );
- gc->set_rgb_fg_color(black);
- window->draw_arc(
- gc,
- false,
- area.get_x(),
- area.get_y(),
- area.get_width(),
- area.get_height(),
- 64*270,
- 64*180
- );
- break;
-
- case INTERPOLATION_HALT:
- window->draw_arc(
- gc,
- true,
- area.get_x(),
- area.get_y()-area.get_height(),
- area.get_width(),
- area.get_height()*2,
- 64*270,
- 64*90
- );
- gc->set_rgb_fg_color(black);
- window->draw_arc(
- gc,
- false,
- area.get_x(),
- area.get_y()-area.get_height(),
- area.get_width(),
- area.get_height()*2,
- 64*270,
- 64*90
- );
- break;
-
- case INTERPOLATION_LINEAR:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
-
- case INTERPOLATION_CONSTANT:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
-
- case INTERPOLATION_UNDEFINED: default:
- points.clear();
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3));
- points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height()));
- points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
- window->draw_polygon(gc,true,points);
- gc->set_rgb_fg_color(black);
- window->draw_lines(gc,points);
- break;
- }
-
-}
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-double defaultfps = 24;
-const int fullheight = 20;
-
-Widget_Timeslider::Widget_Timeslider()
-:layout(Pango::Layout::create(get_pango_context())),
-adj_default(0,0,2,1/defaultfps,10/defaultfps),
-adj_timescale(0),
-//invalidated(false),
-last_event_time(0),
-fps(defaultfps),
-dragscroll(false)
-{
- set_size_request(-1,fullheight);
-
- // click scroll zoom
- add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
- | Gdk::BUTTON_MOTION_MASK | Gdk::SCROLL_MASK );
-
- set_time_adjustment(&adj_default);
- //update_times();
-}
-
-Widget_Timeslider::~Widget_Timeslider()
-{
-}
-
-void Widget_Timeslider::set_time_adjustment(Gtk::Adjustment *x)
-{
- //disconnect old connections
- time_value_change.disconnect();
- time_other_change.disconnect();
-
- //connect update function to new adjustment
- adj_timescale = x;
-
- if(x)
- {
- time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
- time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
- //invalidated = true;
- //refresh();
- }
-}
-
-void Widget_Timeslider::set_global_fps(float d)
-{
- if(fps != d)
- {
- fps = d;
-
- //update everything since we need to redraw already
- //invalidated = true;
- //refresh();
- queue_draw();
- }
-}
-
-/*void Widget_Timeslider::update_times()
-{
- if(adj_timescale)
- {
- start = adj_timescale->get_lower();
- end = adj_timescale->get_upper();
- current = adj_timescale->get_value();
- }
-}*/
-
-void Widget_Timeslider::refresh()
-{
-}
-/*
-{
- if(invalidated)
- {
- queue_draw();
- }else if(adj_timescale)
- {
- double l = adj_timescale->get_lower(),
- u = adj_timescale->get_upper(),
- v = adj_timescale->get_value();
-
- bool invalid = (l != start) || (u != end) || (v != current);
-
- start = l;
- end = u;
- current = v;
-
- if(invalid) queue_draw();
- }
-}*/
-
-bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
-{
- Glib::RefPtr<Gdk::Window> window = get_window();
-
- if(!window) return false;
-
- Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);
- if(!gc) return false;
-
- //synfig::info("Drawing Timeslider");
- //clear and update to current values
- //invalidated = false;
- //update_times();
-
- //draw grey rectangle
- Gdk::Color c("#7f7f7f");
- gc->set_rgb_fg_color(c);
- gc->set_background(c);
-
- //Get the data for the window and the params to draw it...
- int w = get_width(), h = get_height();
-
- window->draw_rectangle(gc,true,0,0,w,h);
-
- const double EPSILON = 1e-6;
- if(!adj_timescale || w == 0) return true;
-
- //Get the time information since we now know it's valid
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper(),
- current = adj_timescale->get_value();
-
- if(end-start < EPSILON) return true;
-
- //synfig::info("Drawing Lines");
-
- //draw all the time stuff
- double dtdp = (end - start)/get_width();
- double dpdt = 1/dtdp;
-
- //lines
-
- //Draw the time line...
- double tpx = (current-start)*dpdt;
- gc->set_rgb_fg_color(Gdk::Color("#ffaf00"));
- window->draw_line(gc,round_to_int(tpx),0,round_to_int(tpx),fullheight);
-
- //normal line/text color
- gc->set_rgb_fg_color(Gdk::Color("#333333"));
-
- int ifps = round_to_int(fps);
- if (ifps < 1) ifps = 1;
-
- std::vector<double> ranges;
-
- unsigned int pos = 0;
-
- // build a list of all the factors of the frame rate
- for (int i = 1; i*i <= ifps; i++)
- if ((ifps%i) == 0)
- {
- ranges.insert(ranges.begin()+pos, i/fps);
- if (i*i != ifps)
- ranges.insert(ranges.begin()+pos+1, ifps/i/fps);
- pos++;
- }
-
- // fill in any gaps where one factor is more than 2 times the previous
- std::vector<double>::iterator iter, next;
- pos = 0;
- for (pos = 0; pos < ranges.size()-1; pos++)
- {
- iter = ranges.begin()+pos;
- next = iter+1;
- if (*iter*2 < *next)
- ranges.insert(next, *iter*2);
- }
-
- double more_ranges[] = {
- 2, 3, 5, 10, 20, 30, 60, 90, 120, 180,
- 300, 600, 1200, 1800, 2700, 3600, 3600*2,
- 3600*4, 3600*8, 3600*16, 3600*32, 3600*64,
- 3600*128, 3600*256, 3600*512, 3600*1024 };
-
- ranges.insert(ranges.end(), more_ranges, more_ranges + sizeof(more_ranges)/sizeof(double));
-
- double lowerrange = dtdp*140, upperrange = dtdp*280;
- double midrange = (lowerrange + upperrange)/2;
-
- //find most ideal scale
- double scale;
- next = binary_find(ranges.begin(), ranges.end(), midrange);
- iter = next++;
-
- if (iter == ranges.end()) iter--;
- if (next == ranges.end()) next--;
-
- if (abs(*next - midrange) < abs(*iter - midrange))
- iter = next;
-
- scale = *iter;
-
- // subdivide into this many tick marks (8 or less)
- int subdiv = round_to_int(scale * ifps);
-
- if (subdiv > 8)
- {
- const int ideal = subdiv;
-
- // find a number of tick marks that nicely divides the scale
- // (5 minutes divided by 6 is 50s, but that's not 'nice' -
- // 5 ticks of 1m each is much simpler than 6 ticks of 50s)
- for (subdiv = 8; subdiv > 0; subdiv--)
- if ((ideal <= ifps*2 && (ideal % (subdiv )) == 0) ||
- (ideal <= ifps*2*60 && (ideal % (subdiv*ifps )) == 0) ||
- (ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60 )) == 0) ||
- (true && (ideal % (subdiv*ifps*60*60)) == 0))
- break;
-
- // if we didn't find anything, use 4 ticks
- if (!subdiv)
- subdiv = 4;
- }
-
- time_per_tickmark = scale / subdiv;
-
- //get first valid line and its position in pixel space
- double time = 0;
- double pixel = 0;
-
- int sdindex = 0;
-
- double subr = scale / subdiv;
-
- //get its position inside...
- time = ceil(start/subr)*subr - start;
- pixel = time*dpdt;
-
- //absolute time of the line to be drawn
- time += start;
-
- { //inside the big'n
- double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1
- //sdindex = (int)floor(t + 0.5); //get how far through the range it is...
- sdindex = round_to_int(t); //get how far through the range it is...
- if (sdindex == subdiv) sdindex = 0;
-
- //synfig::info("Extracted fr %.2lf -> %d", t, sdindex);
- }
-
- //synfig::info("Initial values: %.4lf t, %.1lf pixels, %d i", time,pixel,sdindex);
-
- //loop to draw
- const int heightbig = 12;
- const int heightsmall = 4;
-
- int width = get_width();
- while( pixel < width )
- {
- int xpx = round_to_int(pixel);
-
- //draw big
- if(sdindex == 0)
- {
- window->draw_line(gc,xpx,0,xpx,heightbig);
- //round the time to nearest frame and draw the text
- Time tm((double)time);
- if(get_global_fps()) tm.round(get_global_fps());
- Glib::ustring timecode(tm.get_string(get_global_fps(),App::get_time_format()));
-
- //gc->set_rgb_fg_color(Gdk::Color("#000000"));
- layout->set_text(timecode);
- Pango::AttrList attr_list;
- // Aproximately a font size of 8 pixels.
- // Pango::SCALE = 1024
- // create_attr_size waits a number in 1000th of pixels.
- // Should be user customizable in the future. Now it is fixed to 10
- Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
- pango_size.set_start_index(0);
- pango_size.set_end_index(64);
- attr_list.change(pango_size);
- layout->set_attributes(attr_list);
- window->draw_layout(gc,xpx+2,0,layout);
- }else
- {
- window->draw_line(gc,xpx,0,xpx,heightsmall);
- }
-
- //increment time and position
- pixel += subr / dtdp;
- time += subr;
-
- //increment index
- if(++sdindex >= subdiv) sdindex -= subdiv;
- }
-
- return true;
-}
-
-bool Widget_Timeslider::on_motion_notify_event(GdkEventMotion* event) //for dragging
-{
- if(!adj_timescale) return false;
-
- Gdk::ModifierType mod = Gdk::ModifierType(event->state);
-
- //scrolling...
-
- //NOTE: we might want to address the possibility of dragging with both buttons held down
-
- if(mod & Gdk::BUTTON2_MASK)
- {
-
- //we need this for scrolling by dragging
- double curx = event->x;
-
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper();
-
- if(dragscroll)
- {
- if(event->time-last_event_time<30)
- return false;
- else
- last_event_time=event->time;
-
- if(abs(lastx - curx) < 1 && end != start) return true;
- //translate the window and correct it
-
- //update our stuff so we are operating correctly
- //invalidated = true;
- //update_times();
-
- //Note: Use inverse of mouse movement because of conceptual space relationship
- double diff = lastx - curx; //curx - lastx;
-
- //NOTE: This might be incorrect...
- //fraction to move...
- double dpx = (end - start)/get_width();
- lastx = curx;
-
- diff *= dpx;
-
- //Adjust...
- start += diff;
- end += diff;
-
- //But clamp to bounds if they exist...
- //HACK - bounds should not be required for this slider
- if(adj_bounds)
- {
- if(start < adj_bounds->get_lower())
- {
- diff = adj_bounds->get_lower() - start;
- start += diff;
- end += diff;
- }
-
- if(end > adj_bounds->get_upper())
- {
- diff = adj_bounds->get_upper() - end;
- start += diff;
- end += diff;
- }
- }
-
- //synfig::info("Scrolling timerange to (%.4f,%.4f)",start,end);
-
- adj_timescale->set_lower(start);
- adj_timescale->set_upper(end);
-
- adj_timescale->changed();
- }else
- {
- dragscroll = true;
- lastx = curx;
- //lasty = cury;
- }
-
- return true;
- }
-
- if(mod & Gdk::BUTTON1_MASK)
- {
- double curx = event->x;
-
- //get time from drag...
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper(),
- current = adj_timescale->get_value();
- double t = start + curx*(end - start)/get_width();
-
- //snap it to fps - if they exist...
- if(fps)
- {
- t = floor(t*fps + 0.5)/fps;
- }
-
- //set time if needed
- if(current != t)
- {
- adj_timescale->set_value(t);
-
- //Fixed this to actually do what it's supposed to...
- if(event->time-last_event_time>50)
- {
- adj_timescale->value_changed();
- last_event_time = event->time;
- }
- }
-
- return true;
- }
-
- return false;
-}
-
-bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming
-{
- if(!adj_timescale) return false;
-
- //Update so we are calculating based on current values
- //update_times();
-
- //figure out if we should center ourselves on the current time
- bool center = false;
-
- //we want to zoom in on the time value if control is held down
- if(Gdk::ModifierType(event->state) & Gdk::CONTROL_MASK)
- center = true;
-
- switch(event->direction)
- {
- case GDK_SCROLL_UP: //zoom in
- zoom_in(center);
- return true;
-
- case GDK_SCROLL_DOWN: //zoom out
- zoom_out(center);
- return true;
-
- case GDK_SCROLL_RIGHT:
- case GDK_SCROLL_LEFT:
- {
- double t = adj_timescale->get_value();
- double orig_t = t;
- double start = adj_timescale->get_lower();
- double end = adj_timescale->get_upper();
- double lower = adj_bounds->get_lower();
- double upper = adj_bounds->get_upper();
- double adj = time_per_tickmark;
-
- if( event->direction == GDK_SCROLL_RIGHT )
- {
- // step forward one tick
- t += adj;
-
- // don't go past the end of time
- if (t > upper)
- t = upper;
-
- // if we are already in the right half of the slider
- if ((t-start)*2 > (end-start))
- {
- // if we can't scroll the background left one whole tick, scroll it to the end
- if (end > upper - (t-orig_t))
- {
- adj_timescale->set_lower(upper - (end-start));
- adj_timescale->set_upper(upper);
- }
- // else scroll the background left
- else
- {
- adj_timescale->set_lower(start + (t-orig_t));
- adj_timescale->set_upper(start + (t-orig_t) + (end-start));
- }
- }
- }
- else
- {
- // step backwards one tick
- t -= adj;
-
- // don't go past the start of time
- if (t < lower)
- t = lower;
-
- // if we are already in the left half of the slider
- if ((t-start)*2 < (end-start))
- {
- // if we can't scroll the background right one whole tick, scroll it to the beginning
- if (start < lower + (orig_t-t))
- {
- adj_timescale->set_lower(lower);
- adj_timescale->set_upper(lower + (end-start));
- }
- // else scroll the background right
- else
- {
- adj_timescale->set_lower(start - (orig_t-t));
- adj_timescale->set_upper(start - (orig_t-t) + (end-start));
- }
- }
- }
-
- if(adj_timescale)
- {
- adj_timescale->set_value(t);
- adj_timescale->value_changed();
- }
- return true;
- }
- default:
- return false;
- }
-}
-
-void Widget_Timeslider::zoom_in(bool centerontime)
-{
- if(!adj_timescale) return;
-
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper(),
- current = adj_timescale->get_value();
-
- double focuspoint = centerontime ? current : (start + end)/2;
-
- //calculate new beginning and end
- end = focuspoint + (end-focuspoint)*zoominfactor;
- start = focuspoint + (start-focuspoint)*zoominfactor;
-
- //synfig::info("Zooming in timerange to (%.4f,%.4f)",start,end);
- if(adj_bounds)
- {
- if(start < adj_bounds->get_lower())
- {
- start = adj_bounds->get_lower();
- }
-
- if(end > adj_bounds->get_upper())
- {
- end = adj_bounds->get_upper();
- }
- }
-
- //reset values
- adj_timescale->set_lower(start);
- adj_timescale->set_upper(end);
-
- //call changed function
- adj_timescale->changed();
-}
-
-void Widget_Timeslider::zoom_out(bool centerontime)
-{
- if(!adj_timescale) return;
-
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper(),
- current = adj_timescale->get_value();
-
- double focuspoint = centerontime ? current : (start + end)/2;
-
- //calculate new beginning and end
- end = focuspoint + (end-focuspoint)*zoomoutfactor;
- start = focuspoint + (start-focuspoint)*zoomoutfactor;
-
- //synfig::info("Zooming out timerange to (%.4f,%.4f)",start,end);
- if(adj_bounds)
- {
- if(start < adj_bounds->get_lower())
- {
- start = adj_bounds->get_lower();
- }
-
- if(end > adj_bounds->get_upper())
- {
- end = adj_bounds->get_upper();
- }
- }
-
- //reset values
- adj_timescale->set_lower(start);
- adj_timescale->set_upper(end);
-
- //call changed function
- adj_timescale->changed();
-}
-
-bool Widget_Timeslider::on_button_press_event(GdkEventButton *event) //for clicking
-{
- switch(event->button)
- {
- //time click...
- case 1:
- {
- double start = adj_timescale->get_lower(),
- end = adj_timescale->get_upper(),
- current = adj_timescale->get_value();
-
- double w = get_width();
- double t = start + (end - start) * event->x / w;
-
- t = floor(t*fps + 0.5)/fps;
-
- /*synfig::info("Clicking time from %.3lf to %.3lf [(%.2lf,%.2lf) %.2lf / %.2lf ... %.2lf",
- current, vt, start, end, event->x, w, fps);*/
-
- if(t != current)
- {
- current = t;
-
- if(adj_timescale)
- {
- adj_timescale->set_value(current);
- adj_timescale->value_changed();
- }
- }
-
- break;
- }
-
- //scroll click
- case 2:
- {
- //start dragging
- dragscroll = true;
- lastx = event->x;
- //lasty = event->y;
-
- return true;
- }
-
- default:
- {
- break;
- }
- }
-
- return false;
-}
-
-bool Widget_Timeslider::on_button_release_event(GdkEventButton *event) //end drag
-{
- switch(event->button)
- {
- case 2:
- {
- //start dragging
- dragscroll = false;
- return true;
- }
-
- default:
- {
- break;
- }
- }
-
- return false;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_timeslider.h
-** \brief Time Slider Widget Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2004 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_WIDGET_TIMESLIDER_H
-#define __SYNFIG_WIDGET_TIMESLIDER_H
-
-/* === H E A D E R S ======================================================= */
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/adjustment.h>
-
-#include <synfig/time.h>
-#include "canvasview.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 {
-
-void render_time_point_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::TimePoint &tp,bool selected=false);
-
-
-/* Design for the timeslider...
-
- Concept: Scalable ruler
- Ticks are done every so often (30 s, 10 frames, 5 frames, etc.)
- Print out frame numbers next to the big ticks
- Show blue pills in separate area (above or below)
-*/
-
-class Widget_Timeslider : public Gtk::DrawingArea
-{
-protected: //implementation that other interfaces can see
- Glib::RefPtr<Pango::Layout> layout; //implementation awesomeness for text drawing
-
- Gtk::Adjustment adj_default;
- Gtk::Adjustment *adj_timescale;
-
- //HACK - I should not have to see this...
- Gtk::Adjustment *adj_bounds;
- double time_per_tickmark;
-
- //Statistics used for drawing stuff (and making sure we don't if we don't need to)
- /*double start,end;
- double current;
-
- bool invalidated;*/
-
- guint32 last_event_time;
-
- float fps;
-
- sigc::connection time_value_change;
- sigc::connection time_other_change;
-
- //TODO: fill out blue pill stuff
-
- //input functions
-
- virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
- virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
- virtual bool on_button_press_event(GdkEventButton *event); //for clicking
- virtual bool on_button_release_event(GdkEventButton *event); //for clicking
-
- virtual bool on_expose_event(GdkEventExpose */*event*/) {redraw(); return true;}//for drawing
-
- virtual bool redraw(bool doublebuffer = false);
-
- //void update_times();
-
- void zoom_in(bool centerontime = false);
- void zoom_out(bool centerontime = false);
-
- //Drag the Frame
- bool dragscroll;
-
- /*NOTE: if we can set the mouse position to the original position
- this would only have to be set once (and it would be good otherwise too)
- */
- double lastx; //last mouse position for dragging
-
-public: //structors
- Widget_Timeslider();
- ~Widget_Timeslider();
-
-public: //Normal Interface
-
- void draw() {redraw();}
- virtual void refresh(); //reget bluepills, time values and queue_draw if need be
-
-public: //Time Interface
-
- //Run FPS stuff through it to the MAX
- double get_global_fps() const {return fps;}
- void set_global_fps(float d);
-
- //accessors for the time adjustment
- Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
- void set_time_adjustment(Gtk::Adjustment *x);
-
- //HACK - I should not have to see these bounds (should be boundless)
- Gtk::Adjustment &get_bounds_adjustment() const {return *adj_bounds;}
- void set_bounds_adjustment(Gtk::Adjustment *x) {adj_bounds = x;}
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_value.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/label.h>
-#include "widget_value.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 "widget_vector.h"
-#include "widget_filename.h"
-#include "widget_enum.h"
-#include "widget_coloredit.h"
-#include "widget_canvaschooser.h"
-#include "widget_time.h"
-#include "app.h"
-#include "widget_distance.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_ValueBase::Widget_ValueBase():
- Glib::ObjectBase (typeid(Widget_ValueBase)),
- Gtk::HBox(),
- real_adjustment(0,-2000000000,2000000000,0.05,0.05,0),
- integer_adjustment(0,-2000000000,2000000000,1,1,0),
- angle_adjustment(0,-2000000000,2000000000,1,1,0)
-{
- set_no_show_all();
-
- label=manage(new class Gtk::Label("Unknown Datatype"));
- pack_start(*label);
- label->show();
-
- vector_widget=manage(new class Widget_Vector());
- pack_start(*vector_widget);
-
- color_widget=manage(new class Widget_ColorEdit());
- pack_start(*color_widget);
-
- enum_widget=manage(new class Widget_Enum());
- pack_start(*enum_widget);
-
- real_widget=manage(new class Gtk::SpinButton(real_adjustment,0.05,DIGITS));
- pack_start(*real_widget);
-
- integer_widget=manage(new class Gtk::SpinButton(integer_adjustment,1,0));
- pack_start(*integer_widget);
-
- angle_widget=manage(new class Gtk::SpinButton(angle_adjustment,15,2));
- pack_start(*angle_widget);
-
- bool_widget=manage(new class Gtk::CheckButton());
- pack_start(*bool_widget);
-
- //color_widget=manage(new class Gtk::ColorSelection());
- //pack_start(*color_widget);
-
- string_widget=manage(new class Gtk::Entry());
- pack_start(*string_widget);
-
- canvas_widget=manage(new class Widget_CanvasChooser());
- pack_start(*canvas_widget);
-
- filename_widget=manage(new class Widget_Filename());
- pack_start(*filename_widget);
-
- time_widget=manage(new class Widget_Time());
- pack_start(*time_widget);
-
- distance_widget=manage(new class Widget_Distance());
- pack_start(*distance_widget);
-
-
- vector_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- color_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- enum_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- real_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- integer_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- angle_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- string_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- canvas_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- filename_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- time_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
- distance_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-
- /*signal_focus_in_event().connect(
- sigc::bind_return(
- sigc::hide(
- sigc::mem_fun(*this,&Widget_ValueBase::grab_focus)
- ),false
- )
- );*/
-}
-
-Widget_ValueBase::~Widget_ValueBase()
-{
-}
-
-void
-Widget_ValueBase::activate()
-{
- signal_activate()();
-}
-
-void
-Widget_ValueBase::inside_cellrenderer()
-{
- string_widget->set_has_frame(false);
- string_widget->gobj()->is_cell_renderer = true; // XXX
-
- real_widget->set_has_frame(false);
- //static_cast<Gtk::Entry*>(real_widget)->gobj()->is_cell_renderer = true; // XXX
-
- distance_widget->set_has_frame(false);
- //static_cast<Gtk::Entry*>(distance_widget)->gobj()->is_cell_renderer = true; // XXX
-
- integer_widget->set_has_frame(false);
- //static_cast<Gtk::Entry*>(integer_widget)->gobj()->is_cell_renderer = true; // XXX
- vector_widget->set_has_frame(false);
- //vector_widget->set_digits(10);
-
- color_widget->set_has_frame(false);
- //color_widget->set_digits(10);
- filename_widget->set_has_frame(false);
- time_widget->set_has_frame(false);
-}
-
-void
-Widget_ValueBase::set_sensitive(bool x)
-{
- Gtk::HBox::set_sensitive(x);
- label->set_sensitive(x);
- vector_widget->set_sensitive(x);
- real_widget->set_sensitive(x);
- integer_widget->set_sensitive(x);
- bool_widget->set_sensitive(x);
- color_widget->set_sensitive(x);
- string_widget->set_sensitive(x);
- canvas_widget->set_sensitive(x);
- enum_widget->set_sensitive(x);
- angle_widget->set_sensitive(x);
- filename_widget->set_sensitive(x);
- time_widget->set_sensitive(x);
- distance_widget->set_sensitive(x);
-}
-
-void
-Widget_ValueBase::set_value(const synfig::ValueBase &data)
-{
- label->hide();
- vector_widget->hide();
- real_widget->hide();
- integer_widget->hide();
- bool_widget->hide();
- color_widget->hide();
- string_widget->hide();
- canvas_widget->hide();
- enum_widget->hide();
- angle_widget->hide();
- filename_widget->hide();
- time_widget->hide();
- distance_widget->hide();
-
- value=data;
- try{
- switch(value.get_type())
- {
- case ValueBase::TYPE_VECTOR:
- vector_widget->set_canvas(canvas);
- vector_widget->set_value(value.get(Vector()));
- vector_widget->show();
- break;
- case ValueBase::TYPE_REAL:
- if(param_desc.get_is_distance() && canvas)
- {
- Distance dist(value.get(Real()),Distance::SYSTEM_UNITS);
- dist.convert(App::distance_system,canvas->rend_desc());
- distance_widget->set_value(dist);
- distance_widget->show();
- }
- else
- {
- real_widget->set_value(value.get(Real()));
- real_widget->show();
- }
- break;
- case ValueBase::TYPE_TIME:
- if(canvas)time_widget->set_fps(canvas->rend_desc().get_frame_rate());
- time_widget->set_value(value.get(Time()));
- time_widget->show();
- break;
- case ValueBase::TYPE_ANGLE:
- angle_widget->set_value(Angle::deg(value.get(Angle())).get());
- angle_widget->show();
- break;
- case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
- {
- integer_widget->set_value(value.get(int()));
- integer_widget->show();
- }
- else
- {
- enum_widget->set_param_desc(param_desc);
- enum_widget->set_value(value.get(int()));
- enum_widget->show();
- }
- break;
- case ValueBase::TYPE_CANVAS:
- assert(canvas);
- canvas_widget->set_parent_canvas(canvas);
- canvas_widget->set_value(value.get(etl::loose_handle<synfig::Canvas>()));
- canvas_widget->show();
- break;
- case ValueBase::TYPE_BOOL:
- bool_widget->set_active(value.get(bool()));
- bool_widget->show();
- break;
- case ValueBase::TYPE_STRING:
- if(param_desc.get_hint()!="filename")
- {
- string_widget->set_text(value.get(string()));
- string_widget->show();
- }
- else
- {
- filename_widget->set_value(value.get(string()));
- filename_widget->show();
- }
- break;
- case ValueBase::TYPE_COLOR:
- {
- color_widget->set_value(value.get(synfig::Color()));
- color_widget->show();
-/*
- Gdk::Color gdkcolor;
- synfig::Color color=value.get(synfig::Color());
- gdkcolor.set_rgb_p(color.get_r(),color.get_g(),color.get_b());
- color_widget->set_current_color(gdkcolor);
- color_widget->set_has_opacity_control(true);
- color_widget->set_current_alpha((unsigned short)(color.get_a()*65535.0));
- color_widget->show();
-*/
- }
- break;
- default:
- label->show();
- break;
- }
- }catch(...) { synfig::error(__FILE__":%d: Caught something that was thrown",__LINE__); }
-}
-
-const synfig::ValueBase &
-Widget_ValueBase::get_value()
-{
- switch(value.get_type())
- {
- case ValueBase::TYPE_VECTOR:
- value=vector_widget->get_value();
- break;
- case ValueBase::TYPE_REAL:
- if(param_desc.get_is_distance() && canvas)
- value=distance_widget->get_value().units(canvas->rend_desc());
- else
- value=real_widget->get_value();
- break;
- case ValueBase::TYPE_TIME:
- value=time_widget->get_value();
- break;
- case ValueBase::TYPE_ANGLE:
- value=Angle::deg(angle_widget->get_value());
- break;
- case ValueBase::TYPE_CANVAS:
- value=canvas_widget->get_value();
- break;
- case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
- {
- value=integer_widget->get_value_as_int();
- }
- else
- {
- value=enum_widget->get_value();
- }
-
- break;
- case ValueBase::TYPE_BOOL:
- value=bool_widget->get_active();
- break;
- case ValueBase::TYPE_STRING:
- if(param_desc.get_hint()!="filename")
- {
- value=string(string_widget->get_text());
- }
- else
- {
- value=string(filename_widget->get_value());
- }
- break;
- case ValueBase::TYPE_COLOR:
- {
- value=color_widget->get_value();
-/*
- Gdk::Color gdkcolor;
- synfig::Color color;
- gdkcolor=color_widget->get_current_color();
- color.set_r(gdkcolor.get_red_p());
- color.set_g(gdkcolor.get_green_p());
- color.set_b(gdkcolor.get_blue_p());
- color.set_a(color_widget->get_current_alpha()/65535.0);
-
- value=color;
-*/
- }
- break;
- default:
- break;
- }
-
- return value;
-}
-
-
-void
-Widget_ValueBase::on_grab_focus()
-{
- switch(value.get_type())
- {
- case ValueBase::TYPE_VECTOR:
- vector_widget->grab_focus();
- break;
- case ValueBase::TYPE_REAL:
- if(param_desc.get_is_distance()&& canvas)
- distance_widget->grab_focus();
- else
- real_widget->grab_focus();
- break;
- case ValueBase::TYPE_TIME:
- time_widget->grab_focus();
- break;
- case ValueBase::TYPE_ANGLE:
- angle_widget->grab_focus();
- break;
- case ValueBase::TYPE_CANVAS:
- canvas_widget->grab_focus();
- break;
- case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
- {
- integer_widget->grab_focus();
- }
- else
- {
- enum_widget->grab_focus();
- }
-
- break;
- case ValueBase::TYPE_BOOL:
- bool_widget->grab_focus();
- break;
- case ValueBase::TYPE_STRING:
- if(param_desc.get_hint()!="filename")
- {
- string_widget->grab_focus();
- }
- else
- {
- filename_widget->grab_focus();
- }
- break;
- case ValueBase::TYPE_COLOR:
- {
- color_widget->grab_focus();
- }
- break;
- default:
- break;
- }
-}
-
-/*
-Glib::SignalProxy0<void>
-Widget_ValueBase::signal_activate()
-{
- switch(value.get_type())
- {
- case ValueBase::TYPE_VECTOR:
- return vector_widget->signal_activate();
- break;
- case ValueBase::TYPE_REAL:
- if(param_desc.get_is_distance()&& canvas)
- return distance_widget->signal_activate();
- else
- return real_widget->signal_activate();
-
- break;
- case ValueBase::TYPE_TIME:
- return time_widget->signal_activate();
- break;
- case ValueBase::TYPE_ANGLE:
- return angle_widget->signal_activate();
- break;
- case ValueBase::TYPE_CANVAS:
- return canvas_widget->signal_activate();
- break;
- case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
- return integer_widget->signal_activate();
- else
- return enum_widget->signal_activate();
-
- break;
- case ValueBase::TYPE_BOOL:
- return string_widget->signal_activate();
- break;
- case ValueBase::TYPE_STRING:
- if(param_desc.get_hint()!="filename")
- {
- return string_widget->signal_activate();
- }
- else
- {
- return filename_widget->signal_activate();
- }
- break;
- case ValueBase::TYPE_COLOR:
- {
- return color_widget->signal_activate();
- }
- break;
- default:
- return string_widget->signal_activate();
- break;
- }
-}
-*/
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_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_VALUE_H
-#define __SYNFIG_GTKMM_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/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>
-#include <synfig/canvas.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_ColorEdit;
-class Widget_CanvasChooser;
-class Widget_Enum;
-class Widget_Filename;
-class Widget_Vector;
-class Widget_Time;
-class Widget_Distance;
-
-class Widget_ValueBase : public Gtk::HBox
-{
- Gtk::Label *label;
- synfig::ValueBase value;
-
- Widget_Vector *vector_widget;
- Gtk::SpinButton *real_widget;
- Gtk::Adjustment real_adjustment;
- Gtk::SpinButton *integer_widget;
- Gtk::Adjustment integer_adjustment;
- Gtk::SpinButton *angle_widget;
- Gtk::Adjustment angle_adjustment;
-
- Gtk::CheckButton *bool_widget;
- //Gtk::ColorSelection *color_widget;
- Widget_ColorEdit *color_widget;
- Widget_CanvasChooser *canvas_widget;
- Widget_Enum *enum_widget;
- Widget_Filename *filename_widget;
- Widget_Time *time_widget;
- Gtk::Entry *string_widget;
- Widget_Distance *distance_widget;
-
-// std::string hint;
-
- synfig::ParamDesc param_desc;
- etl::handle<synfig::Canvas> canvas;
- sigc::signal<void> signal_value_changed_;
- sigc::signal<void> signal_activate_;
-
-public:
- sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
- void activate();
-
- sigc::signal<void>& signal_activate() { return signal_activate_; }
-
- void set_value(const synfig::ValueBase &data);
- const synfig::ValueBase &get_value();
-
- void on_grab_focus();
-
- void set_param_desc(const synfig::ParamDesc &x) { param_desc=x; }
- const synfig::ParamDesc &get_param_desc() { return param_desc; }
-
- void set_sensitive(bool x);
-
- //void set_hint(std::string x) { hint=x; }
-// std::string get_hint() { return hint; }
-
- void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; assert(canvas); }
- void inside_cellrenderer();
- Widget_ValueBase();
- ~Widget_ValueBase();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_vector.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/spinbutton.h>
-#include "widget_vector.h"
-#include "widget_distance.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#define DIGITS 10
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Vector::Widget_Vector():
- Gtk::HBox(false, 5),
- x_adjustment(0,-100000000,100000000,0.05,0.05,0),
- y_adjustment(0,-100000000,100000000,0.05,0.05,0)
-{
- Gtk::Label *label;
-
- label=manage(new class Gtk::Label("X:"));
- label->set_alignment(0, 0.5);
- label->show();
- pack_start(*label, Gtk::PACK_SHRINK);
-
- spinbutton_x=manage(new class Gtk::SpinButton(x_adjustment,0.05,DIGITS));
- spinbutton_x->set_alignment(1);
- spinbutton_x->set_update_policy(Gtk::UPDATE_ALWAYS);
- spinbutton_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
- pack_start(*spinbutton_x, Gtk::PACK_EXPAND_WIDGET);
-
- distance_x=manage(new Widget_Distance());
- distance_x->set_digits(4);
- distance_x->set_update_policy(Gtk::UPDATE_ALWAYS);
- distance_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
- pack_start(*distance_x, Gtk::PACK_EXPAND_WIDGET);
-
- label=manage(new class Gtk::Label("Y:"));
- label->set_alignment(0, 0.5);
- label->show();
- pack_start(*label, Gtk::PACK_SHRINK);
-
- spinbutton_y=manage(new class Gtk::SpinButton(y_adjustment,0.05,DIGITS));
- spinbutton_y->set_alignment(1);
- spinbutton_y->set_update_policy(Gtk::UPDATE_ALWAYS);
- spinbutton_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
- spinbutton_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
- pack_start(*spinbutton_y, Gtk::PACK_EXPAND_WIDGET);
-
- distance_y=manage(new Widget_Distance());
- distance_y->set_digits(4);
- distance_y->set_update_policy(Gtk::UPDATE_ALWAYS);
- distance_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
- distance_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
- pack_start(*distance_y, Gtk::PACK_EXPAND_WIDGET);
-
- spinbutton_x->show();
- spinbutton_y->show();
-
- spinbutton_x->signal_activate().connect(sigc::mem_fun(*spinbutton_y,&Gtk::SpinButton::grab_focus));
- distance_x->signal_activate().connect(sigc::mem_fun(*distance_y,&Gtk::SpinButton::grab_focus));
-}
-
-Widget_Vector::~Widget_Vector()
-{
-}
-
-void
-Widget_Vector::on_grab_focus()
-{
- if(canvas_)
- distance_x->grab_focus();
- else
- spinbutton_x->grab_focus();
-}
-
-void
-Widget_Vector::set_has_frame(bool x)
-{
- if(spinbutton_x)
- {
- spinbutton_x->set_has_frame(x);
- spinbutton_y->set_has_frame(x);
- spinbutton_x->set_size_request(48,-1);
- spinbutton_y->set_size_request(48,-1);
- }
-
- distance_x->set_has_frame(x);
- distance_y->set_has_frame(x);
- distance_x->set_size_request(48,-1);
- distance_y->set_size_request(48,-1);
-}
-
-void
-Widget_Vector::set_digits(int x)
-{
- if(spinbutton_x)
- {
- spinbutton_x->set_digits(x);
- spinbutton_y->set_digits(x);
- spinbutton_x->set_size_request(48,-1);
- spinbutton_y->set_size_request(48,-1);
- }
-
- distance_x->set_digits(x);
- distance_y->set_digits(x);
- distance_x->set_size_request(48,-1);
- distance_y->set_size_request(48,-1);
-}
-
-void
-Widget_Vector::set_value(const synfig::Vector &data)
-{
- vector=data;
-
- if(canvas_){try
- {
- Distance distx(vector[0],Distance::SYSTEM_UNITS),disty(vector[1],Distance::SYSTEM_UNITS);
- distx.convert(App::distance_system,canvas_->rend_desc());
- disty.convert(App::distance_system,canvas_->rend_desc());
- distance_x->set_value(distx);
- distance_y->set_value(disty);
- spinbutton_x->hide();
- spinbutton_y->hide();
- }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }}
- else
- {
- spinbutton_x->set_value(vector[0]);
- spinbutton_y->set_value(vector[1]);
- distance_x->hide();
- distance_y->hide();
- }
-}
-
-const synfig::Vector &
-Widget_Vector::get_value()
-{
- if(!canvas_ && spinbutton_x)
- {
- vector[0]=spinbutton_x->get_value();
- vector[1]=spinbutton_y->get_value();
- distance_x->hide();
- distance_y->hide();
- }
- else try
- {
- vector[0]=distance_x->get_value().units(canvas_->rend_desc());
- vector[1]=distance_y->get_value().units(canvas_->rend_desc());
- spinbutton_x->hide();
- spinbutton_y->hide();
- }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }
- return vector;
-}
-
-void
-Widget_Vector::on_value_changed()
-{
- signal_value_changed()();
-}
-
-void
-Widget_Vector::set_canvas(synfig::Canvas::LooseHandle x)
-{
- canvas_=x;
- if(x)
- {
- if(spinbutton_x)
- {
- spinbutton_x->hide();
- spinbutton_y->hide();
- }
- distance_x->show();
- distance_y->show();
- }
- else
- {
- if(spinbutton_x)
- {
- spinbutton_x->show();
- spinbutton_y->show();
- }
- distance_x->hide();
- distance_y->hide();
- }
-}
-
-void
-Widget_Vector::show_all_vfunc()
-{
- if(canvas_)
- {
- distance_x->show();
- distance_y->show();
- }
- else
- {
- spinbutton_x->show();
- spinbutton_y->show();
- }
- show();
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_vector.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_WIDGET_VECTOR_H
-#define __SYNFIG_STUDIO_WIDGET_VECTOR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/adjustment.h>
-#include <synfig/vector.h>
-#include <synfig/distance.h>
-#include <synfig/canvas.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 SpinButton; };
-
-namespace studio {
-
-class Widget_Distance;
-
-class Widget_Vector : public Gtk::HBox
-{
- Gtk::SpinButton* spinbutton_x;
- Gtk::SpinButton* spinbutton_y;
-
- Widget_Distance* distance_x;
- Widget_Distance* distance_y;
-
- Gtk::Adjustment x_adjustment;
- Gtk::Adjustment y_adjustment;
-
- synfig::Vector vector;
-
- sigc::signal<void> signal_value_changed_;
-
- sigc::signal<void> signal_activate_;
-
- synfig::Canvas::LooseHandle canvas_;
-
-public:
-
- void activate() { signal_activate_(); }
-
- void set_canvas(synfig::Canvas::LooseHandle);
- synfig::Canvas::LooseHandle get_canvas()const { return canvas_; }
-
- sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
- sigc::signal<void>& signal_activate() { return signal_activate_; }
-
- void on_value_changed();
- void on_grab_focus();
-
- void set_value(const synfig::Vector &data);
- const synfig::Vector &get_value();
- void set_has_frame(bool x);
- void set_digits(int x);
- Widget_Vector();
- ~Widget_Vector();
-
-protected:
- void show_all_vfunc();
-}; // END of class Widget_Vector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_waypoint.cpp
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2008 Chris Moore
-** Copyright (c) 2008 Paul Wise
-**
-** 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 <gtkmm/frame.h>
-#include <gtkmm/alignment.h>
-#include "dialogs/dialog_waypoint.h"
-#include <gtk/gtk.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/combo.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypoint.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
- Gtk::Alignment(0, 0, 1, 1),
- waypoint(synfig::ValueBase(),0),
- adj_tension(0.0,-20,20,0.1,1),
- adj_continuity(0.0,-20,20,0.1,1),
- adj_bias(0.0,-20,20,0.1,1),
- adj_temporal_tension(0.0,-20,20,0.1,1)
-{
- value_widget=manage(new Widget_ValueBase());
- value_widget->set_canvas(canvas);
- value_widget->show();
-
- value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
-
-
- time_widget=manage(new Widget_Time());
- time_widget->set_fps(canvas->rend_desc().get_frame_rate());
- //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
- //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
- //spinbutton->show();
-
- before_options=manage(new class Gtk::Menu());
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
- // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
- after_options=manage(new class Gtk::Menu());
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
- // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
- before=manage(new class Gtk::OptionMenu());
- before->show();
- before->set_menu(*before_options);
-
- after=manage(new class Gtk::OptionMenu());
- after->show();
- after->set_menu(*after_options);
-
- spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
- spin_tension->show();
- spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
- spin_continuity->show();
- spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
- spin_bias->show();
- spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
- spin_temporal_tension->show();
-
- set_padding(12, 12, 12, 12);
-
- Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
- add(*widgetBox);
-
- Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
- waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
- ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
- widgetBox->pack_start(*waypointFrame, false, false, 0);
-
- Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
- waypointPadding->set_padding(6, 0, 24, 0);
- waypointFrame->add(*waypointPadding);
-
- Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
- waypointTable->set_row_spacings(6);
- waypointTable->set_col_spacings(12);
- waypointPadding->add(*waypointTable);
-
- Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
- waypointValueLabel->set_alignment(0, 0.5);
- waypointValueLabel->set_mnemonic_widget(*value_widget);
- waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
- waypointTimeLabel->set_alignment(0, 0.5);
- waypointTimeLabel->set_mnemonic_widget(*time_widget);
- waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
- interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
- ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
- widgetBox->pack_start(*interpolationFrame, false, false, 0);
-
- Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
- interpolationPadding->set_padding(6, 0, 24, 0);
- interpolationFrame->add(*interpolationPadding);
-
- Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
- interpolationTable->set_row_spacings(6);
- interpolationTable->set_col_spacings(12);
- interpolationPadding->add(*interpolationTable);
-
- Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
- interpolationInLabel->set_alignment(0, 0.5);
- interpolationInLabel->set_mnemonic_widget(*before);
- interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
- interpolationOutLabel->set_alignment(0, 0.5);
- interpolationOutLabel->set_mnemonic_widget(*after);
- interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
- tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
- ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
- widgetBox->pack_start(*tcbFrame, false, false, 0);
-
- Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
- tcbPadding->set_padding(6, 0, 24, 0);
- tcbFrame->add(*tcbPadding);
-
- Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
- tcbTable->set_row_spacings(6);
- tcbTable->set_col_spacings(12);
- tcbPadding->add(*tcbTable);
-
- Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
- tensionLabel->set_alignment(0, 0.5);
- tensionLabel->set_mnemonic_widget(*spin_tension);
- spin_tension->set_alignment(1);
- tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
- continuityLabel->set_alignment(0, 0.5);
- continuityLabel->set_mnemonic_widget(*spin_continuity);
- spin_continuity->set_alignment(1);
- tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
- biasLabel->set_alignment(0, 0.5);
- biasLabel->set_mnemonic_widget(*spin_bias);
- spin_bias->set_alignment(1);
- tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
- temporalTensionLabel->set_alignment(0, 0.5);
- temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
- spin_temporal_tension->set_alignment(1);
- tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
- show_all();
- hide();
- //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- set_canvas(canvas);
-}
-
-void
-Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
-{
- canvas=x;
- assert(canvas);
-
- time_widget->set_fps(canvas->rend_desc().get_frame_rate());
- value_widget->set_canvas(canvas);
-}
-
-void
-Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
-{
- time_widget->set_fps(canvas->rend_desc().get_frame_rate());
-
- waypoint=x;
-
- //! \todo This really needs to be fixed to support value node waypoints!
- if(waypoint.is_static())
- {
- value_widget->set_value(waypoint.get_value());
- value_widget->show();
- value_node_label->hide();
- }
- else
- {
- value_widget->hide();
- value_node_label->show();
- }
-
- time_widget->set_value(waypoint.get_time());
-
- before->set_history((int)waypoint.get_before());
- after->set_history((int)waypoint.get_after());
-
- adj_tension.set_value(waypoint.get_tension());
- adj_continuity.set_value(waypoint.get_continuity());
- adj_bias.set_value(waypoint.get_bias());
- adj_temporal_tension.set_value(waypoint.get_temporal_tension());
-
-}
-const synfig::Waypoint &
-Widget_Waypoint::get_waypoint()const
-{
- //! \todo This too!
- waypoint.set_time(time_widget->get_value());
- if(waypoint.is_static())
- waypoint.set_value(value_widget->get_value());
- //int i;
-
- waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
- waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
-
- waypoint.set_tension(adj_tension.get_value());
- waypoint.set_continuity(adj_continuity.get_value());
- waypoint.set_bias(adj_bias.get_value());
- waypoint.set_temporal_tension(adj_temporal_tension.get_value());
- return waypoint;
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_waypoint.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_GTKMM_WIDGET_WAYPOINT_H
-#define __SYNFIG_GTKMM_WIDGET_WAYPOINT_H
-
-/* === H E A D E R S ======================================================= */
-
-//#include <gtk/gtk.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/button.h>
-//#include <gtkmm/progressbar.h>
-//#include <gtkmm/paned.h>
-#include <gtkmm/box.h>
-//#include <gtkmm/scrollbar.h>
-#include <gtkmm/combo.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/alignment.h>
-
-#include <synfigapp/value_desc.h>
-#include <synfig/waypoint.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 Widget_Time;
-class Widget_Waypoint;
-
-class Widget_Waypoint : public Gtk::Alignment
-{
- Widget_ValueBase *value_widget;
- Gtk::Label *value_node_label;
- Gtk::Label *label;
- Widget_Time *time_widget;
- mutable synfig::Waypoint waypoint;
- synfig::Canvas::Handle canvas;
- //Gtk::Adjustment time_adjustment;
-
- Gtk::Combo *in,*out;
- Gtk::OptionMenu *before, *after;
- Gtk::Menu *before_options,*after_options;
-
- Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
- Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
-// Gtk::ComboDropDownItem item;
-
-public:
- Widget_Waypoint(etl::handle<synfig::Canvas> canvas);
- void set_canvas(synfig::Canvas::Handle x);
- void set_waypoint(synfig::Waypoint &x);
- const synfig::Waypoint &get_waypoint()const;
-}; // END of class Widget_Waypoint
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_waypointmodel.cpp
-** \brief Template Header
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2008 Paul Wise
-**
-** 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 <gtkmm/spinbutton.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypointmodel.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_WaypointModel::Widget_WaypointModel():
- Gtk::Table(4,3,false),
- adj_tension(0.0,-20,20,0.1,1),
- adj_continuity(0.0,-20,20,0.1,1),
- adj_bias(0.0,-20,20,0.1,1),
- adj_temporal_tension(0.0,-20,20,0.1,1),
- checkbutton_after(_("Out:")),
- checkbutton_before(_("In:")),
- checkbutton_tension(_("Tension:")),
- checkbutton_continuity(_("Continuity:")),
- checkbutton_bias(_("Bias:")),
- checkbutton_temporal_tension(_("Temporal Tension:"))
-{
- before_options=manage(new class Gtk::Menu());
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
- before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
- // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
- after_options=manage(new class Gtk::Menu());
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
- after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
- // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
- before=manage(new class Gtk::OptionMenu());
- before->show();
- before->set_menu(*before_options);
-
- after=manage(new class Gtk::OptionMenu());
- after->show();
- after->set_menu(*after_options);
-
- spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
- spin_tension->show();
- spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
- spin_continuity->show();
- spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
- spin_bias->show();
- spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
- spin_temporal_tension->show();
-
- checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
- adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
- before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
- after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
- attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
- attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
- show_all();
- hide();
- updating=false;
- on_change();
-}
-
-void
-Widget_WaypointModel::on_change()
-{
- if(updating)
- return;
-
- waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
- waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
-
- waypoint_model.set_tension(adj_tension.get_value());
- waypoint_model.set_continuity(adj_continuity.get_value());
- waypoint_model.set_bias(adj_bias.get_value());
- waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
-
- waypoint_model.set_before_flag(checkbutton_before.get_active());
- waypoint_model.set_after_flag(checkbutton_after.get_active());
- waypoint_model.set_tension_flag(checkbutton_tension.get_active());
- waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
- waypoint_model.set_bias_flag(checkbutton_bias.get_active());
- waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
-
- before->set_sensitive(checkbutton_before.get_active());
- after->set_sensitive(checkbutton_after.get_active());
- spin_tension->set_sensitive(checkbutton_tension.get_active());
- spin_continuity->set_sensitive(checkbutton_continuity.get_active());
- spin_bias->set_sensitive(checkbutton_bias.get_active());
- spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
-}
-
-void
-Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
-{
- waypoint_model=x;
- updating=true;
-
- before->set_history((int)waypoint_model.get_before());
- after->set_history((int)waypoint_model.get_after());
-
- adj_tension.set_value(waypoint_model.get_tension());
- adj_continuity.set_value(waypoint_model.get_continuity());
- adj_bias.set_value(waypoint_model.get_bias());
- adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
-
- checkbutton_before.set_active(waypoint_model.get_before_flag());
- checkbutton_after.set_active(waypoint_model.get_after_flag());
- checkbutton_tension.set_active(waypoint_model.get_tension_flag());
- checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
- checkbutton_bias.set_active(waypoint_model.get_bias_flag());
- checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());
-
- updating=false;
-
- on_change();
-}
+++ /dev/null
-/* === S Y N F I G ========================================================= */
-/*! \file widget_waypointmodel.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_GTKMM_WIDGET_WAYPOINTMODEL_H
-#define __SYNFIG_GTKMM_WIDGET_WAYPOINTMODEL_H
-
-/* === H E A D E R S ======================================================= */
-
-//#include <gtk/gtk.h>
-//#include <gtkmm/arrow.h>
-//#include <gtkmm/image.h>
-//#include <gdkmm/pixbufloader.h>
-//#include <gtkmm/viewport.h>
-//#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-//#include <gtkmm/progressbar.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/combo.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/checkbutton.h>
-
-
-#include <synfig/waypoint.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_Time;
-class Widget_WaypointModel;
-
-class Widget_WaypointModel : public Gtk::Table
-{
- synfig::Waypoint::Model waypoint_model;
-
- bool updating;
-
- Gtk::Combo *in,*out;
- Gtk::OptionMenu *before, *after;
- Gtk::Menu *before_options,*after_options;
-
- Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
- Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
-
- Gtk::CheckButton checkbutton_after;
- Gtk::CheckButton checkbutton_before;
- Gtk::CheckButton checkbutton_tension;
- Gtk::CheckButton checkbutton_continuity;
- Gtk::CheckButton checkbutton_bias;
- Gtk::CheckButton checkbutton_temporal_tension;
-
- void on_change();
-
-public:
- Widget_WaypointModel();
- void set_waypoint_model(synfig::Waypoint::Model &x);
- const synfig::Waypoint::Model &get_waypoint_model()const { return waypoint_model; }
-}; // END of class Widget_WaypointModel
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_canvaschooser.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 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 "widgets/widget_canvaschooser.h"
+#include <gtkmm/menu.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 ======================================================= */
+
+Widget_CanvasChooser::Widget_CanvasChooser()
+{
+}
+
+Widget_CanvasChooser::~Widget_CanvasChooser()
+{
+}
+
+void
+Widget_CanvasChooser::set_parent_canvas(synfig::Canvas::Handle x)
+{
+ assert(x);
+ parent_canvas=x;
+}
+
+void
+Widget_CanvasChooser::set_value_(synfig::Canvas::Handle data)
+{
+ set_value(data);
+ activate();
+}
+
+void
+Widget_CanvasChooser::set_value(synfig::Canvas::Handle data)
+{
+ assert(parent_canvas);
+ canvas=data;
+
+ canvas_menu=manage(new class Gtk::Menu());
+
+ synfig::Canvas::Children::iterator iter;
+ synfig::Canvas::Children &children(parent_canvas->children());
+ String label;
+
+ if(canvas)
+ {
+ label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
+ canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
+ }
+
+ for(iter=children.begin();iter!=children.end();iter++)
+ if(*iter!=canvas)
+ {
+ label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
+ canvas_menu->items().push_back(
+ Gtk::Menu_Helpers::MenuElem(
+ label,
+ sigc::bind(
+ sigc::mem_fun(
+ *this,
+ &Widget_CanvasChooser::set_value_
+ ),
+ *iter
+ )
+ )
+ );
+ }
+ canvas_menu->items().push_back(
+ Gtk::Menu_Helpers::MenuElem(
+ _("Other..."),
+ sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
+ )
+ );
+ set_menu(*canvas_menu);
+
+ if(canvas)
+ set_history(0);
+}
+
+const etl::handle<synfig::Canvas> &
+Widget_CanvasChooser::get_value()
+{
+ return canvas;
+}
+
+void
+Widget_CanvasChooser::chooser_menu()
+{
+ String canvas_name;
+
+ if (!App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name))
+ {
+ // the user hit 'cancel', so set the parameter back to its previous value
+ set_value_(canvas);
+ return;
+ }
+
+ if (canvas_name == "")
+ {
+ App::dialog_error_blocking(_("Error"),_("No canvas name was specified"));
+ set_value_(canvas);
+ return;
+ }
+
+ Canvas::Handle new_canvas;
+ try
+ {
+ String warnings;
+ new_canvas=parent_canvas->find_canvas(canvas_name, warnings);
+ set_value_(new_canvas);
+ }
+ catch(std::runtime_error x)
+ {
+ App::dialog_error_blocking(_("Error:Exception Thrown"),String(_("Error selecting canvas:\n\n")) + x.what());
+ set_value_(canvas);
+ }
+ catch(...)
+ {
+ App::dialog_error_blocking(_("Error"),_("Unknown Exception"));
+ set_value_(canvas);
+ }
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_canvaschooser.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_WIDGET_CANVASCHOOSER_H
+#define __SYNFIG_STUDIO_WIDGET_CANVASCHOOSER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/canvas.h>
+#include <gtkmm/optionmenu.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 Menu; };
+
+namespace studio {
+
+class Widget_CanvasChooser : public Gtk::OptionMenu
+{
+ Gtk::Menu *canvas_menu;
+ synfig::Canvas::Handle parent_canvas;
+
+ synfig::Canvas::Handle canvas;
+ void set_value_(synfig::Canvas::Handle data);
+public:
+
+ Widget_CanvasChooser();
+ ~Widget_CanvasChooser();
+
+ void set_parent_canvas(synfig::Canvas::Handle x);
+ void set_value(synfig::Canvas::Handle data);
+ const synfig::Canvas::Handle &get_value();
+private:
+ void chooser_menu();
+}; // END of class Widget_CanvasChooser
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_color.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 "widgets/widget_color.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.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 ================================================= */
+
+Gdk::Color
+studio::colorconv_synfig2gdk(const synfig::Color &c_)
+{
+ const synfig::Color c(c_.clamped());
+ Gdk::Color ret;
+ ret.set_rgb(
+ 256*App::gamma.r_F32_to_U8(c.get_r()),
+ 256*App::gamma.g_F32_to_U8(c.get_g()),
+ 256*App::gamma.b_F32_to_U8(c.get_b())
+ );
+ return ret;
+}
+
+void
+studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
+{
+ const int height(ca.get_height());
+ const int width(ca.get_width());
+
+ const int square_size(height/2);
+
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+
+ if(color.get_alpha()!=1.0)
+ {
+ // In this case we need to render the alpha squares
+
+ const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
+ const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
+
+ Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
+ Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
+
+ bool toggle(false);
+ for(int i=0;i<width;i+=square_size)
+ {
+ const int square_width(min(square_size,width-i));
+
+ if(toggle)
+ {
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+ gc->set_rgb_fg_color(gdk_c2);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+ toggle=false;
+ }
+ else
+ {
+ gc->set_rgb_fg_color(gdk_c2);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+ toggle=true;
+ }
+ }
+ }
+ else
+ {
+ // In this case we have a solid color to use
+ Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
+
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
+ }
+ gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+ window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+}
+
+/* === C L A S S E S ======================================================= */
+
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Color::Widget_Color()
+{
+ color=Color(0,0,0,0);
+ set_size_request(-1,16);
+
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Color::redraw));
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+
+}
+
+Widget_Color::~Widget_Color()
+{
+}
+
+void
+Widget_Color::set_value(const synfig::Color &data)
+{
+ assert(data.is_valid());
+ color=data;
+ queue_draw();
+}
+
+const synfig::Color &
+Widget_Color::get_value()
+{
+ assert(color.is_valid());
+ return color;
+}
+
+bool
+Widget_Color::on_event(GdkEvent *event)
+{
+ switch(event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ if(event->button.button==1)
+ {
+ signal_activate_();
+ return true;
+ }
+ if(event->button.button==2)
+ {
+ signal_middle_click_();
+ return true;
+ }
+ if(event->button.button==3)
+ {
+ signal_right_click_();
+ return true;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+Widget_Color::redraw(GdkEventExpose */*bleh*/)
+{
+ //Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+ const int h(get_height());
+ const int w(get_width());
+
+ render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),color);
+
+ return true;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_color.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_WIDGET_COLOR_H
+#define __SYNFIG_STUDIO_WIDGET_COLOR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <synfig/color.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 {
+
+
+Gdk::Color colorconv_synfig2gdk(const synfig::Color &c);
+
+void render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color);
+
+class Widget_Color : public Gtk::DrawingArea
+{
+ synfig::Color color;
+
+ sigc::signal<void> signal_activate_;
+ sigc::signal<void> signal_middle_click_;
+ sigc::signal<void> signal_right_click_;
+
+protected:
+
+public:
+ sigc::signal<void>& signal_activate() { return signal_activate_; }
+ sigc::signal<void>& signal_clicked() { return signal_activate_; }
+ sigc::signal<void>& signal_middle_click() { return signal_middle_click_; }
+ sigc::signal<void>& signal_right_click() { return signal_right_click_; }
+
+ void set_value(const synfig::Color &data);
+ const synfig::Color &get_value();
+ Widget_Color();
+ ~Widget_Color();
+private:
+ bool redraw(GdkEventExpose*bleh);
+ bool on_event(GdkEvent *event);
+
+}; // END of class Widget_Color
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_coloredit.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2008 Paul Wise
+**
+** 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 "widgets/widget_coloredit.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.h>
+#include <pangomm/attributes.h>
+#include <pangomm/attrlist.h>
+#include <algorithm>
+#include <gtkmm/notebook.h>
+#include <gtkmm/box.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 ========================================================= */
+
+#define SPINBUTTON_WIDTH 100
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === C L A S S E S ======================================================= */
+
+ColorSlider::ColorSlider(const ColorSlider::Type &x):
+ type(x)
+{
+ signal_expose_event().connect(sigc::mem_fun(*this, &ColorSlider::redraw));
+ set_size_request(-1,12);
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ add_events(Gdk::BUTTON1_MOTION_MASK);
+}
+
+void
+ColorSlider::set_type(Type x) { type=x; queue_draw(); }
+
+void
+ColorSlider::set_color(synfig::Color x) { color_=x; queue_draw(); }
+
+void
+ColorSlider::slider_color_TYPE_R(synfig::Color &color, float amount) { color.set_r(amount); }
+void
+ColorSlider::slider_color_TYPE_G(synfig::Color &color, float amount) { color.set_g(amount); }
+void
+ColorSlider::slider_color_TYPE_B(synfig::Color &color, float amount) { color.set_b(amount); }
+void
+ColorSlider::slider_color_TYPE_Y(synfig::Color &color, float amount) { color.set_y(amount); }
+void
+ColorSlider::slider_color_TYPE_U(synfig::Color &color, float amount) { color.set_u(amount-0.5f); }
+void
+ColorSlider::slider_color_TYPE_V(synfig::Color &color, float amount) { color.set_v(amount-0.5f); }
+void
+ColorSlider::slider_color_TYPE_HUE(synfig::Color &color, float amount) { color.set_uv_angle(Angle::rot(amount)); }
+void
+ColorSlider::slider_color_TYPE_SAT(synfig::Color &color, float amount) { color.set_s(amount*0.5f); }
+void
+ColorSlider::slider_color_TYPE_A(synfig::Color &color, float amount) { color.set_a(amount); }
+
+void
+ColorSlider::adjust_color(Type type, synfig::Color &color, float amount)
+{
+ static const slider_color_func jump_table[int(TYPE_END)] =
+ {
+ slider_color_TYPE_R,
+ slider_color_TYPE_G,
+ slider_color_TYPE_B,
+ slider_color_TYPE_Y,
+ slider_color_TYPE_U,
+ slider_color_TYPE_V,
+ slider_color_TYPE_HUE,
+ slider_color_TYPE_SAT,
+ slider_color_TYPE_A,
+ };
+ jump_table[int(type)](color,amount);
+}
+
+bool
+ColorSlider::redraw(GdkEventExpose */*bleh*/)
+{
+ Color color(color_);
+
+ static const slider_color_func jump_table[int(TYPE_END)] =
+ {
+ slider_color_TYPE_R,
+ slider_color_TYPE_G,
+ slider_color_TYPE_B,
+ slider_color_TYPE_Y,
+ slider_color_TYPE_U,
+ slider_color_TYPE_V,
+ slider_color_TYPE_HUE,
+ slider_color_TYPE_SAT,
+ slider_color_TYPE_A,
+ };
+
+ slider_color_func color_func(jump_table[int(type)]);
+
+ float amount;
+ switch(type)
+ {
+ case TYPE_R: amount=color.get_r(); break;
+ case TYPE_G: amount=color.get_g(); break;
+ case TYPE_B: amount=color.get_b(); break;
+ case TYPE_Y: amount=color.get_y(); break;
+ case TYPE_U: amount=color.get_u()+0.5; break;
+ case TYPE_V: amount=color.get_v()+0.5; break;
+ case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
+ case TYPE_SAT: amount=color.get_s()*2.0; break;
+ case TYPE_A: amount=color.get_a(); break;
+ default: amount=0; break;
+ }
+ if(use_colorspace_gamma() && (type<TYPE_U))
+ amount=gamma_in(amount);
+
+ const int height(get_height());
+ const int width(get_width());
+
+ Gdk::Rectangle ca(0,0,width,height);
+
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+ const Color bg1(0.75, 0.75, 0.75);
+ const Color bg2(0.5, 0.5, 0.5);
+ int i;
+ for(i=width-1;i>=0;i--)
+ {
+ color_func(color,
+ (use_colorspace_gamma() && type<TYPE_U)
+ ? gamma_out(float(i)/float(width))
+ : (float(i)/float(width)));
+ const Color c1(Color::blend(color,bg1,1.0).clamped());
+ const Color c2(Color::blend(color,bg2,1.0).clamped());
+ assert(c1.is_valid());
+ assert(c2.is_valid());
+
+ if((i*2/height)&1)
+ {
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
+ }
+ else
+ {
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
+ }
+ }
+
+ get_style()->paint_arrow(
+ get_window(),
+ Gtk::STATE_SELECTED,
+ Gtk::SHADOW_OUT,
+ ca,
+ *this,
+ " ",
+ Gtk::ARROW_UP,
+ 1,
+ int(amount*width)-height/2,
+ 0,
+ height,
+ height
+ );
+
+ gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+ get_window()->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ get_window()->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+ return true;
+}
+
+bool
+ColorSlider::on_event(GdkEvent *event)
+{
+ const int width(get_width());
+ float x = 0;
+ if( GDK_SCROLL == event->type ){
+ Color color(color_);
+ float amount;
+ switch(type)
+ {
+ case TYPE_R: amount=color.get_r(); break;
+ case TYPE_G: amount=color.get_g(); break;
+ case TYPE_B: amount=color.get_b(); break;
+ case TYPE_Y: amount=color.get_y(); break;
+ case TYPE_U: amount=color.get_u()+0.5; break;
+ case TYPE_V: amount=color.get_v()+0.5; break;
+ case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
+ case TYPE_SAT: amount=color.get_s()*2.0; break;
+ case TYPE_A: amount=color.get_a(); break;
+ default: amount=0; break;
+ }
+ if(use_colorspace_gamma() && (type<TYPE_U))
+ amount=gamma_in(amount);
+ x = amount*width;
+ switch(event->scroll.direction){
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_RIGHT:
+ x+=1.0;
+ break;
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_LEFT:
+ x-=1.0;
+ break;
+ }
+ } else {
+ x = float(event->button.x);
+ }
+
+ float pos(x/width);
+ if(pos<0 || x<=0)pos=0;
+ if(pos>1)pos=1;
+
+ if(use_colorspace_gamma() && (type<TYPE_U))
+ pos=gamma_out(pos);
+ if(pos<0 || event->button.x<=0)pos=0;
+ if(pos>1)pos=1;
+
+ switch(event->type)
+ {
+ case GDK_SCROLL:
+ signal_slider_moved_(type,pos);
+ queue_draw();
+ signal_activated_();
+ return true;
+
+ case GDK_BUTTON_RELEASE:
+ signal_activated_();
+ return true;
+
+ case GDK_BUTTON_PRESS:
+ case GDK_MOTION_NOTIFY:
+// adjust_color(type,color_,pos);
+ signal_slider_moved_(type,pos);
+ queue_draw();
+ return true;
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+/* === M E T H O D S ======================================================= */
+
+Widget_ColorEdit::Widget_ColorEdit():
+ R_adjustment(0,-10000000,10000000,1,10,0),
+ G_adjustment(0,-10000000,10000000,1,10,0),
+ B_adjustment(0,-10000000,10000000,1,10,0),
+ A_adjustment(0,-10000000,10000000,1,10,0)
+{
+ notebook=manage(new Gtk::Notebook);
+
+ Gtk::Table* rgb_table(manage(new Gtk::Table()));
+ Gtk::Table* yuv_table(manage(new Gtk::Table()));
+ Gtk::Table* main_table(this);
+
+ {
+ Gtk::VBox* rgb_box(manage(new Gtk::VBox()));
+ Gtk::VBox* yuv_box(manage(new Gtk::VBox()));
+ rgb_box->pack_start(*rgb_table,false,false);
+ yuv_box->pack_start(*yuv_table,false,false);
+ notebook->append_page(*rgb_box,_("RGB"));
+ notebook->append_page(*yuv_box,_("YUV"));
+ }
+
+ color=Color(0,0,0,0);
+
+ set_size_request(200,-1);
+ hold_signals=true;
+
+ Gtk::Label *label;
+
+ R_adjustment.set_lower(-10000000);
+ G_adjustment.set_lower(-10000000);
+ B_adjustment.set_lower(-10000000);
+ A_adjustment.set_lower(-10000000);
+
+ clamp_=true;
+
+ Pango::AttrList attr_list;
+ Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
+ pango_size.set_start_index(0);
+ pango_size.set_end_index(64);
+ attr_list.change(pango_size);
+
+ widget_color.set_size_request(-1,16);
+ attach(widget_color, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ attach(*notebook, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+#define SLIDER_ROW(i,n,l) \
+ slider_##n=manage(new ColorSlider(ColorSlider::TYPE_##n)); \
+ slider_##n->signal_slider_moved().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_slider_moved)); \
+ /*slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::activated));*/ \
+ slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed)); \
+ label=manage(new class Gtk::Label(l,0.0,0.5)); \
+ label->set_use_markup(false); \
+ label->set_use_underline(false); \
+ label->set_attributes(attr_list); \
+ table->attach(*label, 0, 1, 1+2*i, 2+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); \
+ table->attach(*slider_##n, 0, 1, 2+2*i, 3+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
+
+#define ATTACH_SPIN_BUTTON(i,n) \
+ spinbutton_##n=manage(new class Gtk::SpinButton(n##_adjustment,1,0)); \
+ spinbutton_##n->set_update_policy(Gtk::UPDATE_ALWAYS); \
+ spinbutton_##n->set_size_request(SPINBUTTON_WIDTH,-1); \
+ spinbutton_##n->show(); \
+ table->attach(*spinbutton_##n, 1, 2, 1+2*i, 3+2*i, Gtk::SHRINK, Gtk::EXPAND, 2, 0)
+
+ {
+ Gtk::Table* table(rgb_table);
+ SLIDER_ROW(0,R,_("Red"));
+ ATTACH_SPIN_BUTTON(0,R);
+ SLIDER_ROW(1,G,_("Green"));
+ ATTACH_SPIN_BUTTON(1,G);
+ SLIDER_ROW(2,B,_("Blue"));
+ ATTACH_SPIN_BUTTON(2,B);
+
+ hex_color_label = manage(new Gtk::Label(_("HTML code"), 0.0, 0.5));
+ hex_color_label->set_use_markup(false);
+ hex_color_label->set_use_underline(false);
+ hex_color_label->set_attributes(attr_list);
+ table->attach(*hex_color_label, 0, 1, 7, 8, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+ hex_color = manage(new Gtk::Entry());
+ hex_color->set_width_chars(8);
+ hex_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_hex_edited));
+ table->attach(*hex_color, 0, 1, 8, 9, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+ }
+ {
+ Gtk::Table* table(yuv_table);
+ SLIDER_ROW(0,Y,_("Luma"));
+ SLIDER_ROW(1,HUE,_("Hue"));
+ SLIDER_ROW(2,SAT,_("Saturation"));
+ SLIDER_ROW(3,U,_("U"));
+ SLIDER_ROW(4,V,_("V"));
+ }
+ {
+ Gtk::Table* table(main_table);
+ SLIDER_ROW(1,A,_("Alpha"));
+ ATTACH_SPIN_BUTTON(1,A);
+ }
+
+#undef SLIDER_ROW
+#undef ATTACH_SPIN_BUTTON
+
+ spinbutton_R->signal_activate().connect(sigc::mem_fun(*spinbutton_G,&Gtk::SpinButton::grab_focus));
+ spinbutton_G->signal_activate().connect(sigc::mem_fun(*spinbutton_B,&Gtk::SpinButton::grab_focus));
+ spinbutton_B->signal_activate().connect(sigc::mem_fun(*spinbutton_A,&Gtk::SpinButton::grab_focus));
+ spinbutton_A->signal_activate().connect(sigc::mem_fun(*spinbutton_R,&Gtk::SpinButton::grab_focus));
+
+ R_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+ G_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+ B_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+ A_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+
+ show_all_children();
+
+ set_digits(1);
+ set_value(color);
+
+ hold_signals=false;
+}
+
+Widget_ColorEdit::~Widget_ColorEdit()
+{
+}
+
+void
+Widget_ColorEdit::on_slider_moved(ColorSlider::Type type, float amount)
+{
+ Color color(get_value_raw());
+
+ assert(color.is_valid());
+ ColorSlider::adjust_color(type,color,amount);
+ assert(color.is_valid());
+
+ // If a non-primary colorslider is adjusted,
+ // we want to make sure that we clamp
+ if(type>ColorSlider::TYPE_B && (color.get_r()<0 ||color.get_g()<0 ||color.get_b()<0))
+ clamp_=true;
+
+ /*
+ if(type==ColorSlider::TYPE_R && color.get_r()<0)clamp_=false;
+ if(type==ColorSlider::TYPE_G && color.get_g()<0)clamp_=false;
+ if(type==ColorSlider::TYPE_B && color.get_b()<0)clamp_=false;
+ */
+ clamp_=false;
+
+ set_value(color);
+ assert(color.is_valid());
+}
+
+void
+Widget_ColorEdit::on_hex_edited()
+{
+ Color color(get_value_raw());
+ String s = hex_color->get_text();
+ color.set_hex(s);
+ set_value(color);
+ signal_value_changed_();
+}
+
+void
+Widget_ColorEdit::on_value_changed()
+{
+ if(hold_signals)
+ return;
+
+ const Color color(get_value_raw());
+ assert(color.is_valid());
+ slider_R->set_color(color);
+ slider_G->set_color(color);
+ slider_B->set_color(color);
+ slider_Y->set_color(color);
+ slider_U->set_color(color);
+ slider_V->set_color(color);
+ slider_HUE->set_color(color);
+ slider_SAT->set_color(color);
+ slider_A->set_color(color);
+ hex_color->set_text(color.get_hex());
+ widget_color.set_value(color);
+
+ activate();
+ signal_value_changed_();
+}
+
+void
+Widget_ColorEdit::set_has_frame(bool x)
+{
+ spinbutton_R->set_has_frame(x);
+ spinbutton_G->set_has_frame(x);
+ spinbutton_B->set_has_frame(x);
+ spinbutton_A->set_has_frame(x);
+ spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
+}
+
+void
+Widget_ColorEdit::set_digits(int x)
+{
+ spinbutton_R->set_digits(x);
+ spinbutton_G->set_digits(x);
+ spinbutton_B->set_digits(x);
+ spinbutton_A->set_digits(x);
+ spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
+ spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
+}
+
+void
+Widget_ColorEdit::set_value(const synfig::Color &data)
+{
+ assert(data.is_valid());
+ hold_signals=true;
+ clamp_=false;
+
+ color=data;
+
+ if(use_colorspace_gamma())
+ {
+ R_adjustment.set_value(gamma_in(color.get_r())*100);
+ G_adjustment.set_value(gamma_in(color.get_g())*100);
+ B_adjustment.set_value(gamma_in(color.get_b())*100);
+ }
+ else
+ {
+ R_adjustment.set_value(color.get_r()*100);
+ G_adjustment.set_value(color.get_g()*100);
+ B_adjustment.set_value(color.get_b()*100);
+ }
+ A_adjustment.set_value(color.get_a()*100);
+
+ slider_R->set_color(color);
+ slider_G->set_color(color);
+ slider_B->set_color(color);
+ slider_Y->set_color(color);
+ slider_U->set_color(color);
+ slider_V->set_color(color);
+ slider_HUE->set_color(color);
+ slider_SAT->set_color(color);
+ slider_A->set_color(color);
+ hex_color->set_text(color.get_hex());
+ widget_color.set_value(color);
+
+ hold_signals=false;
+}
+
+synfig::Color
+Widget_ColorEdit::get_value_raw()
+{
+ Color color;
+ if(use_colorspace_gamma())
+ {
+ color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
+ color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
+ color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
+ }
+ else
+ {
+ color.set_r(R_adjustment.get_value()/100);
+ color.set_g(G_adjustment.get_value()/100);
+ color.set_b(B_adjustment.get_value()/100);
+ }
+ color.set_a(A_adjustment.get_value()/100);
+ assert(color.is_valid());
+
+ return color;
+}
+
+const synfig::Color &
+Widget_ColorEdit::get_value()
+{
+ if(use_colorspace_gamma())
+ {
+ color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
+ color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
+ color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
+ assert(color.is_valid());
+ }
+ else
+ {
+ color.set_r(R_adjustment.get_value()/100);
+ color.set_g(G_adjustment.get_value()/100);
+ color.set_b(B_adjustment.get_value()/100);
+ assert(color.is_valid());
+ }
+ color.set_a(A_adjustment.get_value()/100);
+ assert(color.is_valid());
+
+ if(notebook->get_current_page()!=0)
+ color=color.clamped();
+
+ /*{
+ // Clamp out negative values
+ color.set_r(std::max(0.0f,(float)color.get_r()));
+ color.set_g(std::max(0.0f,(float)color.get_g()));
+ color.set_b(std::max(0.0f,(float)color.get_b()));
+ }*/
+
+ return color;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_coloredit.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_WIDGET_COLOREDIT_H
+#define __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <synfig/color.h>
+#include "widgets/widget_color.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 Notebook;
+};
+
+namespace studio {
+
+class ColorSlider : public Gtk::DrawingArea
+{
+public:
+ enum Type
+ {
+ TYPE_R,
+ TYPE_G,
+ TYPE_B,
+ TYPE_Y,
+ TYPE_U,
+ TYPE_V,
+ TYPE_HUE,
+ TYPE_SAT,
+ TYPE_A,
+
+ TYPE_END
+ };
+
+private:
+
+ sigc::signal<void,Type,float> signal_slider_moved_;
+ sigc::signal<void> signal_activated_;
+
+ Type type;
+ synfig::Color color_;
+
+public:
+
+ sigc::signal<void,Type,float>& signal_slider_moved() { return signal_slider_moved_; }
+ sigc::signal<void>& signal_activated() { return signal_activated_; }
+
+ Type
+ get_type()const { return type; }
+
+ const synfig::Color&
+ get_color()const { return color_; }
+
+
+ ColorSlider(const Type &x=TYPE_Y);
+
+ void
+ set_type(Type x);
+
+ void
+ set_color(synfig::Color x);
+
+ static void adjust_color(Type type, synfig::Color &color, float amount);
+
+private:
+ typedef void (*slider_color_func)(synfig::Color &,float);
+
+ static void slider_color_TYPE_R(synfig::Color &color, float amount);
+ static void slider_color_TYPE_G(synfig::Color &color, float amount);
+ static void slider_color_TYPE_B(synfig::Color &color, float amount);
+ static void slider_color_TYPE_Y(synfig::Color &color, float amount);
+ static void slider_color_TYPE_U(synfig::Color &color, float amount);
+ static void slider_color_TYPE_V(synfig::Color &color, float amount);
+ static void slider_color_TYPE_HUE(synfig::Color &color, float amount);
+ static void slider_color_TYPE_SAT(synfig::Color &color, float amount);
+ static void slider_color_TYPE_A(synfig::Color &color, float amount);
+
+
+ bool
+ redraw(GdkEventExpose*bleh);
+ bool on_event(GdkEvent *event);
+}; // END of class ColorSlider
+
+
+class Widget_ColorEdit : public Gtk::Table
+{
+ sigc::signal<void> signal_activated_;
+ sigc::signal<void> signal_value_changed_;
+
+ ColorSlider *slider_R;
+ ColorSlider *slider_G;
+ ColorSlider *slider_B;
+ Gtk::Label *hex_color_label;
+ Gtk::Entry *hex_color;
+
+ ColorSlider *slider_A;
+ ColorSlider *slider_Y;
+ ColorSlider *slider_U;
+ ColorSlider *slider_V;
+ ColorSlider *slider_SAT;
+ ColorSlider *slider_HUE;
+
+ Widget_Color widget_color;
+
+ bool hold_signals;
+
+ bool clamp_;
+
+ Gtk::SpinButton *spinbutton_R;
+ Gtk::SpinButton *spinbutton_G;
+ Gtk::SpinButton *spinbutton_B;
+ Gtk::SpinButton *spinbutton_A;
+
+ Gtk::Adjustment R_adjustment;
+ Gtk::Adjustment G_adjustment;
+ Gtk::Adjustment B_adjustment;
+ Gtk::Adjustment A_adjustment;
+
+ synfig::Color color;
+
+ Gtk::Notebook* notebook;
+
+protected:
+
+ void on_value_changed();
+
+public:
+
+ sigc::signal<void>& signal_activated() { return signal_activated_; }
+
+ sigc::signal<void>& signal_activate() { return signal_activated_; }
+
+ void on_slider_moved(ColorSlider::Type type, float amount);
+ void on_hex_edited();
+
+ //Glib::SignalProxy0<void> signal_activate() { return spinbutton_A->signal_activate(); }
+
+ sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+ void activated() { signal_activated_(); }
+ void activate() { signal_activated_(); }
+ void set_value(const synfig::Color &data);
+ const synfig::Color &get_value();
+ synfig::Color get_value_raw();
+ void set_has_frame(bool x);
+ void set_digits(int x);
+ Widget_ColorEdit();
+ ~Widget_ColorEdit();
+}; // END of class Widget_ColorEdit
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_compselect.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/menu.h>
+#include "widgets/widget_compselect.h"
+#include <ETL/stringf>
+#include <synfig/valuenode.h>
+#include "instance.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 ======================================================= */
+
+Widget_CompSelect::Widget_CompSelect()
+{
+ App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::new_instance));
+ App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::delete_instance));
+ App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::set_selected_instance_signal));
+
+ set_menu(instance_list_menu);
+ refresh();
+}
+
+Widget_CompSelect::~Widget_CompSelect()
+{
+}
+
+void
+Widget_CompSelect::set_selected_instance_signal(etl::handle<studio::Instance> x)
+{
+ set_selected_instance(x);
+}
+
+void
+Widget_CompSelect::set_selected_instance_(etl::handle<studio::Instance> instance)
+{
+ if(studio::App::shutdown_in_progress)
+ return;
+
+ selected_instance=instance;
+}
+
+void
+Widget_CompSelect::set_selected_instance(etl::loose_handle<studio::Instance> x)
+{
+ if(studio::App::shutdown_in_progress)
+ return;
+
+ // if it's already selected, don't select it again
+ if (x==selected_instance)
+ return;
+
+ std::list<etl::handle<studio::Instance> >::iterator iter;
+
+ if(x)
+ {
+ int i;
+ for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++)
+ ;
+
+ assert(*iter==x);
+
+ set_history(i);
+ }
+ else
+ set_history(0);
+
+ set_selected_instance_(x);
+}
+
+void
+Widget_CompSelect::new_instance(etl::handle<studio::Instance> instance)
+{
+ if(studio::App::shutdown_in_progress)
+ return;
+
+ assert(instance);
+
+ etl::loose_handle<studio::Instance> loose_instance(instance);
+
+ instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Widget_CompSelect::refresh));
+ instance->synfigapp::Instance::signal_filename_changed().connect(
+ sigc::bind<etl::loose_handle<studio::Instance> >(
+ sigc::mem_fun(*this,&Widget_CompSelect::set_selected_instance),
+ loose_instance
+ )
+ );
+
+ {
+ std::string name=basename(instance->get_file_name());
+
+ instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+ sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),loose_instance) ));
+ }
+
+}
+
+void
+Widget_CompSelect::delete_instance(etl::handle<studio::Instance> instance)
+{
+ refresh();
+
+ if(selected_instance==instance)
+ {
+ set_selected_instance(0);
+ set_history(0);
+ }
+}
+
+void
+Widget_CompSelect::refresh()
+{
+ remove_menu();
+
+ if(!instance_list_menu.items().empty())
+ instance_list_menu.items().clear();
+
+ if(studio::App::shutdown_in_progress)
+ return;
+
+ std::list<etl::handle<studio::Instance> >::iterator iter;
+ for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
+ {
+ std::string name=basename((*iter)->get_file_name());
+
+ instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+ sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),*iter) ));
+ }
+ set_menu(instance_list_menu);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_compselect.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_WIDGET_COMPSELECT_H
+#define __SYNFIG_STUDIO_WIDGET_COMPSELECT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/menu.h>
+#include "app.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 Menu; };
+
+namespace studio {
+
+class Widget_CompSelect : public Gtk::OptionMenu
+{
+ Gtk::Menu instance_list_menu;
+
+
+ etl::loose_handle<studio::Instance> selected_instance;
+ void set_selected_instance_(etl::handle<studio::Instance> x);
+
+ void new_instance(etl::handle<studio::Instance> x);
+
+ void delete_instance(etl::handle<studio::Instance> x);
+
+ void set_selected_instance(etl::loose_handle<studio::Instance> x);
+
+ void set_selected_instance_signal(etl::handle<studio::Instance> x);
+
+public:
+
+ Widget_CompSelect();
+ ~Widget_CompSelect();
+
+ etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
+
+ void refresh();
+}; // END of class Widget_CompSelect
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_curves.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Gerco Ballintijn
+**
+** 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 "widgets/widget_curves.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.h>
+#include <map>
+#include <vector>
+#include <ETL/misc>
+#include <sigc++/object.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 ================================================= */
+
+/*
+void
+studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
+{
+ const int height(ca.get_height());
+ const int width(ca.get_width());
+
+ const int square_size(height/2);
+
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+
+ if(color.get_alpha()!=1.0)
+ {
+ // In this case we need to render the alpha squares
+
+ const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
+ const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
+
+ Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
+ Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
+
+ bool toggle(false);
+ for(int i=0;i<width;i+=square_size)
+ {
+ const int square_width(min(square_size,width-i));
+
+ if(toggle)
+ {
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+ gc->set_rgb_fg_color(gdk_c2);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+ toggle=false;
+ }
+ else
+ {
+ gc->set_rgb_fg_color(gdk_c2);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+ toggle=true;
+ }
+ }
+ }
+ else
+ {
+ // In this case we have a solid color to use
+ Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
+
+ gc->set_rgb_fg_color(gdk_c1);
+ window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
+ }
+ gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+ window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+}
+*/
+
+/* === C L A S S E S ======================================================= */
+
+
+
+struct studio::Widget_Curves::Channel
+{
+ synfig::String name;
+ Gdk::Color color;
+ std::map<synfig::Real,synfig::Real> values;
+};
+
+struct studio::Widget_Curves::CurveStruct : sigc::trackable
+{
+ synfigapp::ValueDesc value_desc;
+ std::vector<Channel> channels;
+
+ CurveStruct(const synfigapp::ValueDesc& x):
+ value_desc(x)
+ {
+ switch(value_desc.get_value_type())
+ {
+ case ValueBase::TYPE_REAL:
+ channels.push_back(Channel());
+ channels.back().name="real";
+ channels.back().color=Gdk::Color("#007f7f");
+ break;
+ case ValueBase::TYPE_TIME:
+ channels.push_back(Channel());
+ channels.back().name="time";
+ channels.back().color=Gdk::Color("#7f7f00");
+ break;
+ case ValueBase::TYPE_INTEGER:
+ channels.push_back(Channel());
+ channels.back().name="int";
+ channels.back().color=Gdk::Color("#7f0000");
+ break;
+ case ValueBase::TYPE_BOOL:
+ channels.push_back(Channel());
+ channels.back().name="bool";
+ channels.back().color=Gdk::Color("#ff7f00");
+ break;
+ case ValueBase::TYPE_ANGLE:
+ channels.push_back(Channel());
+ channels.back().name="theta";
+ channels.back().color=Gdk::Color("#004f4f");
+ break;
+ case ValueBase::TYPE_COLOR:
+ channels.push_back(Channel());
+ channels.back().name="red";
+ channels.back().color=Gdk::Color("#7f0000");
+ channels.push_back(Channel());
+ channels.back().name="green";
+ channels.back().color=Gdk::Color("#007f00");
+ channels.push_back(Channel());
+ channels.back().name="blue";
+ channels.back().color=Gdk::Color("#00007f");
+ channels.push_back(Channel());
+ channels.back().name="alpha";
+ channels.back().color=Gdk::Color("#000000");
+ break;
+ case ValueBase::TYPE_VECTOR:
+ channels.push_back(Channel());
+ channels.back().name="x";
+ channels.back().color=Gdk::Color("#7f007f");
+ channels.push_back(Channel());
+ channels.back().name="y";
+ channels.back().color=Gdk::Color("#007f7f");
+ break;
+ case ValueBase::TYPE_BLINEPOINT:
+ channels.push_back(Channel());
+ channels.back().name="v.x";
+ channels.back().color=Gdk::Color("#ff7f00");
+ channels.push_back(Channel());
+ channels.back().name="v.y";
+ channels.back().color=Gdk::Color("#7f3f00");
+
+ channels.push_back(Channel());
+ channels.back().name="width";
+ channels.back().color=Gdk::Color("#000000");
+
+ channels.push_back(Channel());
+ channels.back().name="origin";
+ channels.back().color=Gdk::Color("#ffffff");
+
+ channels.push_back(Channel());
+ channels.back().name="tsplit";
+ channels.back().color=Gdk::Color("#ff00ff");
+
+ channels.push_back(Channel());
+ channels.back().name="t1.x";
+ channels.back().color=Gdk::Color("#ff0000");
+ channels.push_back(Channel());
+ channels.back().name="t1.y";
+ channels.back().color=Gdk::Color("#7f0000");
+
+ channels.push_back(Channel());
+ channels.back().name="t2.x";
+ channels.back().color=Gdk::Color("#ffff00");
+ channels.push_back(Channel());
+ channels.back().name="t2.y";
+ channels.back().color=Gdk::Color("#7f7f00");
+ break;
+ default:
+ throw synfig::Exception::BadType("Bad type for curves");
+ }
+ }
+
+ void clear_all_values()
+ {
+ std::vector<Channel>::iterator iter;
+ for(iter=channels.begin();iter!=channels.end();++iter)
+ iter->values.clear();
+ }
+
+ synfig::Real get_value(int chan, synfig::Real time, synfig::Real tolerance)
+ {
+ std::map<synfig::Real,synfig::Real>::iterator iter;
+
+ // First check to see if we have a value
+ // that is "close enough" to the time
+ // we are looking for
+ iter=channels[chan].values.lower_bound(time);
+ if(iter!=channels[chan].values.end() && iter->first-time<=tolerance)
+ return -iter->second;
+
+ // Since that didn't work, we now need
+ // to go ahead and figure out what the
+ // actual value is at that time.
+ ValueBase value(value_desc.get_value(time));
+ switch(value.get_type())
+ {
+ case ValueBase::TYPE_REAL:
+ channels[0].values[time]=value.get(Real());
+ break;
+ case ValueBase::TYPE_TIME:
+ channels[0].values[time]=value.get(Time());
+ break;
+ case ValueBase::TYPE_INTEGER:
+ channels[0].values[time]=value.get(int());
+ break;
+ case ValueBase::TYPE_BOOL:
+ channels[0].values[time]=value.get(bool());
+ break;
+ case ValueBase::TYPE_ANGLE:
+ channels[0].values[time]=Angle::rad(value.get(Angle())).get();
+ break;
+ case ValueBase::TYPE_COLOR:
+ channels[0].values[time]=value.get(Color()).get_r();
+ channels[1].values[time]=value.get(Color()).get_g();
+ channels[2].values[time]=value.get(Color()).get_b();
+ channels[3].values[time]=value.get(Color()).get_a();
+ break;
+ case ValueBase::TYPE_VECTOR:
+ channels[0].values[time]=value.get(Vector())[0];
+ channels[1].values[time]=value.get(Vector())[1];
+ break;
+ case ValueBase::TYPE_BLINEPOINT:
+ channels[0].values[time]=value.get(BLinePoint()).get_vertex()[0];
+ channels[1].values[time]=value.get(BLinePoint()).get_vertex()[1];
+ channels[2].values[time]=value.get(BLinePoint()).get_width();
+ channels[3].values[time]=value.get(BLinePoint()).get_origin();
+ channels[4].values[time]=value.get(BLinePoint()).get_split_tangent_flag();
+ channels[5].values[time]=value.get(BLinePoint()).get_tangent1()[0];
+ channels[6].values[time]=value.get(BLinePoint()).get_tangent1()[1];
+ channels[7].values[time]=value.get(BLinePoint()).get_tangent2()[0];
+ channels[8].values[time]=value.get(BLinePoint()).get_tangent2()[1];
+ break;
+ default:
+ return 0;
+ }
+
+ return -channels[chan].values[time];
+ }
+
+ static bool is_not_supported(const synfigapp::ValueDesc& x)
+ {
+ return x.get_value_type() == ValueBase::TYPE_STRING
+ || x.get_value_type() == ValueBase::TYPE_CANVAS
+ || x.get_value_type() == ValueBase::TYPE_GRADIENT
+ || x.get_value_type() == ValueBase::TYPE_LIST
+ || x.get_value_type() == ValueBase::TYPE_SEGMENT;
+ }
+};
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Curves::Widget_Curves():
+ range_adjustment_(new Gtk::Adjustment(-1,-2,2,0.1,0.1,2))
+{
+ set_size_request(64,64);
+
+ range_adjustment_->signal_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &Widget_Curves::queue_draw
+ )
+ );
+ range_adjustment_->signal_value_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &Widget_Curves::queue_draw
+ )
+ );
+ //set_vadjustment(*range_adjustment_);
+
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Curves::redraw));
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+
+}
+
+Widget_Curves::~Widget_Curves()
+{
+}
+
+void
+Widget_Curves::set_time_adjustment(Gtk::Adjustment&x)
+{
+ time_adjustment_=&x;
+ time_adjustment_->signal_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &Widget_Curves::queue_draw
+ )
+ );
+ time_adjustment_->signal_value_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &Widget_Curves::queue_draw
+ )
+ );
+ //set_hadjustment(*time_adjustment_);
+}
+
+void
+Widget_Curves::clear()
+{
+ curve_list_.clear();
+}
+
+void
+Widget_Curves::refresh()
+{
+ std::list<CurveStruct>::iterator curve_iter;
+ for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+ {
+ curve_iter->clear_all_values();
+ }
+ queue_draw();
+}
+
+void
+Widget_Curves::set_value_descs(std::list<synfigapp::ValueDesc> value_descs)
+{
+ curve_list_.clear();
+
+ std::list<synfigapp::ValueDesc>::iterator iter;
+ for(iter=value_descs.begin();iter!=value_descs.end();++iter)
+ {
+ if (CurveStruct::is_not_supported(*iter))
+ continue;
+
+ try {
+ curve_list_.push_back(*iter);
+ if(iter->is_value_node())
+ {
+ iter->get_value_node()->signal_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &studio::Widget_Curves::refresh
+ )
+ );
+ }
+ if(iter->parent_is_value_node())
+ {
+ iter->get_parent_value_node()->signal_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &studio::Widget_Curves::refresh
+ )
+ );
+ }
+ if(iter->parent_is_layer_param())
+ {
+ iter->get_layer()->signal_changed().connect(
+ sigc::mem_fun(
+ *this,
+ &studio::Widget_Curves::refresh
+ )
+ );
+ }
+ }catch(synfig::Exception::BadType)
+ {
+ continue;
+ }
+ }
+ queue_draw();
+}
+
+bool
+Widget_Curves::on_event(GdkEvent *event)
+{
+ switch(event->type)
+ {
+ case GDK_SCROLL:
+ switch(event->scroll.direction)
+ {
+ case GDK_SCROLL_UP:
+ range_adjustment_->set_page_size(range_adjustment_->get_page_size()/1.25);
+ range_adjustment_->changed();
+ break;
+ case GDK_SCROLL_DOWN:
+ range_adjustment_->set_page_size(range_adjustment_->get_page_size()*1.25);
+ range_adjustment_->changed();
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ return Gtk::DrawingArea::on_event(event);
+ break;
+ }
+
+ return true;
+
+/* switch(event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ if(event->button.button==1)
+ {
+ signal_activate_();
+ return true;
+ }
+ if(event->button.button==3)
+ {
+ signal_secondary_();
+ return true;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return false;
+*/
+}
+
+bool
+Widget_Curves::redraw(GdkEventExpose */*bleh*/)
+{
+ const int h(get_height());
+ const int w(get_width());
+ get_window()->clear();
+
+ if(!time_adjustment_ || !range_adjustment_ || !h || !w)
+ return false;
+
+ if(!curve_list_.size())
+ return false;
+
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+ const Real t_begin(time_adjustment_->get_lower());
+ const Real t_end(time_adjustment_->get_upper());
+ const Real dt((t_end-t_begin)/w);
+
+ const Real r_bottom(range_adjustment_->get_value());
+ const Real r_top(r_bottom+range_adjustment_->get_page_size());
+ const Real dr((r_top-r_bottom)/h);
+ Real r_max(-100000000);
+ Real r_min(100000000);
+
+ std::list<CurveStruct>::iterator curve_iter;
+
+ vector<Gdk::Point> points[10];
+
+ gc->set_function(Gdk::COPY);
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+ // Draw zero mark
+ gc->set_rgb_fg_color(Gdk::Color("#4f4f4f"));
+ get_window()->draw_rectangle(gc, false, 0, round_to_int((0-r_bottom)/dr), w, 0);
+
+ // This try to find a valid vanvas to show the keyframes of those
+ // valuenodes. If not canvas found then no keyframes marks are shown.
+ synfig::Canvas::Handle canvas=0;
+ for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+ {
+ canvas=curve_iter->value_desc.get_canvas();
+ if(canvas)
+ break;
+ }
+
+ if(canvas)
+ {
+ // Draw vertical lines for the keyframes marks.
+ 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)w/(t_end-t_begin)*(iter->get_time()-t_begin)));
+ if(iter->get_time()>=t_begin && iter->get_time()<t_end)
+ {
+ gc->set_rgb_fg_color(Gdk::Color("#a07f7f")); // It should be user selectable
+ get_window()->draw_rectangle(gc, true, x, 0, 1, h);
+ }
+ }
+ }
+
+ // Draw current time
+ gc->set_rgb_fg_color(Gdk::Color("#0000ff")); // It should be user selectable
+ get_window()->draw_rectangle(gc, false, round_to_int((time_adjustment_->get_value()-t_begin)/dt), 0, 0, h);
+
+ // Draw curves for the valuenodes stored in the curve list
+ for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+ {
+ Real t;
+ int i;
+ int channels(curve_iter->channels.size());
+ for(i=0;i<channels;i++)
+ points[i].clear();
+
+ for(i=0,t=t_begin;i<w;i++,t+=dt)
+ {
+ for(int chan=0;chan<channels;chan++)
+ {
+ Real x(curve_iter->get_value(chan,t,dt));
+ r_max=max(r_max,x);
+ r_min=min(r_min,x);
+ points[chan].push_back(
+ Gdk::Point(
+ i,
+ round_to_int(
+ (
+ x-r_bottom
+ )/dr
+ )
+ )
+ );
+ }
+ }
+
+ for(int chan=0;chan<channels;chan++)
+ {
+ gc->set_rgb_fg_color(curve_iter->channels[chan].color);
+
+ // Draw the curve
+ get_window()->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points[chan]));
+
+ Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+
+ layout->set_text(curve_iter->channels[chan].name);
+ get_window()->draw_layout(gc, 1, points[chan][0].get_y()+1, layout);
+ }
+ }
+
+ if(!curve_list_.empty())
+ {
+ range_adjustment_->set_upper(r_max+range_adjustment_->get_page_size()/2);
+ range_adjustment_->set_lower(r_min-range_adjustment_->get_page_size()/2);
+ }
+ get_window()->get_update_area();
+
+ return true;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_curves.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_WIDGET_CURVES_H
+#define __SYNFIG_STUDIO_WIDGET_CURVES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/layout.h>
+#include <synfig/color.h>
+#include <synfigapp/value_desc.h>
+#include <list>
+
+/* === 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_Curves : public Gtk::DrawingArea
+{
+ struct Channel;
+ struct CurveStruct;
+
+ Gtk::Adjustment* time_adjustment_;
+ Gtk::Adjustment* range_adjustment_;
+
+ std::list<CurveStruct> curve_list_;
+
+public:
+
+ Widget_Curves();
+ ~Widget_Curves();
+
+ void set_value_descs(std::list<synfigapp::ValueDesc> value_descs);
+ void clear();
+ void refresh();
+
+ Gtk::Adjustment& get_range_adjustment() { return *range_adjustment_; }
+ Gtk::Adjustment& get_time_adjustment() { return *time_adjustment_; }
+ void set_time_adjustment(Gtk::Adjustment&);
+
+private:
+ bool redraw(GdkEventExpose*bleh);
+ bool on_event(GdkEvent *event);
+
+}; // END of class Widget_Curves
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_defaults.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Chris Moore
+** Copyright (c) 2008 Carlos López
+**
+** 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 "widgets/widget_defaults.h"
+#include "widgets/widget_color.h"
+#include "widgets/widget_gradient.h"
+#include "dialogs/dialog_color.h"
+#include "dialogs/dialog_gradient.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/scale.h>
+#include <synfig/exception.h>
+#include <synfigapp/main.h>
+#include "canvasview.h"
+#include "widgets/widget_distance.h"
+#include "widgets/widget_enum.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 ========================================================= */
+
+#define GRADIENT_HEIGHT 16
+#define DEFAULT_INCREMENT (0.25)
+#define DEFAULT_WIDTH (synfig::Distance(3,synfig::Distance::SYSTEM_POINTS))
+
+/* === G L O B A L S ======================================================= */
+
+class studio::Widget_Brush : public Gtk::DrawingArea
+{
+public:
+ Widget_Brush()
+ {
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Brush::redraw));
+
+ set_size_request(24,24);
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ add_events(Gdk::BUTTON1_MOTION_MASK);
+
+ synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+ synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+ synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+ studio::App::signal_instance_selected().connect(sigc::hide(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw)));
+ }
+
+ bool
+ redraw(GdkEventExpose */*bleh*/)
+ {
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+ const int h(get_height());
+ const int w(get_width());
+
+ float pixelsize(0);
+ if(App::get_selected_canvas_view())
+ {
+ const RendDesc& rend_desc(App::get_selected_canvas_view()->get_canvas()->rend_desc());
+ pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
+ }
+ else
+ {
+ RendDesc rend_desc;
+ pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
+ }
+ // Fill in the fill color
+ render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_fill_color());
+
+/*
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_fill_color()));
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+ get_window()->draw_rectangle(
+ gc,
+ true, // Fill?
+ 0,0, // x,y
+ w,h //w,h
+ );
+*/
+
+ // Draw in the circle
+ gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_outline_color()));
+ gc->set_function(Gdk::COPY);
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+ get_window()->draw_arc(
+ gc,
+ true,
+ round_to_int(((float)w/2.0f)-pixelsize/2.0f),
+ round_to_int(((float)h/2.0f)-pixelsize/2.0f),
+ round_to_int(pixelsize+0.6),
+ round_to_int(pixelsize+0.6),
+ 0,
+ 360*64
+ );
+
+ return true;
+ }
+
+ bool
+ on_event(GdkEvent *event)
+ {
+// const int x(static_cast<int>(event->button.x));
+ const int y(static_cast<int>(event->button.y));
+
+ const int h(get_height());
+// const int w(get_width());
+
+ switch(event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ break;
+ case GDK_BUTTON_RELEASE:
+ if(event->button.button==1) // Left click
+ {
+ Distance dist(synfigapp::Main::get_bline_width());
+
+ if(y<h/2) // increase BLine size
+ {
+ dist+=DEFAULT_INCREMENT;
+ }
+ else // Decrease BLine size
+ {
+ dist-=DEFAULT_INCREMENT;
+ }
+ synfigapp::Main::set_bline_width(dist);
+ return true;
+ }
+ if(event->button.button==3)
+ {
+ // right click on bline width
+ synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
+ return true;
+ }
+ break;
+ case GDK_SCROLL:
+ {
+ Distance dist(synfigapp::Main::get_bline_width());
+
+ switch(event->scroll.direction){
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_RIGHT:
+ dist+=DEFAULT_INCREMENT;
+ break;
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_LEFT:
+ dist-=DEFAULT_INCREMENT;
+ break;
+ }
+ synfigapp::Main::set_bline_width(dist);
+ return true;
+ }
+ default:
+ break;
+ }
+
+ return false;
+ }
+
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Defaults::Widget_Defaults()
+{
+ //set_size_request(48,48+GRADIENT_HEIGHT+16);
+ //set_size_request(48,-1);
+
+ {
+ Gtk::Table* subtable(manage(new Gtk::Table()));
+
+ // Outline Color
+ widget_otln_color=manage(new Widget_Color());
+ widget_otln_color->show();
+ widget_otln_color->set_size_request(16,16);
+ widget_otln_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_otln_color_clicked));
+ subtable->attach(*widget_otln_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ tooltips_.set_tip(*widget_otln_color,_("Outline Color"));
+
+ // Fill Color
+ widget_fill_color=manage(new Widget_Color());
+ widget_fill_color->show();
+ widget_fill_color->set_size_request(16,16);
+ widget_fill_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fill_color_clicked));
+ subtable->attach(*widget_fill_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ tooltips_.set_tip(*widget_fill_color,_("Fill Color"));
+
+ Gtk::Image* icon;
+
+ // Swap button
+ Gtk::Button* button_swap(manage(new Gtk::Button()));
+ button_swap->show();
+ button_swap->set_relief(Gtk::RELIEF_NONE);
+ button_swap->set_border_width(0);
+ icon=manage(new Gtk::Image(Gtk::StockID("synfig-swap_colors"),Gtk::IconSize(1)));
+ icon->show();
+ button_swap->add(*icon);
+ //button_swap->get_child()->set_size_request(16/3,16/3);
+ //button_swap->set_size_request(16/3,16/3);
+ dynamic_cast<Gtk::Misc*>(button_swap->get_child())->set_padding(0,0);
+ button_swap->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_swap_color_clicked));
+ subtable->attach(*button_swap, 4, 7, 0, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ tooltips_.set_tip(*button_swap,_("Swap Fill and\nOutline Colors"));
+
+ // Reset button
+ Gtk::Button* button_reset(manage(new Gtk::Button()));
+ button_reset->show();
+ button_reset->set_relief(Gtk::RELIEF_NONE);
+ button_reset->set_border_width(0);
+ icon=manage(new Gtk::Image(Gtk::StockID("synfig-reset_colors"),Gtk::IconSize(1)));
+ icon->show();
+ button_reset->add(*icon);
+ dynamic_cast<Gtk::Misc*>(button_reset->get_child())->set_padding(0,0);
+ //button_reset->set_size_request(16/3,16/3);
+ button_reset->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_reset_color_clicked));
+ subtable->attach(*button_reset, 0, 3, 4, 7, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ tooltips_.set_tip(*button_reset,_("Reset Colors to Black and White"));
+
+
+ attach(*subtable, 0, 1, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
+ subtable->set_size_request(36,36);
+ subtable->set_homogeneous(true);
+ subtable->show();
+ }
+ widget_brush=manage(new Widget_Brush());
+ widget_brush->show();
+ widget_brush->set_size_request(36,36);
+ attach(*widget_brush,1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
+ tooltips_.set_tip(*widget_brush,_("Brush Preview"));
+
+ widget_bline_width=manage(new Widget_Distance());
+ widget_bline_width->show();
+ bline_width_refresh();
+ widget_bline_width->set_digits(2);
+ widget_bline_width->set_range(0,10000000);
+ widget_bline_width->set_size_request(24,-1);
+ widget_bline_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_bline_width_changed));
+ attach(*widget_bline_width,1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ tooltips_.set_tip(*widget_bline_width,_("Brush Size"));
+
+
+ widget_blend_method=manage(new Widget_Enum());
+ widget_blend_method->show();
+ widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed));
+ widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method"));
+ attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+ tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
+
+ widget_interpolation=manage(new Widget_Enum());
+ widget_interpolation->show();
+ widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
+ widget_interpolation->set_param_desc(
+ ParamDesc("interpolation")
+ .set_hint("enum")
+ .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
+ .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
+ .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
+ .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
+ );
+ attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+ tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
+
+ widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
+ widget_opacity->show();
+ widget_opacity->set_digits(2);
+ widget_opacity->set_value_pos(Gtk::POS_LEFT);
+ widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
+ attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+ tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
+
+ widget_gradient=manage(new Widget_Gradient());
+ widget_gradient->show();
+ widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
+ widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
+ attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+ tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
+
+
+ // Signals
+ synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
+ synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
+ synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
+ synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_color_refresh));
+ synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
+ synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
+ synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
+
+ otln_color_refresh();
+ fill_color_refresh();
+ gradient_refresh();
+ blend_method_refresh();
+ opacity_refresh();
+ interpolation_refresh();
+/*
+ set_size_request(48,48+GRADIENT_HEIGHT);
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ add_events(Gdk::BUTTON1_MOTION_MASK);
+
+ synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+ synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+ synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+ synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+
+ if(App::dialog_gradient)
+ {
+ App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+ App::dialog_gradient->reset();
+ App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
+ }
+
+ if(App::dialog_color)
+ {
+ App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+ App::dialog_color->reset();
+ App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
+ }
+*/
+}
+
+Widget_Defaults::~Widget_Defaults()
+{
+}
+
+void
+Widget_Defaults::otln_color_refresh()
+{
+ widget_otln_color->set_value(synfigapp::Main::get_outline_color());
+}
+
+void
+Widget_Defaults::fill_color_refresh()
+{
+ widget_fill_color->set_value(synfigapp::Main::get_fill_color());
+}
+
+void
+Widget_Defaults::gradient_refresh()
+{
+ widget_gradient->set_value(synfigapp::Main::get_gradient());
+}
+
+void
+Widget_Defaults::bline_width_refresh()
+{
+ widget_bline_width->set_value(synfigapp::Main::get_bline_width());
+}
+
+void
+Widget_Defaults::blend_method_refresh()
+{
+ widget_blend_method->set_value(synfigapp::Main::get_blend_method());
+}
+
+void
+Widget_Defaults::interpolation_refresh()
+{
+ widget_interpolation->set_value(synfigapp::Main::get_interpolation());
+}
+
+void
+Widget_Defaults::opacity_refresh()
+{
+ widget_opacity->set_value(synfigapp::Main::get_opacity());
+}
+
+void
+Widget_Defaults::on_opacity_changed()
+{
+ synfigapp::Main::set_opacity(widget_opacity->get_value());
+}
+
+void
+Widget_Defaults::on_blend_method_changed()
+{
+ synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
+}
+
+void
+Widget_Defaults::on_interpolation_changed()
+{
+ synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
+}
+
+void
+Widget_Defaults::on_bline_width_changed()
+{
+ synfigapp::Main::set_bline_width(widget_bline_width->get_value());
+}
+
+void
+Widget_Defaults::on_otln_color_clicked()
+{
+ // Left click on outline color
+ App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+ App::dialog_color->reset();
+ App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
+ App::dialog_color->present();
+}
+
+void
+Widget_Defaults::on_fill_color_clicked()
+{
+ // Left click on fill color
+ App::dialog_color->set_color(synfigapp::Main::get_fill_color());
+ App::dialog_color->reset();
+ App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_color));
+ App::dialog_color->present();
+}
+
+void
+Widget_Defaults::on_swap_color_clicked()
+{
+ synfigapp::Main::color_swap();
+}
+
+void
+Widget_Defaults::on_reset_color_clicked()
+{
+ synfigapp::Main::set_fill_color(Color::white());
+ synfigapp::Main::set_outline_color(Color::black());
+}
+
+void
+Widget_Defaults::on_gradient_clicked()
+{
+ App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+ App::dialog_gradient->reset();
+ App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
+ App::dialog_gradient->set_default_button_set_sensitive(false);
+ App::dialog_gradient->present();
+}
+
+/*
+bool
+Widget_Defaults::redraw(GdkEventExpose*bleh)
+{
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+ const int h(get_height());
+ const int w(get_width());
+ const int size=std::min(h-GRADIENT_HEIGHT,w);
+
+ render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_fill_color());
+ render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
+ render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
+
+
+
+
+
+ Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+
+ gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+ layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
+ layout->set_alignment(Pango::ALIGN_CENTER);
+ layout->set_width(w/2);
+ get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
+
+ return true;
+}
+
+bool
+Widget_Defaults::on_event(GdkEvent *event)
+{
+ const int x(static_cast<int>(event->button.x));
+ const int y(static_cast<int>(event->button.y));
+
+ const int h(get_height());
+ const int w(get_width());
+ const int size=std::min(h-GRADIENT_HEIGHT,w);
+
+ switch(event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ break;
+ case GDK_BUTTON_PRESS:
+// if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
+ break;
+ case GDK_BUTTON_RELEASE:
+ if(event->button.button==1)
+ {
+ if(y>size)
+ {
+ // Left click on gradient
+ App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+ App::dialog_gradient->reset();
+ App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
+ App::dialog_gradient->present();
+ return true;
+ }
+ if(x>0 && x<=size)
+ {
+ if(x<size*3/4 && y<size*3/4)
+ {
+ // Left click on outline coloe
+ App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+ App::dialog_color->reset();
+ App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
+ App::dialog_color->present();
+ return true;
+ }
+ if(x>size*3/4 && y>size/4)
+ {
+ // Left click on fill color
+ App::dialog_color->set_color(synfigapp::Main::get_fill_color());
+ App::dialog_color->reset();
+ App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
+ App::dialog_color->present();
+ return true;
+ }
+ }
+ if(x>size) // Left click on BLine Width
+ {
+ Distance dist(synfigapp::Main::get_bline_width());
+
+ if(y<size/2) // increase BLine size
+ {
+ dist+=DEFAULT_INCREMENT;
+ }
+ else // Decrease BLine size
+ {
+ dist-=DEFAULT_INCREMENT;
+ }
+ synfigapp::Main::set_bline_width(dist);
+ }
+ }
+ if(event->button.button==3)
+ {
+ if(y>size)
+ {
+ // right click on gradient
+ synfigapp::Main::set_gradient_default_colors();
+ return true;
+ }
+ else
+ {
+ if(x<size)
+ {
+ // right click on colors
+ synfigapp::Main::color_swap();
+ return true;
+ }
+
+ if(x>w/2)
+ {
+ // right click on bline width
+ synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
+ }
+
+ }
+ }
+ break;
+ case GDK_SCROLL:
+ {
+ Distance dist(synfigapp::Main::get_bline_width());
+
+ if(event->scroll.direction==GDK_SCROLL_UP)
+ {
+ dist+=DEFAULT_INCREMENT;
+ }
+ else if(event->scroll.direction==GDK_SCROLL_DOWN)
+ {
+ dist-=DEFAULT_INCREMENT;
+ }
+ synfigapp::Main::set_bline_width(dist);
+ }
+ default:
+ break;
+ }
+
+ return false;
+}
+*/
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_defaults.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_WIDGET_DEFAULTS_H
+#define __SYNFIG_STUDIO_WIDGET_DEFAULTS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/table.h>
+#include <synfig/gradient.h>
+#include "widgets/widget_gradient.h"
+#include <gtkmm/tooltips.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 HScale; }
+
+namespace studio {
+
+class Widget_Brush;
+class Widget_Color;
+class Widget_Distance;
+class Widget_Enum;
+
+class Widget_Defaults : public Gtk::Table
+{
+ Widget_Brush *widget_brush;
+ Widget_Color *widget_otln_color;
+ Widget_Color *widget_fill_color;
+ Widget_Distance *widget_bline_width;
+ Widget_Gradient *widget_gradient;
+ Widget_Enum *widget_blend_method;
+ Widget_Enum *widget_interpolation;
+ Gtk::HScale *widget_opacity;
+
+ void otln_color_refresh();
+ void fill_color_refresh();
+ void gradient_refresh();
+ void bline_width_refresh();
+ void interpolation_refresh();
+
+ void on_bline_width_changed();
+ void on_otln_color_clicked();
+ void on_fill_color_clicked();
+ void on_swap_color_clicked();
+ void on_reset_color_clicked();
+ void on_gradient_clicked();
+ void on_interpolation_changed();
+
+ void blend_method_refresh();
+ void on_blend_method_changed();
+
+ void opacity_refresh();
+ void on_opacity_changed();
+
+ Gtk::Tooltips tooltips_;
+
+public:
+
+ Widget_Defaults();
+
+ ~Widget_Defaults();
+
+// bool redraw(GdkEventExpose*bleh=NULL);
+
+// bool on_event(GdkEvent *event);
+}; // END of class BlackLevelSelector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_distance.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 "widgets/widget_distance.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 ======================================================= */
+
+Widget_Distance::Widget_Distance():
+ Gtk::SpinButton(0.05,5),
+ distance_(1, Distance::SYSTEM_POINTS),
+ adjustment(0,-100000000,100000000,1,1,0)
+{
+ set_adjustment(adjustment);
+ set_numeric(false);
+}
+
+Widget_Distance::~Widget_Distance()
+{
+}
+
+int
+Widget_Distance::on_input(double* new_value)
+{
+ distance_=synfig::String(get_text());
+ *new_value=distance_.get();
+ return 1;
+}
+
+bool
+Widget_Distance::on_output()
+{
+ try{
+ distance_=get_adjustment()->get_value();
+ set_text(distance_.get_string(get_digits()));
+ } catch (...) { /* synfig::error("Widget_Distance::on_output(): Caught something..."); */ }
+ return true;
+}
+
+void
+Widget_Distance::set_value(const synfig::Distance &data)
+{
+ distance_=data;
+ get_adjustment()->set_value(distance_.get());
+}
+
+synfig::Distance
+Widget_Distance::get_value() const
+{
+ distance_=get_adjustment()->get_value();
+ return distance_;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_distance.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_WIDGET_DISTANCE_H
+#define __SYNFIG_STUDIO_WIDGET_DISTANCE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <synfig/distance.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 Widget_Distance : public Gtk::SpinButton
+{
+ //sigc::signal<void> signal_value_changed_;
+
+ mutable synfig::Distance distance_;
+
+ Gtk::Adjustment adjustment;
+
+protected:
+
+ int on_input(double* new_value);
+ bool on_output();
+
+public:
+ //sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+ void set_value(const synfig::Distance &data);
+ synfig::Distance get_value()const;
+ Widget_Distance();
+ ~Widget_Distance();
+}; // END of class Widget_Distance
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_enum.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/menu.h>
+#include "widgets/widget_enum.h"
+#include <ETL/stringf>
+#include <synfig/valuenode.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 ======================================================= */
+
+Widget_Enum::Widget_Enum()
+{
+}
+
+Widget_Enum::~Widget_Enum()
+{
+}
+
+void
+Widget_Enum::set_param_desc(const synfig::ParamDesc &x)
+{
+ param_desc=x;
+ //refresh();
+}
+
+void
+Widget_Enum::set_value_(int data)
+{
+ set_value(data);
+ activate();
+}
+
+void
+Widget_Enum::refresh()
+{
+ enum_menu = manage(new class Gtk::Menu());
+
+ std::list<synfig::ParamDesc::EnumData> enum_list=param_desc.get_enum_list();
+ std::list<synfig::ParamDesc::EnumData>::iterator iter;
+
+ String name=strprintf("(%d)",value);
+
+ for(iter=enum_list.begin();iter!=enum_list.end();iter++)
+ if(iter->value!=value)
+ enum_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->local_name,
+ sigc::bind(sigc::mem_fun(*this,&Widget_Enum::set_value_),iter->value)
+ ));
+ else
+ name=iter->local_name;
+
+ enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
+
+ set_menu(*enum_menu);
+}
+
+void
+Widget_Enum::set_value(int data)
+{
+ value=data;
+
+ refresh();
+
+ set_history(0);
+}
+
+int
+Widget_Enum::get_value() const
+{
+ return value;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_enum.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_WIDGET_ENUM_H
+#define __SYNFIG_STUDIO_WIDGET_ENUM_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/layer.h>
+#include <gtkmm/optionmenu.h>
+#include <synfig/paramdesc.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 Menu; };
+
+namespace studio {
+
+class Widget_Enum : public Gtk::OptionMenu
+{
+ Gtk::Menu *enum_menu;
+ synfig::ParamDesc param_desc;
+
+ int value;
+ void set_value_(int data);
+public:
+
+ Widget_Enum();
+ ~Widget_Enum();
+
+ void set_param_desc(const synfig::ParamDesc &x);
+ void refresh();
+
+ void set_value(int data);
+ int get_value() const;
+}; // END of class Widget_Enum
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_filename.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 "widgets/widget_filename.h"
+#include "app.h"
+#include "canvasview.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 ======================================================= */
+
+Widget_Filename::Widget_Filename()
+{
+ entry_filename=manage(new Gtk::Entry());
+ label_find= manage(new Gtk::Label(_("Find")));
+ button_choose=manage(new Gtk::Button());
+ Pango::AttrList attr_list;
+ {
+ Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
+ pango_size.set_start_index(0);
+ pango_size.set_end_index(64);
+ attr_list.change(pango_size);
+ }
+ label_find->set_attributes(attr_list);
+ label_find->set_ellipsize(Pango::ELLIPSIZE_END);
+ button_choose->add(*label_find);
+
+ pack_start(*entry_filename);
+ pack_start(*button_choose);
+ entry_filename->show();
+ button_choose->show();
+ label_find->show();
+
+ button_choose->signal_clicked().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_button_choose_pressed));
+ //entry_filename->signal_value_changed().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
+ entry_filename->signal_activate().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
+}
+
+Widget_Filename::~Widget_Filename()
+{
+}
+
+void
+Widget_Filename::set_has_frame(bool x)
+{
+ entry_filename->set_has_frame(x);
+}
+
+
+void
+Widget_Filename::set_value(const std::string &data)
+{
+ entry_filename->set_text(data);
+}
+
+string
+Widget_Filename::get_value() const
+{
+ try
+ {
+ return entry_filename->get_text();
+ }
+ catch(...)
+ {
+ throw string("Caught unknown exception");
+ }
+}
+
+void
+Widget_Filename::on_value_changed()
+{
+ signal_value_changed()();
+}
+
+void
+Widget_Filename::on_button_choose_pressed()
+{
+ string filename=entry_filename->get_text();
+ if(filename.empty())
+ filename=".";
+ else
+ filename = etl::absolute_path(
+ etl::dirname(App::get_selected_canvas_view()->get_canvas()->get_file_name()) +
+ ETL_DIRECTORY_SEPARATOR +
+ filename);
+ if(App::dialog_open_file(_("Choose File"), filename, MISC_DIR_PREFERENCE))
+ entry_filename->set_text(filename);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_filename.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_WIDGET_FILENAME_H
+#define __SYNFIG_STUDIO_WIDGET_FILENAME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/box.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/button.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 Widget_Filename : public Gtk::HBox
+{
+ Gtk::Entry *entry_filename;
+ Gtk::Button *button_choose;
+ Gtk::Label *label_find;
+
+ void on_button_choose_pressed();
+
+ sigc::signal<void> signal_value_changed_;
+
+public:
+ sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+ Glib::SignalProxy0<void> signal_activate() { return entry_filename->signal_activate(); }
+
+ void on_value_changed();
+
+ void set_value(const std::string &data);
+ std::string get_value() const;
+ void set_has_frame(bool x);
+ Widget_Filename();
+ ~Widget_Filename();
+}; // END of class Widget_Filename
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_gradient.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 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 "widgets/widget_gradient.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <synfig/exception.h>
+#include <ETL/misc>
+
+#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 ================================================= */
+
+void
+studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
+{
+ int height = ca.get_height();
+ int width = ca.get_width()-4;
+
+ float sample_width(1.0f/(float)width);
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+ const Color bg1(0.25, 0.25, 0.25);
+ const Color bg2(0.5, 0.5, 0.5);
+ Gdk::Color gdk_c;
+ int i;
+ for(i=0;i<width;i++)
+ {
+ const Color c(gradient(float(i)/float(width),sample_width));
+ const Color c1(Color::blend(c,bg1,1.0).clamped());
+ const Color c2(Color::blend(c,bg2,1.0).clamped());
+ gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
+ gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
+ gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
+ gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
+ gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
+ gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
+
+ if((i*2/height)&1)
+ {
+ gdk_c.set_rgb(r1,g1,b1);
+ gc->set_rgb_fg_color(gdk_c);
+ window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
+
+ gdk_c.set_rgb(r2,g2,b2);
+ gc->set_rgb_fg_color(gdk_c);
+ window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
+ }
+ else
+ {
+ gdk_c.set_rgb(r2,g2,b2);
+ gc->set_rgb_fg_color(gdk_c);
+ window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
+
+ gdk_c.set_rgb(r1,g1,b1);
+ gc->set_rgb_fg_color(gdk_c);
+ window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
+ }
+ }
+ gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+ window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
+ gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
+}
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Gradient::Widget_Gradient():
+ editable_(false)
+{
+ set_size_request(-1,64);
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Gradient::redraw));
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ add_events(Gdk::BUTTON1_MOTION_MASK);
+
+}
+
+Widget_Gradient::~Widget_Gradient()
+{
+}
+
+#define CONTROL_HEIGHT 16
+bool
+Widget_Gradient::redraw(GdkEventExpose */*bleh*/)
+{
+ const int h(get_height());
+ const int w(get_width());
+
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+ Gdk::Rectangle area(0,0,w,h);
+ if(!editable_)
+ {
+ render_gradient_to_window(get_window(),area,gradient_);
+ return true;
+ }
+
+ render_gradient_to_window(get_window(),Gdk::Rectangle(0,0,w,h-CONTROL_HEIGHT),gradient_);
+
+ gc->set_rgb_fg_color(Gdk::Color("#7f7f7f"));
+ get_window()->draw_rectangle(gc, false, 0, h-CONTROL_HEIGHT, w, CONTROL_HEIGHT);
+
+ Gradient::iterator iter,selected_iter;
+ bool show_selected(false);
+ for(iter=gradient_.begin();iter!=gradient_.end();iter++)
+ {
+ if(*iter!=selected_cpoint)
+ get_style()->paint_arrow(
+ get_window(),
+ (*iter==selected_cpoint)?Gtk::STATE_SELECTED:Gtk::STATE_ACTIVE,
+ Gtk::SHADOW_OUT,
+ area,
+ *this,
+ " ",
+ Gtk::ARROW_UP,
+ 1,
+ int(iter->pos*w)-CONTROL_HEIGHT/2+1,
+ h-CONTROL_HEIGHT,
+ CONTROL_HEIGHT,
+ CONTROL_HEIGHT
+ );
+ else
+ {
+ selected_iter=iter;
+ show_selected=true;
+ }
+ }
+
+ // we do this so that we can be sure that
+ // the selected marker is shown on top
+ if(show_selected)
+ {
+ get_style()->paint_arrow(
+ get_window(),
+ Gtk::STATE_SELECTED,
+ Gtk::SHADOW_OUT,
+ area,
+ *this,
+ " ",
+ Gtk::ARROW_UP,
+ 1,
+ round_to_int(selected_iter->pos*w)-CONTROL_HEIGHT/2+1,
+ h-CONTROL_HEIGHT,
+ CONTROL_HEIGHT,
+ CONTROL_HEIGHT
+ );
+ }
+
+ return true;
+}
+
+void
+Widget_Gradient::insert_cpoint(float x)
+{
+ Gradient::CPoint new_cpoint;
+ new_cpoint.pos=x;
+ new_cpoint.color=gradient_(x);
+ gradient_.push_back(new_cpoint);
+ gradient_.sort();
+ gradient_.sort();
+ set_selected_cpoint(new_cpoint);
+ queue_draw();
+}
+
+void
+Widget_Gradient::remove_cpoint(float x)
+{
+ gradient_.erase(gradient_.proximity(x));
+ signal_value_changed_();
+ queue_draw();
+}
+
+void
+Widget_Gradient::popup_menu(float x)
+{
+ Gtk::Menu* menu(manage(new Gtk::Menu()));
+ menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+
+ menu->items().clear();
+
+ menu->items().push_back(
+ Gtk::Menu_Helpers::MenuElem(
+ _("Insert CPoint"),
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Widget_Gradient::insert_cpoint),
+ x
+ )
+ )
+ );
+
+ if(!gradient_.empty())
+ {
+ menu->items().push_back(
+ Gtk::Menu_Helpers::MenuElem(
+ _("Remove CPoint"),
+ sigc::bind(
+ sigc::mem_fun(*this,&studio::Widget_Gradient::remove_cpoint),
+ x
+ )
+ )
+ );
+ }
+
+ menu->popup(0,0);
+}
+
+void
+Widget_Gradient::set_value(const synfig::Gradient& x)
+{
+ gradient_=x;
+ if(gradient_.size())
+ set_selected_cpoint(*gradient_.proximity(0.0f));
+ queue_draw();
+}
+
+void
+Widget_Gradient::set_selected_cpoint(const synfig::Gradient::CPoint &x)
+{
+ selected_cpoint=x;
+ signal_cpoint_selected_(selected_cpoint);
+ queue_draw();
+}
+
+void
+Widget_Gradient::update_cpoint(const synfig::Gradient::CPoint &x)
+{
+ try
+ {
+ Gradient::iterator iter(gradient_.find(x));
+ iter->pos=x.pos;
+ iter->color=x.color;
+ gradient_.sort();
+ queue_draw();
+ }
+ catch(synfig::Exception::NotFound)
+ {
+ // Yotta...
+ }
+}
+
+bool
+Widget_Gradient::on_event(GdkEvent *event)
+{
+ //if(editable_)
+ {
+ const int x(static_cast<int>(event->button.x));
+ const int y(static_cast<int>(event->button.y));
+
+ float pos((float)x/(float)get_width());
+ if(pos<0.0f)pos=0.0f;
+ if(pos>1.0f)pos=1.0f;
+
+ switch(event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ if(editable_ && y>get_height()-CONTROL_HEIGHT)
+ {
+ if(!gradient_.size()) return true;
+ Gradient::iterator iter(gradient_.find(selected_cpoint));
+ //! Use SHIFT to stack two CPoints together.
+ if(event->button.state&GDK_SHIFT_MASK)
+ {
+ float begin(-100000000),end(100000000);
+ Gradient::iterator before(iter),after(iter);
+ after++;
+ if(iter!=gradient_.begin())
+ {
+ before--;
+ begin=before->pos;
+ }
+ if(after!=gradient_.end())
+ {
+ end=after->pos;
+ }
+
+ if(pos>end)
+ pos=end;
+ if(pos<begin)
+ pos=begin;
+
+ iter->pos=pos;
+ }
+ else
+ {
+ iter->pos=pos;
+ gradient_.sort();
+ }
+
+// signal_value_changed_();
+ changed_=true;
+ queue_draw();
+ return true;
+ }
+ break;
+ case GDK_BUTTON_PRESS:
+ changed_=false;
+ if(event->button.button==1)
+ {
+ if(editable_ && y>get_height()-CONTROL_HEIGHT)
+ {
+ set_selected_cpoint(*gradient_.proximity(pos));
+ queue_draw();
+ return true;
+ }
+ else
+ {
+ signal_clicked_();
+ return true;
+ }
+ }
+ else if(editable_ && event->button.button==3)
+ {
+ popup_menu(pos);
+ return true;
+ }
+ break;
+ case GDK_BUTTON_RELEASE:
+ if(editable_ && event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
+ {
+ set_selected_cpoint(*gradient_.proximity(pos));
+ if(changed_)signal_value_changed_();
+ return true;
+ }
+ default:
+ break;
+ }
+ }
+
+ return false;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_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_WIDGET_GRADIENT_H
+#define __SYNFIG_STUDIO_WIDGET_GRADIENT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.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 studio {
+
+void render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient);
+
+class Widget_Gradient : public Gtk::DrawingArea
+{
+ sigc::signal<void> signal_value_changed_;
+ sigc::signal<void> signal_clicked_;
+
+ sigc::signal<void,synfig::Gradient::CPoint> signal_cpoint_selected_;
+
+ synfig::Gradient gradient_;
+
+ bool editable_;
+
+ bool changed_;
+
+ synfig::Gradient::CPoint selected_cpoint;
+
+ void popup_menu(float x);
+
+ void insert_cpoint(float x);
+
+ void remove_cpoint(float x);
+
+public:
+
+ Widget_Gradient();
+
+ ~Widget_Gradient();
+
+ sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+ sigc::signal<void>& signal_clicked() { return signal_clicked_; }
+
+ sigc::signal<void,synfig::Gradient::CPoint>& signal_cpoint_selected() { return signal_cpoint_selected_; }
+
+ void set_value(const synfig::Gradient& x);
+
+ const synfig::Gradient& get_value()const { return gradient_; }
+
+ void set_editable(bool x=true) { editable_=x; }
+
+ bool get_editable()const { return editable_; }
+
+
+
+ void set_selected_cpoint(const synfig::Gradient::CPoint &x);
+
+ const synfig::Gradient::CPoint& get_selected_cpoint() { return selected_cpoint; }
+
+ void update_cpoint(const synfig::Gradient::CPoint &x);
+
+
+
+ bool redraw(GdkEventExpose*bleh=NULL);
+
+ bool on_event(GdkEvent *event);
+}; // END of class BlackLevelSelector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_keyframe_list.cpp
+** \brief A custom widget to manage keyframes in the timeline.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2009 Carlos López
+**
+** 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 "widget_keyframe_list.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <synfig/exception.h>
+#include <ETL/misc>
+
+#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 ========================================================= */
+#define WIDGET_KEYFRAME_LIST_DEFAULT_FPS 24.0
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Keyframe_List::Widget_Keyframe_List():
+ adj_default(0,0,2,1/WIDGET_KEYFRAME_LIST_DEFAULT_FPS,10/WIDGET_KEYFRAME_LIST_DEFAULT_FPS),
+ kf_list_(&default_kf_list_),
+ time_ratio("4f", WIDGET_KEYFRAME_LIST_DEFAULT_FPS)
+{
+ adj_timescale=0;
+ editable_=true;
+ fps=WIDGET_KEYFRAME_LIST_DEFAULT_FPS;
+ set_size_request(-1,64);
+ //!This signal is called when the widget need to be redrawn
+ signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Keyframe_List::redraw));
+ //! The widget respond to mouse button press and release and to
+ //! left button motion
+ add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ add_events(Gdk::BUTTON1_MOTION_MASK /*| Gdk::BUTTON3_MOTION_MASK*/);
+ add_events(Gdk::POINTER_MOTION_MASK);
+ set_time_adjustment(&adj_default);
+ queue_draw();
+}
+
+Widget_Keyframe_List::~Widget_Keyframe_List()
+{
+}
+
+bool
+Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/)
+{
+
+ const int h(get_height());
+ const int w(get_width());
+
+ //!Boundaries of the drawing area in time units.
+ synfig::Time top(adj_timescale->get_upper());
+ synfig::Time bottom(adj_timescale->get_lower());
+
+ //! The graphic context
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+ //! A rectangle that defines the drawing area.
+ Gdk::Rectangle area(0,0,w,h);
+
+ //! draw a background
+ gc->set_rgb_fg_color(Gdk::Color("#9d9d9d"));
+ get_window()->draw_rectangle(gc, true, 0, 0, w, h);
+
+ if(!editable_)
+ {
+ return true; //needs fixing!
+ }
+ //!Returns if there are not keyframes to draw.
+ if (kf_list_->empty()) return false;
+
+ //!Loop all the keyframes
+ synfig::KeyframeList::iterator iter,selected_iter;
+ bool show_selected(false);
+ for(iter=kf_list_->begin();iter!=kf_list_->end();iter++)
+ {
+ //!do not draw keyframes out of the widget boundaries
+ if (iter->get_time()>top || iter->get_time()<bottom)
+ continue;
+ //! If the keyframe is not the selected one
+ if(*iter!=selected_kf)
+ {
+ const int x((int)((float)(iter->get_time()-bottom) * (w/(top-bottom)) ) );
+ get_style()->paint_arrow(get_window(), Gtk::STATE_NORMAL,
+ Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+ x-h/2+1, 0, h, h );
+ }
+ else
+ {
+ selected_iter=iter;
+ show_selected=true;
+ }
+ }
+
+ // we do this so that we can be sure that
+ // the selected keyframe is shown on top
+ if(show_selected)
+ {
+ // If not dragging just show the selected keyframe
+ if (!dragging_)
+ {
+ int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+ get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+ Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+ x-h/2+1, 0, h, h );
+ }
+ // If dragging then show the selected as insensitive and the
+ // dragged as selected
+ else
+ {
+ int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+ get_style()->paint_arrow(get_window(), Gtk::STATE_INSENSITIVE,
+ Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+ x-h/2, 0, h, h );
+ x=(int)((float)(dragging_kf_time-bottom) * (w/(top-bottom)) ) ;
+ get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+ Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+ x-h/2+1, 0, h, h );
+ }
+ }
+ return true;
+}
+
+
+void
+Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
+{
+ kf_list_=x;
+ set_selected_keyframe(selected_none);
+ selected_=false;
+ dragging_=false;
+}
+
+void
+Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
+{
+ selected_kf=x;
+ selected_=true;
+ dragging_kf_time=selected_kf.get_time();
+ //signal_keyframe_selected_(selected_kf);
+ dragging_=false;
+ queue_draw();
+}
+
+bool
+Widget_Keyframe_List::perform_move_kf(bool delta=false)
+{
+ if(!selected_)
+ return false;
+ if(dragging_kf_time == selected_kf.get_time())
+ return false; // change this checking if not sticked to integer frames
+ Time selected_kf_time(selected_kf.get_time());
+ Time prev, next;
+ kf_list_->find_prev_next(selected_kf_time, prev, next);
+ // Not possible to set delta to the first keyframe
+ // perform normal movement
+ // As suggested by Zelgadis it is better to not perform anything.
+ if (prev==Time::begin() && delta==true)
+ {
+ synfig::info(_("Not possible to ALT-drag the first keyframe"));
+ return false;
+ }
+ if(!delta)
+ {
+ synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+ if(!action)
+ return false;
+ selected_kf.set_time(dragging_kf_time);
+ action->set_param("canvas",canvas_interface_->get_canvas());
+ action->set_param("canvas_interface",canvas_interface_);
+ action->set_param("keyframe",selected_kf);
+ try
+ {
+ canvas_interface_->get_instance()->perform_action(action);
+ }
+ catch(...)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ Keyframe prev_kf(*kf_list_->find_prev(selected_kf_time));
+ Time prev_kf_time(prev_kf.get_time());
+ if (prev_kf_time >= dragging_kf_time) //Not allowed
+ {
+ synfig::warning(_("Delta set not allowed"));
+ synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::prev_kf_time=%s", delta, prev_kf_time.get_string().c_str());
+ synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::dragging_kf_time=%s", delta, dragging_kf_time.get_string().c_str());
+ return false;
+ }
+ else
+ {
+ Time old_delta_time(selected_kf_time-prev_kf_time);
+ Time new_delta_time(dragging_kf_time-prev_kf_time);
+ Time change_delta(new_delta_time-old_delta_time);
+ synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
+ if(!action)
+ return false;
+ action->set_param("canvas",canvas_interface_->get_canvas());
+ action->set_param("canvas_interface",canvas_interface_);
+ action->set_param("keyframe",prev_kf);
+ action->set_param("delta",change_delta);
+ canvas_interface_->get_instance()->perform_action(action);
+ }
+ }
+ queue_draw();
+ return true;
+}
+
+bool
+Widget_Keyframe_List::on_event(GdkEvent *event)
+{
+ const int x(static_cast<int>(event->button.x));
+ //const int y(static_cast<int>(event->button.y));
+ //!Boundaries of the drawing area in time units.
+ synfig::Time top(adj_timescale->get_upper());
+ synfig::Time bottom(adj_timescale->get_lower());
+ //!pos is the [0,1] relative horizontal place on the widget
+ float pos((float)x/(get_width()));
+ if(pos<0.0f)pos=0.0f;
+ if(pos>1.0f)pos=1.0f;
+ //! The time where the event x is
+ synfig::Time t((float)(bottom+pos*(top-bottom)));
+ //Do not respond mouse events if the list is empty
+ if(!kf_list_->size())
+ return true;
+
+ //! here the guts of the event
+ switch(event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ if(editable_)
+ {
+ // here is captured mouse motion
+ // AND left or right mouse button pressed
+ if (event->motion.state & (GDK_BUTTON1_MASK /*| GDK_BUTTON3_MASK*/))
+ {
+ // stick to integer frames. It can be optional in the future
+ if(fps) t = floor(t*fps + 0.5)/fps;
+ dragging_kf_time=t;
+ dragging_=true;
+ queue_draw();
+ return true;
+ }
+ // here is captured mouse motion
+ // AND NOT left or right mouse button pressed
+ else
+ {
+ Glib::ustring ttip="";
+ synfig::Time p_t,n_t;
+ kf_list_->find_prev_next(t, p_t, n_t);
+ if( (p_t==Time::begin() && n_t==Time::end())
+ ||
+ ((t-p_t)>time_ratio && (n_t-t)>time_ratio)
+ )
+ {
+ ttip = _("Click and drag keyframes");
+ }
+ else if ((t-p_t)<(n_t-t))
+ {
+ synfig::Keyframe kf(*kf_list_->find_prev(t));
+ synfig::String kf_name(kf.get_description().c_str());
+ ttip = kf_name.c_str();
+ }
+ else
+ {
+ synfig::Keyframe kf(*kf_list_->find_next(t));
+ synfig::String kf_name(kf.get_description().c_str());
+ ttip = kf_name.c_str();
+ }
+ tooltips.set_tip(*this, ttip);
+ dragging_=false;
+ queue_draw();
+ return true;
+ }
+ }
+ break;
+ case GDK_BUTTON_PRESS:
+ changed_=false;
+ dragging_=false;
+ if(event->button.button==1 /*|| event->button.button==3*/)
+ {
+ if(editable_)
+ {
+ synfig::Time prev_t,next_t;
+ kf_list_->find_prev_next(t, prev_t, next_t);
+ if( (prev_t==Time::begin() && next_t==Time::end())
+ ||
+ ((t-prev_t)>time_ratio && (next_t-t)>time_ratio)
+ )
+ {
+ set_selected_keyframe(selected_none);
+ selected_=false;
+ queue_draw();
+ }
+ else if ((t-prev_t)<(next_t-t))
+ {
+ set_selected_keyframe(*(kf_list_->find_prev(t)));
+ queue_draw();
+ selected_=true;
+ }
+ else
+ {
+ set_selected_keyframe(*(kf_list_->find_next(t)));
+ queue_draw();
+ selected_=true;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ break;
+ case GDK_BUTTON_RELEASE:
+ if(editable_ && (event->button.button==1 /*|| event->button.button==3*/))
+ {
+ // stick to integer frames.
+ if(fps) t = floor(t*fps + 0.5)/fps;
+ bool stat=false;
+ if(dragging_)
+ {
+ //if (event->button.button==3)
+ if(event->button.state & GDK_MOD1_MASK)
+ {
+ stat=perform_move_kf(true);
+ }
+ else
+ {
+ stat=perform_move_kf(false);
+ }
+ }
+ dragging_=false;
+ return stat;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+
+void Widget_Keyframe_List::set_time_adjustment(Gtk::Adjustment *x)
+{
+ //disconnect old connections
+ time_value_change.disconnect();
+ time_other_change.disconnect();
+
+ //connect update function to new adjustment
+ adj_timescale = x;
+
+ if(x)
+ {
+ time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+ time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+ }
+}
+
+void
+Widget_Keyframe_List::set_fps(float d)
+{
+ if(fps != d)
+ {
+ fps = d;
+ //update everything since we need to redraw already
+ queue_draw();
+ }
+}
+
+void
+Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
+{
+ canvas_interface_=h;
+ // Store the values used fomr the canvas interface.
+ if (canvas_interface_)
+ {
+ set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
+ set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
+ }
+}
+
+
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_keyframe_list.h
+** \brief A custom widget to manage keyframes in the timeline.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2009 Carlos López
+**
+** 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_WIDGET_KEYFRAME_LIST_H
+#define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/tooltips.h>
+#include <synfig/keyframe.h>
+#include <sigc++/connection.h>
+#include <synfigapp/canvasinterface.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_Keyframe_List : public Gtk::DrawingArea
+{
+ //! Tooltips class. It is deprecated since gtkmm 2.12
+ //! replace with Tooltip class or use the own tooltip widget's members
+ Gtk::Tooltips tooltips;
+
+ //! The canvas interface being watched
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+ //! Time adjustment window
+ Gtk::Adjustment adj_default;
+ Gtk::Adjustment *adj_timescale;
+
+ //!The list of keyframes to be drawn on the widget and moved with mouse
+ synfig::KeyframeList default_kf_list_;
+ mutable synfig::KeyframeList* kf_list_;
+
+ //! The frames per second of the canvas
+ float fps;
+
+ //! Time radius to click a keyframe
+ synfig::Time time_ratio;
+
+ //!True if it is editable. Keyframes can be moved.
+ bool editable_;
+
+ //!True if a keyframe is being dragged.
+ bool dragging_;
+
+ //!True if a keyframe has been moved
+ bool changed_;
+
+ //!Holds the selected keyframe of the keyframe list
+ synfig::Keyframe selected_kf;
+ synfig::Keyframe selected_none;
+ bool selected_;
+
+ //!The time of the selected keyframe
+ synfig::Time selected_kf_time;
+
+ //!The time of the selected keyframe during draging
+ synfig::Time dragging_kf_time;
+
+ //!Connectors for handling the signals of the time adjustment
+ sigc::connection time_value_change;
+ sigc::connection time_other_change;
+
+public:
+
+ //!Default constructor
+ Widget_Keyframe_List();
+
+ //!Destructror
+ ~Widget_Keyframe_List();
+
+ //!Loads a new keyframe list on the widget.
+ void set_kf_list(synfig::KeyframeList* x);
+
+ //!Member for private data.
+ synfig::KeyframeList* get_kf_list()const { return kf_list_; }
+
+ //!Member for private data
+ void set_editable(bool x=true) { editable_=x; }
+
+ //!Member for private data
+ bool get_editable()const { return editable_; }
+
+
+ //!Store the selected keyframe value
+ void set_selected_keyframe(const synfig::Keyframe &x);
+
+ //!Returns the selected keyframe
+ const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
+
+ //! Set the time adjustment and proper connects its change signals
+ void set_time_adjustment(Gtk::Adjustment *x);
+
+ //! Set the fps
+ void set_fps(float x);
+
+ //! Set the canvas interface
+ void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
+
+ //! Performs the keyframe movement. Returns true if it was sucessful
+ //! @return true: if success otherwise false
+ //! |delta=false: permorm normal move. true: perform delta movement
+ bool perform_move_kf(bool delta);
+
+
+
+/* ======================= EVENTS HANDLERS ===========================*/
+ //!Redraw event. Should draw all the keyframes + the selected + the dragged
+ bool redraw(GdkEventExpose*bleh=NULL);
+
+ //!Mouse event handler.
+ bool on_event(GdkEvent *event);
+}; // END of class Keyframe_List
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_sound.cpp
+** \brief Widget Sound Implementation 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/adjustment.h>
+
+#include <synfig/general.h>
+#include <ETL/clock>
+
+#include "widgets/widget_sound.h"
+#include "audiocontainer.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+//using namespace synfig;
+
+using studio::AudioProfile;
+
+/* === 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 ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+studio::Widget_Sound::Widget_Sound()
+{
+}
+
+studio::Widget_Sound::~Widget_Sound()
+{
+}
+
+void studio::Widget_Sound::set_position(double t)
+{
+ //synfig::info("Setting position to %.2lf s", t);
+ if(adj_timescale && t != adj_timescale->get_value())
+ {
+ float upper = adj_timescale->get_upper();
+ float lower = adj_timescale->get_lower();
+ float framesize = upper - lower;
+
+ if(t < lower)
+ {
+ lower -= ceil((lower-t)/framesize)*framesize;
+ upper = lower + framesize;
+ adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
+ adj_timescale->set_value(t);
+ adj_timescale->changed(); adj_timescale->value_changed();
+ }else
+ if(t > upper)
+ {
+ lower += ceil((t-upper)/framesize)*framesize;
+ upper = lower + framesize;
+ adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
+ adj_timescale->set_value(t);
+ adj_timescale->changed(); adj_timescale->value_changed();
+ }else
+ {
+ adj_timescale->set_value(t);
+ adj_timescale->value_changed();
+ }
+ }
+}
+
+double studio::Widget_Sound::get_position() const
+{
+ if(adj_timescale)
+ {
+ return adj_timescale->get_value();
+ }
+ return 0;
+}
+
+bool studio::Widget_Sound::set_profile(etl::handle<AudioProfile> p)
+{
+ clear();
+
+ //set the profile
+ audioprof = p;
+
+ if(!audioprof)
+ {
+ clear();
+ return false;
+ }
+
+ return true;
+}
+
+etl::handle<AudioProfile> studio::Widget_Sound::get_profile() const
+{
+ return audioprof;
+}
+
+void studio::Widget_Sound::clear()
+{
+ audioprof.detach();
+}
+
+void studio::Widget_Sound::draw()
+{
+ on_expose_event();
+}
+
+bool studio::Widget_Sound::on_expose_event(GdkEventExpose */*heh*/)
+{
+ if(!get_window()) return false;
+
+ //clear the background to dark grey
+ Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(get_window());
+
+ if(!gc) return false;
+
+ {
+ Gdk::Rectangle r(0,0,get_width(),get_height());
+ get_window()->begin_paint_rect(r);
+ }
+ Gdk::Color c("#3f3f3f");
+ gc->set_rgb_fg_color(c);
+ gc->set_background(c);
+
+ int w = get_width();
+ int baseline = get_height()/2;
+ get_window()->draw_rectangle(gc,true,0,0,w,get_height());
+
+ //set up the color to be blue
+ c.set_rgb_p(0,0.5,1);
+ gc->set_rgb_fg_color(c);
+
+ //draw the base line
+ get_window()->draw_line(gc,0,baseline,w,baseline);
+
+ //redraw all the samples from begin to end, but only if we have samples to draw (or there is no space to draw)
+
+ //synfig::warning("Ok rendered everything, now must render actual sound wave");
+ if(!audioprof || !adj_timescale || !w)
+ {
+ get_window()->end_paint();
+ return true;
+ }
+
+ //draw you fool!
+ float framesize = adj_timescale->get_upper() - adj_timescale->get_lower();
+ if(framesize)
+ {
+ float delta=0,cum=0;
+
+ //position in sample space
+ int begin=0,end=0;
+ int cur=0,maxs=0,mins=0;
+
+ int i=0; //pixel counter
+
+ //etl::clock check; check.reset();
+
+ float position = adj_timescale->get_value();
+ float samplerate = audioprof->get_samplerate();
+ int posi = 0;
+ //enforce position inside of frame size
+ {
+ float offset = audioprof->get_offset();
+
+ //clamp begin and end to framesize
+ float beginf = adj_timescale->get_lower();
+ float endf = adj_timescale->get_upper();
+
+ posi = round_to_int((position-beginf)*w/framesize);
+ //posi = (int)((position-beginf)*w/framesize);
+
+ //calculate in sample space from seconds
+ begin = round_to_int((beginf - offset)*samplerate);
+ end = round_to_int((endf - offset)*samplerate);
+ //begin = (int)((beginf - offset)*samplerate);
+ //end = (int)((endf - offset)*samplerate);
+ }
+
+ delta = (end - begin)/(float)w; //samples per pixel
+
+ /*synfig::warning("Rendering a framesize of %f secs from [%d,%d) samples to %d samples, took %f sec",
+ framesize, begin, end, w, check());*/
+
+ cur = begin;
+ i = 0; cum = 0;
+ for(int i=0;i<w;++i)
+ {
+ //get the maximum of the collected samples
+ maxs = 0;
+ mins = 0;
+ for(;cum < delta; ++cum, ++cur)
+ {
+ maxs = std::max(maxs,(int)(*audioprof)[cur]);
+ mins = std::min(mins,(int)(*audioprof)[cur]);
+ }
+ cum -= delta;
+
+ //draw spike if not needed be
+ if(maxs||mins)
+ {
+ int top = maxs * baseline / 64;
+ int bot = mins * baseline / 64;
+
+ get_window()->draw_line(gc,i,baseline+bot,i,baseline+top);
+ }
+ }
+
+ //synfig::warning("Drawing audio line");
+ c.set_rgb_p(1,0,0);
+ gc->set_rgb_fg_color(c);
+ get_window()->draw_line(gc,posi,0,posi,get_height());
+ }
+ get_window()->end_paint();
+
+ return true;
+}
+
+//--- Handle the single clicking and dragging for scrubbing
+
+bool studio::Widget_Sound::on_motion_notify_event(GdkEventMotion* event)
+{
+ Gdk::ModifierType mod = Gdk::ModifierType(event->state);
+
+ //if we are scrubbing
+ if(mod & Gdk::BUTTON1_MASK)
+ {
+ //Can't do this if we don't have a time frame (heheh...)
+ if(!adj_timescale) return false;
+
+ double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
+
+ //find event position in time
+ double t = beg + event->x * (end-beg) / get_width();
+
+ //signal that we are scrubbing to this new value...
+ signal_scrub()(t);
+
+
+ // We should be able to just call
+ // Widget_Timeslider::on_motion_notify_event(),
+ // but that seems to cause the program to halt
+ // for some reason. So for now, let's do the job ourselves
+ //adj_timescale->set_value(t);
+ //adj_timescale->changed();
+ //return true;
+ }
+
+ return Widget_Timeslider::on_motion_notify_event(event);
+}
+
+bool studio::Widget_Sound::on_button_press_event(GdkEventButton *event)
+{
+ //Assume button PRESS
+
+ //if we are starting... using left click
+ if(event->button == 1)
+ {
+ if(!adj_timescale) return false;
+
+ double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
+
+ //find event position in time
+ double t = beg + event->x * (end-beg) / get_width();
+
+ //signal the attached scrubbing devices...
+ signal_start_scrubbing()(t);
+
+ return true;
+ }
+
+ return Widget_Timeslider::on_button_press_event(event);
+}
+
+bool studio::Widget_Sound::on_button_release_event(GdkEventButton *event)
+{
+ //Assume button RELEASE
+
+ //if we are ending... using left click
+ if(event->button == 1)
+ {
+ //signal the scrubbing device... to stop
+ signal_stop_scrubbing()();
+
+ return true;
+ }
+
+ return Widget_Timeslider::on_button_release_event(event);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_sound.h
+** \brief Widget Sound 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_WIDGET_SOUND_H
+#define __SYNFIG_WIDGET_SOUND_H
+
+/* === H E A D E R S ======================================================= */
+#include <ETL/handle>
+
+#include <gtkmm/drawingarea.h>
+
+#include "widgets/widget_timeslider.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 AudioProfile;
+class AudioContainer;
+
+/* What can widget sound do?
+ Options:
+ 1. Just draw the sound
+ 2. Scroll time and draw the sound
+ 3. Play, stop, and scrub the sound... (full interaction...)
+ 4. Provide hooks for scrubbing to work... (and possibly play and stop in the future)
+
+ Going with 4 for now...
+*/
+class Widget_Sound : public Widget_Timeslider
+{
+ etl::handle<AudioProfile> audioprof;
+
+ //event override interface
+ virtual bool on_expose_event(GdkEventExpose *heh = 0);
+
+ //for scrubbing... (click is start, drag is scrub, and release is stop...)
+ virtual bool on_motion_notify_event(GdkEventMotion* event);
+ virtual bool on_button_press_event(GdkEventButton *event);
+ virtual bool on_button_release_event(GdkEventButton *event);
+
+ //Might want a signal setup for scrubbing... and here it is
+ sigc::signal1<void,double> signal_start_scrubbing_;
+ sigc::signal1<void,double> signal_scrub_;
+ sigc::signal0<void> signal_stop_scrubbing_;
+
+public: //structors
+ Widget_Sound();
+ ~Widget_Sound();
+
+public: //accessors
+ bool set_profile(etl::handle<AudioProfile> p);
+ etl::handle<AudioProfile> get_profile() const;
+
+ //for signal interface
+ sigc::signal1<void,double> & signal_start_scrubbing() {return signal_start_scrubbing_;}
+ sigc::signal1<void,double> & signal_scrub() {return signal_scrub_;}
+ sigc::signal0<void> & signal_stop_scrubbing() {return signal_stop_scrubbing_;}
+
+public: //get set interface
+ void set_position(double t);
+ double get_position() const;
+
+public: //interface
+ void draw();
+
+ void clear();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_time.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Chris Moore
+** Copyright (c) 2008 Paul Wise
+**
+** 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 "widgets/widget_time.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 ======================================================= */
+
+Widget_Time::Widget_Time():
+ fps_(0),
+ time_(0)
+{
+ signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
+ signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
+}
+
+Widget_Time::~Widget_Time()
+{
+}
+
+void
+Widget_Time::refresh_text()
+{
+ set_text(time_.get_string(fps_,App::get_time_format()));
+}
+
+
+void
+Widget_Time::set_value(const synfig::Time &data)
+{
+ time_=data;
+ refresh_text();
+}
+
+synfig::Time
+Widget_Time::get_value() const
+{
+ return time_;
+}
+
+void
+Widget_Time::set_fps(float x)
+{
+ fps_=Time(x);
+ refresh_text();
+}
+
+void
+Widget_Time::refresh_value()
+{
+ try
+ {
+ Time newtime(get_text(),fps_);
+ if(abs(newtime-time_)>=0.001)
+ {
+ time_=newtime;
+ refresh_text();
+ signal_value_changed()();
+ }
+ }
+ catch(...)
+ {
+ throw string("Caught unknown exception");
+ }
+}
+
+bool
+Widget_Time::on_event(GdkEvent* event)
+{
+ const Time scroll_amount(0.25);
+
+ switch(event->type)
+ {
+ case GDK_SCROLL:
+ if(event->scroll.direction==GDK_SCROLL_DOWN || event->scroll.direction==GDK_SCROLL_LEFT)
+ {
+ time_-=scroll_amount;
+ refresh_text();
+ signal_value_changed()();
+ }
+ else if(event->scroll.direction==GDK_SCROLL_UP || event->scroll.direction==GDK_SCROLL_RIGHT)
+ {
+ time_+=scroll_amount;
+ refresh_text();
+ signal_value_changed()();
+ }
+ return true;
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ if (!has_focus())
+ grab_focus();
+ break;
+ default:
+ break;
+ }
+
+ return Gtk::Entry::on_event(event);
+}
+
+bool
+Widget_Time::on_focus_out_event(GdkEventFocus* event)
+{
+ refresh_value();
+ refresh_text();
+ return Gtk::Entry::on_focus_out_event(event);
+}
+
+bool
+Widget_Time::on_focus_in_event(GdkEventFocus* event)
+{
+ // if defined, show the full time format "0h 0m 5s 0f" when the time widget gets focus
+ if (getenv("SYNFIG_SHOW_FULL_TIME_ON_FOCUS"))
+ set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
+
+ return Gtk::Entry::on_focus_in_event(event);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_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_WIDGET_TIME_H
+#define __SYNFIG_STUDIO_WIDGET_TIME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/entry.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 Widget_Time : public Gtk::Entry
+{
+
+
+ sigc::signal<void> signal_value_changed_;
+
+ float fps_;
+
+ synfig::Time time_;
+
+protected:
+ bool on_focus_out_event(GdkEventFocus* event);
+
+ bool on_focus_in_event(GdkEventFocus* event);
+
+ //void on_activate();
+
+ void refresh_text();
+
+ void refresh_value();
+
+ bool on_event(GdkEvent* event);
+
+public:
+ sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+
+
+ void set_value(const synfig::Time &data);
+ synfig::Time get_value()const;
+ void set_fps(float x);
+ Widget_Time();
+ ~Widget_Time();
+}; // END of class Widget_Time
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_timeslider.cpp
+** \brief Time Slider Widget Implementation File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2004 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 "widgets/widget_timeslider.h"
+
+#include <ETL/misc>
+
+#include <cmath>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+using studio::Widget_Timeslider;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+const double zoominfactor = 0.75;
+const double zoomoutfactor = 1/zoominfactor;
+
+/* === P R O C E D U R E S ================================================= */
+
+Gdk::Color get_interp_color(synfig::Interpolation x)
+{
+ switch(x)
+ {
+ case INTERPOLATION_TCB:
+ return Gdk::Color("#00B000");
+
+ break;
+
+ case INTERPOLATION_LINEAR:
+ return Gdk::Color("#B0B000");
+ break;
+
+ case INTERPOLATION_CONSTANT:
+ return Gdk::Color("#C70000");
+ break;
+
+ case INTERPOLATION_HALT:
+ return Gdk::Color("#00b0b0");
+ break;
+
+ case INTERPOLATION_MANUAL:
+ return Gdk::Color("#B000B0");
+ break;
+
+ case INTERPOLATION_UNDEFINED: default:
+ return Gdk::Color("#808080");
+ break;
+ }
+}
+
+static Gdk::Color
+color_darken(Gdk::Color x, float amount)
+{
+ double red = x.get_red_p() * amount;
+ double green = x.get_green_p() * amount;
+ double blue = x.get_blue_p() * amount;
+
+ x.set_rgb_p( red > 1 ? 1 : red,
+ green > 1 ? 1 : green,
+ blue > 1 ? 1 : blue);
+
+ return x;
+}
+
+void
+studio::render_time_point_to_window(
+ const Glib::RefPtr<Gdk::Drawable>& window,
+ const Gdk::Rectangle& area,
+ const synfig::TimePoint &tp,
+ bool selected
+)
+{
+ Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+ const Gdk::Color black("#000000");
+
+ if(selected)
+ gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+ else
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+ Gdk::Color color;
+ std::vector<Gdk::Point> points;
+
+/*- BEFORE ------------------------------------- */
+
+ color=get_interp_color(tp.get_before());
+ color=color_darken(color,1.0f);
+ if(selected)color=color_darken(color,1.3f);
+ gc->set_rgb_fg_color(color);
+
+ switch(tp.get_before())
+ {
+ case INTERPOLATION_TCB:
+ window->draw_arc(
+ gc,
+ true,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height(),
+ 64*90,
+ 64*180
+ );
+ gc->set_rgb_fg_color(black);
+ window->draw_arc(
+ gc,
+ false,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height(),
+ 64*90,
+ 64*180
+ );
+ break;
+
+ case INTERPOLATION_HALT:
+ window->draw_arc(
+ gc,
+ true,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height()*2,
+ 64*90,
+ 64*90
+ );
+ gc->set_rgb_fg_color(black);
+ window->draw_arc(
+ gc,
+ false,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height()*2,
+ 64*90,
+ 64*90
+ );
+ break;
+
+ case INTERPOLATION_LINEAR:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+
+ case INTERPOLATION_CONSTANT:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()+area.get_height()/2));
+ points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
+ points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+
+ case INTERPOLATION_UNDEFINED: default:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3));
+ points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+ }
+
+/*- AFTER -------------------------------------- */
+
+ color=get_interp_color(tp.get_after());
+ color=color_darken(color,0.8f);
+ if(selected)color=color_darken(color,1.3f);
+ gc->set_rgb_fg_color(color);
+
+ switch(tp.get_after())
+ {
+ case INTERPOLATION_TCB:
+ window->draw_arc(
+ gc,
+ true,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height(),
+ 64*270,
+ 64*180
+ );
+ gc->set_rgb_fg_color(black);
+ window->draw_arc(
+ gc,
+ false,
+ area.get_x(),
+ area.get_y(),
+ area.get_width(),
+ area.get_height(),
+ 64*270,
+ 64*180
+ );
+ break;
+
+ case INTERPOLATION_HALT:
+ window->draw_arc(
+ gc,
+ true,
+ area.get_x(),
+ area.get_y()-area.get_height(),
+ area.get_width(),
+ area.get_height()*2,
+ 64*270,
+ 64*90
+ );
+ gc->set_rgb_fg_color(black);
+ window->draw_arc(
+ gc,
+ false,
+ area.get_x(),
+ area.get_y()-area.get_height(),
+ area.get_width(),
+ area.get_height()*2,
+ 64*270,
+ 64*90
+ );
+ break;
+
+ case INTERPOLATION_LINEAR:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+
+ case INTERPOLATION_CONSTANT:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+
+ case INTERPOLATION_UNDEFINED: default:
+ points.clear();
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height()));
+ points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+ window->draw_polygon(gc,true,points);
+ gc->set_rgb_fg_color(black);
+ window->draw_lines(gc,points);
+ break;
+ }
+
+}
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+double defaultfps = 24;
+const int fullheight = 20;
+
+Widget_Timeslider::Widget_Timeslider()
+:layout(Pango::Layout::create(get_pango_context())),
+adj_default(0,0,2,1/defaultfps,10/defaultfps),
+adj_timescale(0),
+//invalidated(false),
+last_event_time(0),
+fps(defaultfps),
+dragscroll(false)
+{
+ set_size_request(-1,fullheight);
+
+ // click scroll zoom
+ add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
+ | Gdk::BUTTON_MOTION_MASK | Gdk::SCROLL_MASK );
+
+ set_time_adjustment(&adj_default);
+ //update_times();
+}
+
+Widget_Timeslider::~Widget_Timeslider()
+{
+}
+
+void Widget_Timeslider::set_time_adjustment(Gtk::Adjustment *x)
+{
+ //disconnect old connections
+ time_value_change.disconnect();
+ time_other_change.disconnect();
+
+ //connect update function to new adjustment
+ adj_timescale = x;
+
+ if(x)
+ {
+ time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
+ time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
+ //invalidated = true;
+ //refresh();
+ }
+}
+
+void Widget_Timeslider::set_global_fps(float d)
+{
+ if(fps != d)
+ {
+ fps = d;
+
+ //update everything since we need to redraw already
+ //invalidated = true;
+ //refresh();
+ queue_draw();
+ }
+}
+
+/*void Widget_Timeslider::update_times()
+{
+ if(adj_timescale)
+ {
+ start = adj_timescale->get_lower();
+ end = adj_timescale->get_upper();
+ current = adj_timescale->get_value();
+ }
+}*/
+
+void Widget_Timeslider::refresh()
+{
+}
+/*
+{
+ if(invalidated)
+ {
+ queue_draw();
+ }else if(adj_timescale)
+ {
+ double l = adj_timescale->get_lower(),
+ u = adj_timescale->get_upper(),
+ v = adj_timescale->get_value();
+
+ bool invalid = (l != start) || (u != end) || (v != current);
+
+ start = l;
+ end = u;
+ current = v;
+
+ if(invalid) queue_draw();
+ }
+}*/
+
+bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
+{
+ Glib::RefPtr<Gdk::Window> window = get_window();
+
+ if(!window) return false;
+
+ Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);
+ if(!gc) return false;
+
+ //synfig::info("Drawing Timeslider");
+ //clear and update to current values
+ //invalidated = false;
+ //update_times();
+
+ //draw grey rectangle
+ Gdk::Color c("#7f7f7f");
+ gc->set_rgb_fg_color(c);
+ gc->set_background(c);
+
+ //Get the data for the window and the params to draw it...
+ int w = get_width(), h = get_height();
+
+ window->draw_rectangle(gc,true,0,0,w,h);
+
+ const double EPSILON = 1e-6;
+ if(!adj_timescale || w == 0) return true;
+
+ //Get the time information since we now know it's valid
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper(),
+ current = adj_timescale->get_value();
+
+ if(end-start < EPSILON) return true;
+
+ //synfig::info("Drawing Lines");
+
+ //draw all the time stuff
+ double dtdp = (end - start)/get_width();
+ double dpdt = 1/dtdp;
+
+ //lines
+
+ //Draw the time line...
+ double tpx = (current-start)*dpdt;
+ gc->set_rgb_fg_color(Gdk::Color("#ffaf00"));
+ window->draw_line(gc,round_to_int(tpx),0,round_to_int(tpx),fullheight);
+
+ //normal line/text color
+ gc->set_rgb_fg_color(Gdk::Color("#333333"));
+
+ int ifps = round_to_int(fps);
+ if (ifps < 1) ifps = 1;
+
+ std::vector<double> ranges;
+
+ unsigned int pos = 0;
+
+ // build a list of all the factors of the frame rate
+ for (int i = 1; i*i <= ifps; i++)
+ if ((ifps%i) == 0)
+ {
+ ranges.insert(ranges.begin()+pos, i/fps);
+ if (i*i != ifps)
+ ranges.insert(ranges.begin()+pos+1, ifps/i/fps);
+ pos++;
+ }
+
+ // fill in any gaps where one factor is more than 2 times the previous
+ std::vector<double>::iterator iter, next;
+ pos = 0;
+ for (pos = 0; pos < ranges.size()-1; pos++)
+ {
+ iter = ranges.begin()+pos;
+ next = iter+1;
+ if (*iter*2 < *next)
+ ranges.insert(next, *iter*2);
+ }
+
+ double more_ranges[] = {
+ 2, 3, 5, 10, 20, 30, 60, 90, 120, 180,
+ 300, 600, 1200, 1800, 2700, 3600, 3600*2,
+ 3600*4, 3600*8, 3600*16, 3600*32, 3600*64,
+ 3600*128, 3600*256, 3600*512, 3600*1024 };
+
+ ranges.insert(ranges.end(), more_ranges, more_ranges + sizeof(more_ranges)/sizeof(double));
+
+ double lowerrange = dtdp*140, upperrange = dtdp*280;
+ double midrange = (lowerrange + upperrange)/2;
+
+ //find most ideal scale
+ double scale;
+ next = binary_find(ranges.begin(), ranges.end(), midrange);
+ iter = next++;
+
+ if (iter == ranges.end()) iter--;
+ if (next == ranges.end()) next--;
+
+ if (abs(*next - midrange) < abs(*iter - midrange))
+ iter = next;
+
+ scale = *iter;
+
+ // subdivide into this many tick marks (8 or less)
+ int subdiv = round_to_int(scale * ifps);
+
+ if (subdiv > 8)
+ {
+ const int ideal = subdiv;
+
+ // find a number of tick marks that nicely divides the scale
+ // (5 minutes divided by 6 is 50s, but that's not 'nice' -
+ // 5 ticks of 1m each is much simpler than 6 ticks of 50s)
+ for (subdiv = 8; subdiv > 0; subdiv--)
+ if ((ideal <= ifps*2 && (ideal % (subdiv )) == 0) ||
+ (ideal <= ifps*2*60 && (ideal % (subdiv*ifps )) == 0) ||
+ (ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60 )) == 0) ||
+ (true && (ideal % (subdiv*ifps*60*60)) == 0))
+ break;
+
+ // if we didn't find anything, use 4 ticks
+ if (!subdiv)
+ subdiv = 4;
+ }
+
+ time_per_tickmark = scale / subdiv;
+
+ //get first valid line and its position in pixel space
+ double time = 0;
+ double pixel = 0;
+
+ int sdindex = 0;
+
+ double subr = scale / subdiv;
+
+ //get its position inside...
+ time = ceil(start/subr)*subr - start;
+ pixel = time*dpdt;
+
+ //absolute time of the line to be drawn
+ time += start;
+
+ { //inside the big'n
+ double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1
+ //sdindex = (int)floor(t + 0.5); //get how far through the range it is...
+ sdindex = round_to_int(t); //get how far through the range it is...
+ if (sdindex == subdiv) sdindex = 0;
+
+ //synfig::info("Extracted fr %.2lf -> %d", t, sdindex);
+ }
+
+ //synfig::info("Initial values: %.4lf t, %.1lf pixels, %d i", time,pixel,sdindex);
+
+ //loop to draw
+ const int heightbig = 12;
+ const int heightsmall = 4;
+
+ int width = get_width();
+ while( pixel < width )
+ {
+ int xpx = round_to_int(pixel);
+
+ //draw big
+ if(sdindex == 0)
+ {
+ window->draw_line(gc,xpx,0,xpx,heightbig);
+ //round the time to nearest frame and draw the text
+ Time tm((double)time);
+ if(get_global_fps()) tm.round(get_global_fps());
+ Glib::ustring timecode(tm.get_string(get_global_fps(),App::get_time_format()));
+
+ //gc->set_rgb_fg_color(Gdk::Color("#000000"));
+ layout->set_text(timecode);
+ Pango::AttrList attr_list;
+ // Aproximately a font size of 8 pixels.
+ // Pango::SCALE = 1024
+ // create_attr_size waits a number in 1000th of pixels.
+ // Should be user customizable in the future. Now it is fixed to 10
+ Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
+ pango_size.set_start_index(0);
+ pango_size.set_end_index(64);
+ attr_list.change(pango_size);
+ layout->set_attributes(attr_list);
+ window->draw_layout(gc,xpx+2,0,layout);
+ }else
+ {
+ window->draw_line(gc,xpx,0,xpx,heightsmall);
+ }
+
+ //increment time and position
+ pixel += subr / dtdp;
+ time += subr;
+
+ //increment index
+ if(++sdindex >= subdiv) sdindex -= subdiv;
+ }
+
+ return true;
+}
+
+bool Widget_Timeslider::on_motion_notify_event(GdkEventMotion* event) //for dragging
+{
+ if(!adj_timescale) return false;
+
+ Gdk::ModifierType mod = Gdk::ModifierType(event->state);
+
+ //scrolling...
+
+ //NOTE: we might want to address the possibility of dragging with both buttons held down
+
+ if(mod & Gdk::BUTTON2_MASK)
+ {
+
+ //we need this for scrolling by dragging
+ double curx = event->x;
+
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper();
+
+ if(dragscroll)
+ {
+ if(event->time-last_event_time<30)
+ return false;
+ else
+ last_event_time=event->time;
+
+ if(abs(lastx - curx) < 1 && end != start) return true;
+ //translate the window and correct it
+
+ //update our stuff so we are operating correctly
+ //invalidated = true;
+ //update_times();
+
+ //Note: Use inverse of mouse movement because of conceptual space relationship
+ double diff = lastx - curx; //curx - lastx;
+
+ //NOTE: This might be incorrect...
+ //fraction to move...
+ double dpx = (end - start)/get_width();
+ lastx = curx;
+
+ diff *= dpx;
+
+ //Adjust...
+ start += diff;
+ end += diff;
+
+ //But clamp to bounds if they exist...
+ //HACK - bounds should not be required for this slider
+ if(adj_bounds)
+ {
+ if(start < adj_bounds->get_lower())
+ {
+ diff = adj_bounds->get_lower() - start;
+ start += diff;
+ end += diff;
+ }
+
+ if(end > adj_bounds->get_upper())
+ {
+ diff = adj_bounds->get_upper() - end;
+ start += diff;
+ end += diff;
+ }
+ }
+
+ //synfig::info("Scrolling timerange to (%.4f,%.4f)",start,end);
+
+ adj_timescale->set_lower(start);
+ adj_timescale->set_upper(end);
+
+ adj_timescale->changed();
+ }else
+ {
+ dragscroll = true;
+ lastx = curx;
+ //lasty = cury;
+ }
+
+ return true;
+ }
+
+ if(mod & Gdk::BUTTON1_MASK)
+ {
+ double curx = event->x;
+
+ //get time from drag...
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper(),
+ current = adj_timescale->get_value();
+ double t = start + curx*(end - start)/get_width();
+
+ //snap it to fps - if they exist...
+ if(fps)
+ {
+ t = floor(t*fps + 0.5)/fps;
+ }
+
+ //set time if needed
+ if(current != t)
+ {
+ adj_timescale->set_value(t);
+
+ //Fixed this to actually do what it's supposed to...
+ if(event->time-last_event_time>50)
+ {
+ adj_timescale->value_changed();
+ last_event_time = event->time;
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming
+{
+ if(!adj_timescale) return false;
+
+ //Update so we are calculating based on current values
+ //update_times();
+
+ //figure out if we should center ourselves on the current time
+ bool center = false;
+
+ //we want to zoom in on the time value if control is held down
+ if(Gdk::ModifierType(event->state) & Gdk::CONTROL_MASK)
+ center = true;
+
+ switch(event->direction)
+ {
+ case GDK_SCROLL_UP: //zoom in
+ zoom_in(center);
+ return true;
+
+ case GDK_SCROLL_DOWN: //zoom out
+ zoom_out(center);
+ return true;
+
+ case GDK_SCROLL_RIGHT:
+ case GDK_SCROLL_LEFT:
+ {
+ double t = adj_timescale->get_value();
+ double orig_t = t;
+ double start = adj_timescale->get_lower();
+ double end = adj_timescale->get_upper();
+ double lower = adj_bounds->get_lower();
+ double upper = adj_bounds->get_upper();
+ double adj = time_per_tickmark;
+
+ if( event->direction == GDK_SCROLL_RIGHT )
+ {
+ // step forward one tick
+ t += adj;
+
+ // don't go past the end of time
+ if (t > upper)
+ t = upper;
+
+ // if we are already in the right half of the slider
+ if ((t-start)*2 > (end-start))
+ {
+ // if we can't scroll the background left one whole tick, scroll it to the end
+ if (end > upper - (t-orig_t))
+ {
+ adj_timescale->set_lower(upper - (end-start));
+ adj_timescale->set_upper(upper);
+ }
+ // else scroll the background left
+ else
+ {
+ adj_timescale->set_lower(start + (t-orig_t));
+ adj_timescale->set_upper(start + (t-orig_t) + (end-start));
+ }
+ }
+ }
+ else
+ {
+ // step backwards one tick
+ t -= adj;
+
+ // don't go past the start of time
+ if (t < lower)
+ t = lower;
+
+ // if we are already in the left half of the slider
+ if ((t-start)*2 < (end-start))
+ {
+ // if we can't scroll the background right one whole tick, scroll it to the beginning
+ if (start < lower + (orig_t-t))
+ {
+ adj_timescale->set_lower(lower);
+ adj_timescale->set_upper(lower + (end-start));
+ }
+ // else scroll the background right
+ else
+ {
+ adj_timescale->set_lower(start - (orig_t-t));
+ adj_timescale->set_upper(start - (orig_t-t) + (end-start));
+ }
+ }
+ }
+
+ if(adj_timescale)
+ {
+ adj_timescale->set_value(t);
+ adj_timescale->value_changed();
+ }
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
+void Widget_Timeslider::zoom_in(bool centerontime)
+{
+ if(!adj_timescale) return;
+
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper(),
+ current = adj_timescale->get_value();
+
+ double focuspoint = centerontime ? current : (start + end)/2;
+
+ //calculate new beginning and end
+ end = focuspoint + (end-focuspoint)*zoominfactor;
+ start = focuspoint + (start-focuspoint)*zoominfactor;
+
+ //synfig::info("Zooming in timerange to (%.4f,%.4f)",start,end);
+ if(adj_bounds)
+ {
+ if(start < adj_bounds->get_lower())
+ {
+ start = adj_bounds->get_lower();
+ }
+
+ if(end > adj_bounds->get_upper())
+ {
+ end = adj_bounds->get_upper();
+ }
+ }
+
+ //reset values
+ adj_timescale->set_lower(start);
+ adj_timescale->set_upper(end);
+
+ //call changed function
+ adj_timescale->changed();
+}
+
+void Widget_Timeslider::zoom_out(bool centerontime)
+{
+ if(!adj_timescale) return;
+
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper(),
+ current = adj_timescale->get_value();
+
+ double focuspoint = centerontime ? current : (start + end)/2;
+
+ //calculate new beginning and end
+ end = focuspoint + (end-focuspoint)*zoomoutfactor;
+ start = focuspoint + (start-focuspoint)*zoomoutfactor;
+
+ //synfig::info("Zooming out timerange to (%.4f,%.4f)",start,end);
+ if(adj_bounds)
+ {
+ if(start < adj_bounds->get_lower())
+ {
+ start = adj_bounds->get_lower();
+ }
+
+ if(end > adj_bounds->get_upper())
+ {
+ end = adj_bounds->get_upper();
+ }
+ }
+
+ //reset values
+ adj_timescale->set_lower(start);
+ adj_timescale->set_upper(end);
+
+ //call changed function
+ adj_timescale->changed();
+}
+
+bool Widget_Timeslider::on_button_press_event(GdkEventButton *event) //for clicking
+{
+ switch(event->button)
+ {
+ //time click...
+ case 1:
+ {
+ double start = adj_timescale->get_lower(),
+ end = adj_timescale->get_upper(),
+ current = adj_timescale->get_value();
+
+ double w = get_width();
+ double t = start + (end - start) * event->x / w;
+
+ t = floor(t*fps + 0.5)/fps;
+
+ /*synfig::info("Clicking time from %.3lf to %.3lf [(%.2lf,%.2lf) %.2lf / %.2lf ... %.2lf",
+ current, vt, start, end, event->x, w, fps);*/
+
+ if(t != current)
+ {
+ current = t;
+
+ if(adj_timescale)
+ {
+ adj_timescale->set_value(current);
+ adj_timescale->value_changed();
+ }
+ }
+
+ break;
+ }
+
+ //scroll click
+ case 2:
+ {
+ //start dragging
+ dragscroll = true;
+ lastx = event->x;
+ //lasty = event->y;
+
+ return true;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+
+ return false;
+}
+
+bool Widget_Timeslider::on_button_release_event(GdkEventButton *event) //end drag
+{
+ switch(event->button)
+ {
+ case 2:
+ {
+ //start dragging
+ dragscroll = false;
+ return true;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+
+ return false;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_timeslider.h
+** \brief Time Slider Widget Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2004 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_WIDGET_TIMESLIDER_H
+#define __SYNFIG_WIDGET_TIMESLIDER_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/adjustment.h>
+
+#include <synfig/time.h>
+#include "canvasview.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 {
+
+void render_time_point_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::TimePoint &tp,bool selected=false);
+
+
+/* Design for the timeslider...
+
+ Concept: Scalable ruler
+ Ticks are done every so often (30 s, 10 frames, 5 frames, etc.)
+ Print out frame numbers next to the big ticks
+ Show blue pills in separate area (above or below)
+*/
+
+class Widget_Timeslider : public Gtk::DrawingArea
+{
+protected: //implementation that other interfaces can see
+ Glib::RefPtr<Pango::Layout> layout; //implementation awesomeness for text drawing
+
+ Gtk::Adjustment adj_default;
+ Gtk::Adjustment *adj_timescale;
+
+ //HACK - I should not have to see this...
+ Gtk::Adjustment *adj_bounds;
+ double time_per_tickmark;
+
+ //Statistics used for drawing stuff (and making sure we don't if we don't need to)
+ /*double start,end;
+ double current;
+
+ bool invalidated;*/
+
+ guint32 last_event_time;
+
+ float fps;
+
+ sigc::connection time_value_change;
+ sigc::connection time_other_change;
+
+ //TODO: fill out blue pill stuff
+
+ //input functions
+
+ virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
+ virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
+ virtual bool on_button_press_event(GdkEventButton *event); //for clicking
+ virtual bool on_button_release_event(GdkEventButton *event); //for clicking
+
+ virtual bool on_expose_event(GdkEventExpose */*event*/) {redraw(); return true;}//for drawing
+
+ virtual bool redraw(bool doublebuffer = false);
+
+ //void update_times();
+
+ void zoom_in(bool centerontime = false);
+ void zoom_out(bool centerontime = false);
+
+ //Drag the Frame
+ bool dragscroll;
+
+ /*NOTE: if we can set the mouse position to the original position
+ this would only have to be set once (and it would be good otherwise too)
+ */
+ double lastx; //last mouse position for dragging
+
+public: //structors
+ Widget_Timeslider();
+ ~Widget_Timeslider();
+
+public: //Normal Interface
+
+ void draw() {redraw();}
+ virtual void refresh(); //reget bluepills, time values and queue_draw if need be
+
+public: //Time Interface
+
+ //Run FPS stuff through it to the MAX
+ double get_global_fps() const {return fps;}
+ void set_global_fps(float d);
+
+ //accessors for the time adjustment
+ Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
+ void set_time_adjustment(Gtk::Adjustment *x);
+
+ //HACK - I should not have to see these bounds (should be boundless)
+ Gtk::Adjustment &get_bounds_adjustment() const {return *adj_bounds;}
+ void set_bounds_adjustment(Gtk::Adjustment *x) {adj_bounds = x;}
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_value.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/label.h>
+#include "widgets/widget_value.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_vector.h"
+#include "widgets/widget_filename.h"
+#include "widgets/widget_enum.h"
+#include "widgets/widget_coloredit.h"
+#include "widgets/widget_canvaschooser.h"
+#include "widgets/widget_time.h"
+#include "app.h"
+#include "widgets/widget_distance.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_ValueBase::Widget_ValueBase():
+ Glib::ObjectBase (typeid(Widget_ValueBase)),
+ Gtk::HBox(),
+ real_adjustment(0,-2000000000,2000000000,0.05,0.05,0),
+ integer_adjustment(0,-2000000000,2000000000,1,1,0),
+ angle_adjustment(0,-2000000000,2000000000,1,1,0)
+{
+ set_no_show_all();
+
+ label=manage(new class Gtk::Label("Unknown Datatype"));
+ pack_start(*label);
+ label->show();
+
+ vector_widget=manage(new class Widget_Vector());
+ pack_start(*vector_widget);
+
+ color_widget=manage(new class Widget_ColorEdit());
+ pack_start(*color_widget);
+
+ enum_widget=manage(new class Widget_Enum());
+ pack_start(*enum_widget);
+
+ real_widget=manage(new class Gtk::SpinButton(real_adjustment,0.05,DIGITS));
+ pack_start(*real_widget);
+
+ integer_widget=manage(new class Gtk::SpinButton(integer_adjustment,1,0));
+ pack_start(*integer_widget);
+
+ angle_widget=manage(new class Gtk::SpinButton(angle_adjustment,15,2));
+ pack_start(*angle_widget);
+
+ bool_widget=manage(new class Gtk::CheckButton());
+ pack_start(*bool_widget);
+
+ //color_widget=manage(new class Gtk::ColorSelection());
+ //pack_start(*color_widget);
+
+ string_widget=manage(new class Gtk::Entry());
+ pack_start(*string_widget);
+
+ canvas_widget=manage(new class Widget_CanvasChooser());
+ pack_start(*canvas_widget);
+
+ filename_widget=manage(new class Widget_Filename());
+ pack_start(*filename_widget);
+
+ time_widget=manage(new class Widget_Time());
+ pack_start(*time_widget);
+
+ distance_widget=manage(new class Widget_Distance());
+ pack_start(*distance_widget);
+
+
+ vector_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ color_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ enum_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ real_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ integer_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ angle_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ string_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ canvas_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ filename_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ time_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+ distance_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+
+ /*signal_focus_in_event().connect(
+ sigc::bind_return(
+ sigc::hide(
+ sigc::mem_fun(*this,&Widget_ValueBase::grab_focus)
+ ),false
+ )
+ );*/
+}
+
+Widget_ValueBase::~Widget_ValueBase()
+{
+}
+
+void
+Widget_ValueBase::activate()
+{
+ signal_activate()();
+}
+
+void
+Widget_ValueBase::inside_cellrenderer()
+{
+ string_widget->set_has_frame(false);
+ string_widget->gobj()->is_cell_renderer = true; // XXX
+
+ real_widget->set_has_frame(false);
+ //static_cast<Gtk::Entry*>(real_widget)->gobj()->is_cell_renderer = true; // XXX
+
+ distance_widget->set_has_frame(false);
+ //static_cast<Gtk::Entry*>(distance_widget)->gobj()->is_cell_renderer = true; // XXX
+
+ integer_widget->set_has_frame(false);
+ //static_cast<Gtk::Entry*>(integer_widget)->gobj()->is_cell_renderer = true; // XXX
+ vector_widget->set_has_frame(false);
+ //vector_widget->set_digits(10);
+
+ color_widget->set_has_frame(false);
+ //color_widget->set_digits(10);
+ filename_widget->set_has_frame(false);
+ time_widget->set_has_frame(false);
+}
+
+void
+Widget_ValueBase::set_sensitive(bool x)
+{
+ Gtk::HBox::set_sensitive(x);
+ label->set_sensitive(x);
+ vector_widget->set_sensitive(x);
+ real_widget->set_sensitive(x);
+ integer_widget->set_sensitive(x);
+ bool_widget->set_sensitive(x);
+ color_widget->set_sensitive(x);
+ string_widget->set_sensitive(x);
+ canvas_widget->set_sensitive(x);
+ enum_widget->set_sensitive(x);
+ angle_widget->set_sensitive(x);
+ filename_widget->set_sensitive(x);
+ time_widget->set_sensitive(x);
+ distance_widget->set_sensitive(x);
+}
+
+void
+Widget_ValueBase::set_value(const synfig::ValueBase &data)
+{
+ label->hide();
+ vector_widget->hide();
+ real_widget->hide();
+ integer_widget->hide();
+ bool_widget->hide();
+ color_widget->hide();
+ string_widget->hide();
+ canvas_widget->hide();
+ enum_widget->hide();
+ angle_widget->hide();
+ filename_widget->hide();
+ time_widget->hide();
+ distance_widget->hide();
+
+ value=data;
+ try{
+ switch(value.get_type())
+ {
+ case ValueBase::TYPE_VECTOR:
+ vector_widget->set_canvas(canvas);
+ vector_widget->set_value(value.get(Vector()));
+ vector_widget->show();
+ break;
+ case ValueBase::TYPE_REAL:
+ if(param_desc.get_is_distance() && canvas)
+ {
+ Distance dist(value.get(Real()),Distance::SYSTEM_UNITS);
+ dist.convert(App::distance_system,canvas->rend_desc());
+ distance_widget->set_value(dist);
+ distance_widget->show();
+ }
+ else
+ {
+ real_widget->set_value(value.get(Real()));
+ real_widget->show();
+ }
+ break;
+ case ValueBase::TYPE_TIME:
+ if(canvas)time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+ time_widget->set_value(value.get(Time()));
+ time_widget->show();
+ break;
+ case ValueBase::TYPE_ANGLE:
+ angle_widget->set_value(Angle::deg(value.get(Angle())).get());
+ angle_widget->show();
+ break;
+ case ValueBase::TYPE_INTEGER:
+ if(param_desc.get_hint()!="enum")
+ {
+ integer_widget->set_value(value.get(int()));
+ integer_widget->show();
+ }
+ else
+ {
+ enum_widget->set_param_desc(param_desc);
+ enum_widget->set_value(value.get(int()));
+ enum_widget->show();
+ }
+ break;
+ case ValueBase::TYPE_CANVAS:
+ assert(canvas);
+ canvas_widget->set_parent_canvas(canvas);
+ canvas_widget->set_value(value.get(etl::loose_handle<synfig::Canvas>()));
+ canvas_widget->show();
+ break;
+ case ValueBase::TYPE_BOOL:
+ bool_widget->set_active(value.get(bool()));
+ bool_widget->show();
+ break;
+ case ValueBase::TYPE_STRING:
+ if(param_desc.get_hint()!="filename")
+ {
+ string_widget->set_text(value.get(string()));
+ string_widget->show();
+ }
+ else
+ {
+ filename_widget->set_value(value.get(string()));
+ filename_widget->show();
+ }
+ break;
+ case ValueBase::TYPE_COLOR:
+ {
+ color_widget->set_value(value.get(synfig::Color()));
+ color_widget->show();
+/*
+ Gdk::Color gdkcolor;
+ synfig::Color color=value.get(synfig::Color());
+ gdkcolor.set_rgb_p(color.get_r(),color.get_g(),color.get_b());
+ color_widget->set_current_color(gdkcolor);
+ color_widget->set_has_opacity_control(true);
+ color_widget->set_current_alpha((unsigned short)(color.get_a()*65535.0));
+ color_widget->show();
+*/
+ }
+ break;
+ default:
+ label->show();
+ break;
+ }
+ }catch(...) { synfig::error(__FILE__":%d: Caught something that was thrown",__LINE__); }
+}
+
+const synfig::ValueBase &
+Widget_ValueBase::get_value()
+{
+ switch(value.get_type())
+ {
+ case ValueBase::TYPE_VECTOR:
+ value=vector_widget->get_value();
+ break;
+ case ValueBase::TYPE_REAL:
+ if(param_desc.get_is_distance() && canvas)
+ value=distance_widget->get_value().units(canvas->rend_desc());
+ else
+ value=real_widget->get_value();
+ break;
+ case ValueBase::TYPE_TIME:
+ value=time_widget->get_value();
+ break;
+ case ValueBase::TYPE_ANGLE:
+ value=Angle::deg(angle_widget->get_value());
+ break;
+ case ValueBase::TYPE_CANVAS:
+ value=canvas_widget->get_value();
+ break;
+ case ValueBase::TYPE_INTEGER:
+ if(param_desc.get_hint()!="enum")
+ {
+ value=integer_widget->get_value_as_int();
+ }
+ else
+ {
+ value=enum_widget->get_value();
+ }
+
+ break;
+ case ValueBase::TYPE_BOOL:
+ value=bool_widget->get_active();
+ break;
+ case ValueBase::TYPE_STRING:
+ if(param_desc.get_hint()!="filename")
+ {
+ value=string(string_widget->get_text());
+ }
+ else
+ {
+ value=string(filename_widget->get_value());
+ }
+ break;
+ case ValueBase::TYPE_COLOR:
+ {
+ value=color_widget->get_value();
+/*
+ Gdk::Color gdkcolor;
+ synfig::Color color;
+ gdkcolor=color_widget->get_current_color();
+ color.set_r(gdkcolor.get_red_p());
+ color.set_g(gdkcolor.get_green_p());
+ color.set_b(gdkcolor.get_blue_p());
+ color.set_a(color_widget->get_current_alpha()/65535.0);
+
+ value=color;
+*/
+ }
+ break;
+ default:
+ break;
+ }
+
+ return value;
+}
+
+
+void
+Widget_ValueBase::on_grab_focus()
+{
+ switch(value.get_type())
+ {
+ case ValueBase::TYPE_VECTOR:
+ vector_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_REAL:
+ if(param_desc.get_is_distance()&& canvas)
+ distance_widget->grab_focus();
+ else
+ real_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_TIME:
+ time_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_ANGLE:
+ angle_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_CANVAS:
+ canvas_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_INTEGER:
+ if(param_desc.get_hint()!="enum")
+ {
+ integer_widget->grab_focus();
+ }
+ else
+ {
+ enum_widget->grab_focus();
+ }
+
+ break;
+ case ValueBase::TYPE_BOOL:
+ bool_widget->grab_focus();
+ break;
+ case ValueBase::TYPE_STRING:
+ if(param_desc.get_hint()!="filename")
+ {
+ string_widget->grab_focus();
+ }
+ else
+ {
+ filename_widget->grab_focus();
+ }
+ break;
+ case ValueBase::TYPE_COLOR:
+ {
+ color_widget->grab_focus();
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+Glib::SignalProxy0<void>
+Widget_ValueBase::signal_activate()
+{
+ switch(value.get_type())
+ {
+ case ValueBase::TYPE_VECTOR:
+ return vector_widget->signal_activate();
+ break;
+ case ValueBase::TYPE_REAL:
+ if(param_desc.get_is_distance()&& canvas)
+ return distance_widget->signal_activate();
+ else
+ return real_widget->signal_activate();
+
+ break;
+ case ValueBase::TYPE_TIME:
+ return time_widget->signal_activate();
+ break;
+ case ValueBase::TYPE_ANGLE:
+ return angle_widget->signal_activate();
+ break;
+ case ValueBase::TYPE_CANVAS:
+ return canvas_widget->signal_activate();
+ break;
+ case ValueBase::TYPE_INTEGER:
+ if(param_desc.get_hint()!="enum")
+ return integer_widget->signal_activate();
+ else
+ return enum_widget->signal_activate();
+
+ break;
+ case ValueBase::TYPE_BOOL:
+ return string_widget->signal_activate();
+ break;
+ case ValueBase::TYPE_STRING:
+ if(param_desc.get_hint()!="filename")
+ {
+ return string_widget->signal_activate();
+ }
+ else
+ {
+ return filename_widget->signal_activate();
+ }
+ break;
+ case ValueBase::TYPE_COLOR:
+ {
+ return color_widget->signal_activate();
+ }
+ break;
+ default:
+ return string_widget->signal_activate();
+ break;
+ }
+}
+*/
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_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_VALUE_H
+#define __SYNFIG_GTKMM_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/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>
+#include <synfig/canvas.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_ColorEdit;
+class Widget_CanvasChooser;
+class Widget_Enum;
+class Widget_Filename;
+class Widget_Vector;
+class Widget_Time;
+class Widget_Distance;
+
+class Widget_ValueBase : public Gtk::HBox
+{
+ Gtk::Label *label;
+ synfig::ValueBase value;
+
+ Widget_Vector *vector_widget;
+ Gtk::SpinButton *real_widget;
+ Gtk::Adjustment real_adjustment;
+ Gtk::SpinButton *integer_widget;
+ Gtk::Adjustment integer_adjustment;
+ Gtk::SpinButton *angle_widget;
+ Gtk::Adjustment angle_adjustment;
+
+ Gtk::CheckButton *bool_widget;
+ //Gtk::ColorSelection *color_widget;
+ Widget_ColorEdit *color_widget;
+ Widget_CanvasChooser *canvas_widget;
+ Widget_Enum *enum_widget;
+ Widget_Filename *filename_widget;
+ Widget_Time *time_widget;
+ Gtk::Entry *string_widget;
+ Widget_Distance *distance_widget;
+
+// std::string hint;
+
+ synfig::ParamDesc param_desc;
+ etl::handle<synfig::Canvas> canvas;
+ sigc::signal<void> signal_value_changed_;
+ sigc::signal<void> signal_activate_;
+
+public:
+ sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+ void activate();
+
+ sigc::signal<void>& signal_activate() { return signal_activate_; }
+
+ void set_value(const synfig::ValueBase &data);
+ const synfig::ValueBase &get_value();
+
+ void on_grab_focus();
+
+ void set_param_desc(const synfig::ParamDesc &x) { param_desc=x; }
+ const synfig::ParamDesc &get_param_desc() { return param_desc; }
+
+ void set_sensitive(bool x);
+
+ //void set_hint(std::string x) { hint=x; }
+// std::string get_hint() { return hint; }
+
+ void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; assert(canvas); }
+ void inside_cellrenderer();
+ Widget_ValueBase();
+ ~Widget_ValueBase();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_vector.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/spinbutton.h>
+#include "widgets/widget_vector.h"
+#include "widgets/widget_distance.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#define DIGITS 10
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Vector::Widget_Vector():
+ Gtk::HBox(false, 5),
+ x_adjustment(0,-100000000,100000000,0.05,0.05,0),
+ y_adjustment(0,-100000000,100000000,0.05,0.05,0)
+{
+ Gtk::Label *label;
+
+ label=manage(new class Gtk::Label("X:"));
+ label->set_alignment(0, 0.5);
+ label->show();
+ pack_start(*label, Gtk::PACK_SHRINK);
+
+ spinbutton_x=manage(new class Gtk::SpinButton(x_adjustment,0.05,DIGITS));
+ spinbutton_x->set_alignment(1);
+ spinbutton_x->set_update_policy(Gtk::UPDATE_ALWAYS);
+ spinbutton_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+ pack_start(*spinbutton_x, Gtk::PACK_EXPAND_WIDGET);
+
+ distance_x=manage(new Widget_Distance());
+ distance_x->set_digits(4);
+ distance_x->set_update_policy(Gtk::UPDATE_ALWAYS);
+ distance_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+ pack_start(*distance_x, Gtk::PACK_EXPAND_WIDGET);
+
+ label=manage(new class Gtk::Label("Y:"));
+ label->set_alignment(0, 0.5);
+ label->show();
+ pack_start(*label, Gtk::PACK_SHRINK);
+
+ spinbutton_y=manage(new class Gtk::SpinButton(y_adjustment,0.05,DIGITS));
+ spinbutton_y->set_alignment(1);
+ spinbutton_y->set_update_policy(Gtk::UPDATE_ALWAYS);
+ spinbutton_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+ spinbutton_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
+ pack_start(*spinbutton_y, Gtk::PACK_EXPAND_WIDGET);
+
+ distance_y=manage(new Widget_Distance());
+ distance_y->set_digits(4);
+ distance_y->set_update_policy(Gtk::UPDATE_ALWAYS);
+ distance_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+ distance_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
+ pack_start(*distance_y, Gtk::PACK_EXPAND_WIDGET);
+
+ spinbutton_x->show();
+ spinbutton_y->show();
+
+ spinbutton_x->signal_activate().connect(sigc::mem_fun(*spinbutton_y,&Gtk::SpinButton::grab_focus));
+ distance_x->signal_activate().connect(sigc::mem_fun(*distance_y,&Gtk::SpinButton::grab_focus));
+}
+
+Widget_Vector::~Widget_Vector()
+{
+}
+
+void
+Widget_Vector::on_grab_focus()
+{
+ if(canvas_)
+ distance_x->grab_focus();
+ else
+ spinbutton_x->grab_focus();
+}
+
+void
+Widget_Vector::set_has_frame(bool x)
+{
+ if(spinbutton_x)
+ {
+ spinbutton_x->set_has_frame(x);
+ spinbutton_y->set_has_frame(x);
+ spinbutton_x->set_size_request(48,-1);
+ spinbutton_y->set_size_request(48,-1);
+ }
+
+ distance_x->set_has_frame(x);
+ distance_y->set_has_frame(x);
+ distance_x->set_size_request(48,-1);
+ distance_y->set_size_request(48,-1);
+}
+
+void
+Widget_Vector::set_digits(int x)
+{
+ if(spinbutton_x)
+ {
+ spinbutton_x->set_digits(x);
+ spinbutton_y->set_digits(x);
+ spinbutton_x->set_size_request(48,-1);
+ spinbutton_y->set_size_request(48,-1);
+ }
+
+ distance_x->set_digits(x);
+ distance_y->set_digits(x);
+ distance_x->set_size_request(48,-1);
+ distance_y->set_size_request(48,-1);
+}
+
+void
+Widget_Vector::set_value(const synfig::Vector &data)
+{
+ vector=data;
+
+ if(canvas_){try
+ {
+ Distance distx(vector[0],Distance::SYSTEM_UNITS),disty(vector[1],Distance::SYSTEM_UNITS);
+ distx.convert(App::distance_system,canvas_->rend_desc());
+ disty.convert(App::distance_system,canvas_->rend_desc());
+ distance_x->set_value(distx);
+ distance_y->set_value(disty);
+ spinbutton_x->hide();
+ spinbutton_y->hide();
+ }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }}
+ else
+ {
+ spinbutton_x->set_value(vector[0]);
+ spinbutton_y->set_value(vector[1]);
+ distance_x->hide();
+ distance_y->hide();
+ }
+}
+
+const synfig::Vector &
+Widget_Vector::get_value()
+{
+ if(!canvas_ && spinbutton_x)
+ {
+ vector[0]=spinbutton_x->get_value();
+ vector[1]=spinbutton_y->get_value();
+ distance_x->hide();
+ distance_y->hide();
+ }
+ else try
+ {
+ vector[0]=distance_x->get_value().units(canvas_->rend_desc());
+ vector[1]=distance_y->get_value().units(canvas_->rend_desc());
+ spinbutton_x->hide();
+ spinbutton_y->hide();
+ }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }
+ return vector;
+}
+
+void
+Widget_Vector::on_value_changed()
+{
+ signal_value_changed()();
+}
+
+void
+Widget_Vector::set_canvas(synfig::Canvas::LooseHandle x)
+{
+ canvas_=x;
+ if(x)
+ {
+ if(spinbutton_x)
+ {
+ spinbutton_x->hide();
+ spinbutton_y->hide();
+ }
+ distance_x->show();
+ distance_y->show();
+ }
+ else
+ {
+ if(spinbutton_x)
+ {
+ spinbutton_x->show();
+ spinbutton_y->show();
+ }
+ distance_x->hide();
+ distance_y->hide();
+ }
+}
+
+void
+Widget_Vector::show_all_vfunc()
+{
+ if(canvas_)
+ {
+ distance_x->show();
+ distance_y->show();
+ }
+ else
+ {
+ spinbutton_x->show();
+ spinbutton_y->show();
+ }
+ show();
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_vector.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_WIDGET_VECTOR_H
+#define __SYNFIG_STUDIO_WIDGET_VECTOR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <synfig/vector.h>
+#include <synfig/distance.h>
+#include <synfig/canvas.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 SpinButton; };
+
+namespace studio {
+
+class Widget_Distance;
+
+class Widget_Vector : public Gtk::HBox
+{
+ Gtk::SpinButton* spinbutton_x;
+ Gtk::SpinButton* spinbutton_y;
+
+ Widget_Distance* distance_x;
+ Widget_Distance* distance_y;
+
+ Gtk::Adjustment x_adjustment;
+ Gtk::Adjustment y_adjustment;
+
+ synfig::Vector vector;
+
+ sigc::signal<void> signal_value_changed_;
+
+ sigc::signal<void> signal_activate_;
+
+ synfig::Canvas::LooseHandle canvas_;
+
+public:
+
+ void activate() { signal_activate_(); }
+
+ void set_canvas(synfig::Canvas::LooseHandle);
+ synfig::Canvas::LooseHandle get_canvas()const { return canvas_; }
+
+ sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+ sigc::signal<void>& signal_activate() { return signal_activate_; }
+
+ void on_value_changed();
+ void on_grab_focus();
+
+ void set_value(const synfig::Vector &data);
+ const synfig::Vector &get_value();
+ void set_has_frame(bool x);
+ void set_digits(int x);
+ Widget_Vector();
+ ~Widget_Vector();
+
+protected:
+ void show_all_vfunc();
+}; // END of class Widget_Vector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_waypoint.cpp
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Chris Moore
+** Copyright (c) 2008 Paul Wise
+**
+** 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 <gtkmm/frame.h>
+#include <gtkmm/alignment.h>
+#include "dialogs/dialog_waypoint.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_waypoint.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
+ Gtk::Alignment(0, 0, 1, 1),
+ waypoint(synfig::ValueBase(),0),
+ adj_tension(0.0,-20,20,0.1,1),
+ adj_continuity(0.0,-20,20,0.1,1),
+ adj_bias(0.0,-20,20,0.1,1),
+ adj_temporal_tension(0.0,-20,20,0.1,1)
+{
+ value_widget=manage(new Widget_ValueBase());
+ value_widget->set_canvas(canvas);
+ value_widget->show();
+
+ value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
+
+
+ time_widget=manage(new Widget_Time());
+ time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+ //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
+ //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
+ //spinbutton->show();
+
+ before_options=manage(new class Gtk::Menu());
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
+ // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+ after_options=manage(new class Gtk::Menu());
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
+ // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+ before=manage(new class Gtk::OptionMenu());
+ before->show();
+ before->set_menu(*before_options);
+
+ after=manage(new class Gtk::OptionMenu());
+ after->show();
+ after->set_menu(*after_options);
+
+ spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
+ spin_tension->show();
+ spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
+ spin_continuity->show();
+ spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
+ spin_bias->show();
+ spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
+ spin_temporal_tension->show();
+
+ set_padding(12, 12, 12, 12);
+
+ Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
+ add(*widgetBox);
+
+ Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
+ waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
+ ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
+ widgetBox->pack_start(*waypointFrame, false, false, 0);
+
+ Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+ waypointPadding->set_padding(6, 0, 24, 0);
+ waypointFrame->add(*waypointPadding);
+
+ Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
+ waypointTable->set_row_spacings(6);
+ waypointTable->set_col_spacings(12);
+ waypointPadding->add(*waypointTable);
+
+ Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
+ waypointValueLabel->set_alignment(0, 0.5);
+ waypointValueLabel->set_mnemonic_widget(*value_widget);
+ waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
+ waypointTimeLabel->set_alignment(0, 0.5);
+ waypointTimeLabel->set_mnemonic_widget(*time_widget);
+ waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
+ interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
+ ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
+ widgetBox->pack_start(*interpolationFrame, false, false, 0);
+
+ Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+ interpolationPadding->set_padding(6, 0, 24, 0);
+ interpolationFrame->add(*interpolationPadding);
+
+ Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
+ interpolationTable->set_row_spacings(6);
+ interpolationTable->set_col_spacings(12);
+ interpolationPadding->add(*interpolationTable);
+
+ Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
+ interpolationInLabel->set_alignment(0, 0.5);
+ interpolationInLabel->set_mnemonic_widget(*before);
+ interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
+ interpolationOutLabel->set_alignment(0, 0.5);
+ interpolationOutLabel->set_mnemonic_widget(*after);
+ interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
+ tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
+ ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
+ widgetBox->pack_start(*tcbFrame, false, false, 0);
+
+ Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+ tcbPadding->set_padding(6, 0, 24, 0);
+ tcbFrame->add(*tcbPadding);
+
+ Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
+ tcbTable->set_row_spacings(6);
+ tcbTable->set_col_spacings(12);
+ tcbPadding->add(*tcbTable);
+
+ Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
+ tensionLabel->set_alignment(0, 0.5);
+ tensionLabel->set_mnemonic_widget(*spin_tension);
+ spin_tension->set_alignment(1);
+ tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
+ continuityLabel->set_alignment(0, 0.5);
+ continuityLabel->set_mnemonic_widget(*spin_continuity);
+ spin_continuity->set_alignment(1);
+ tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
+ biasLabel->set_alignment(0, 0.5);
+ biasLabel->set_mnemonic_widget(*spin_bias);
+ spin_bias->set_alignment(1);
+ tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
+ temporalTensionLabel->set_alignment(0, 0.5);
+ temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
+ spin_temporal_tension->set_alignment(1);
+ tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+ tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+ show_all();
+ hide();
+ //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ set_canvas(canvas);
+}
+
+void
+Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
+{
+ canvas=x;
+ assert(canvas);
+
+ time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+ value_widget->set_canvas(canvas);
+}
+
+void
+Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
+{
+ time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+
+ waypoint=x;
+
+ //! \todo This really needs to be fixed to support value node waypoints!
+ if(waypoint.is_static())
+ {
+ value_widget->set_value(waypoint.get_value());
+ value_widget->show();
+ value_node_label->hide();
+ }
+ else
+ {
+ value_widget->hide();
+ value_node_label->show();
+ }
+
+ time_widget->set_value(waypoint.get_time());
+
+ before->set_history((int)waypoint.get_before());
+ after->set_history((int)waypoint.get_after());
+
+ adj_tension.set_value(waypoint.get_tension());
+ adj_continuity.set_value(waypoint.get_continuity());
+ adj_bias.set_value(waypoint.get_bias());
+ adj_temporal_tension.set_value(waypoint.get_temporal_tension());
+
+}
+const synfig::Waypoint &
+Widget_Waypoint::get_waypoint()const
+{
+ //! \todo This too!
+ waypoint.set_time(time_widget->get_value());
+ if(waypoint.is_static())
+ waypoint.set_value(value_widget->get_value());
+ //int i;
+
+ waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
+ waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
+
+ waypoint.set_tension(adj_tension.get_value());
+ waypoint.set_continuity(adj_continuity.get_value());
+ waypoint.set_bias(adj_bias.get_value());
+ waypoint.set_temporal_tension(adj_temporal_tension.get_value());
+ return waypoint;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_waypoint.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_GTKMM_WIDGET_WAYPOINT_H
+#define __SYNFIG_GTKMM_WIDGET_WAYPOINT_H
+
+/* === H E A D E R S ======================================================= */
+
+//#include <gtk/gtk.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/button.h>
+//#include <gtkmm/progressbar.h>
+//#include <gtkmm/paned.h>
+#include <gtkmm/box.h>
+//#include <gtkmm/scrollbar.h>
+#include <gtkmm/combo.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/alignment.h>
+
+#include <synfigapp/value_desc.h>
+#include <synfig/waypoint.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 Widget_Time;
+class Widget_Waypoint;
+
+class Widget_Waypoint : public Gtk::Alignment
+{
+ Widget_ValueBase *value_widget;
+ Gtk::Label *value_node_label;
+ Gtk::Label *label;
+ Widget_Time *time_widget;
+ mutable synfig::Waypoint waypoint;
+ synfig::Canvas::Handle canvas;
+ //Gtk::Adjustment time_adjustment;
+
+ Gtk::Combo *in,*out;
+ Gtk::OptionMenu *before, *after;
+ Gtk::Menu *before_options,*after_options;
+
+ Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
+ Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
+// Gtk::ComboDropDownItem item;
+
+public:
+ Widget_Waypoint(etl::handle<synfig::Canvas> canvas);
+ void set_canvas(synfig::Canvas::Handle x);
+ void set_waypoint(synfig::Waypoint &x);
+ const synfig::Waypoint &get_waypoint()const;
+}; // END of class Widget_Waypoint
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widget_waypointmodel.cpp
+** \brief Template Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Paul Wise
+**
+** 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 <gtkmm/spinbutton.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_waypointmodel.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_WaypointModel::Widget_WaypointModel():
+ Gtk::Table(4,3,false),
+ adj_tension(0.0,-20,20,0.1,1),
+ adj_continuity(0.0,-20,20,0.1,1),
+ adj_bias(0.0,-20,20,0.1,1),
+ adj_temporal_tension(0.0,-20,20,0.1,1),
+ checkbutton_after(_("Out:")),
+ checkbutton_before(_("In:")),
+ checkbutton_tension(_("Tension:")),
+ checkbutton_continuity(_("Continuity:")),
+ checkbutton_bias(_("Bias:")),
+ checkbutton_temporal_tension(_("Temporal Tension:"))
+{
+ before_options=manage(new class Gtk::Menu());
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+ before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
+ // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+ after_options=manage(new class Gtk::Menu());
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+ after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
+ // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+ before=manage(new class Gtk::OptionMenu());
+ before->show();
+ before->set_menu(*before_options);
+
+ after=manage(new class Gtk::OptionMenu());
+ after->show();
+ after->set_menu(*after_options);
+
+ spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
+ spin_tension->show();
+ spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
+ spin_continuity->show();
+ spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
+ spin_bias->show();
+ spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
+ spin_temporal_tension->show();
+
+ checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+ adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+ before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+ after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+ attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ show_all();
+ hide();
+ updating=false;
+ on_change();
+}
+
+void
+Widget_WaypointModel::on_change()
+{
+ if(updating)
+ return;
+
+ waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
+ waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
+
+ waypoint_model.set_tension(adj_tension.get_value());
+ waypoint_model.set_continuity(adj_continuity.get_value());
+ waypoint_model.set_bias(adj_bias.get_value());
+ waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
+
+ waypoint_model.set_before_flag(checkbutton_before.get_active());
+ waypoint_model.set_after_flag(checkbutton_after.get_active());
+ waypoint_model.set_tension_flag(checkbutton_tension.get_active());
+ waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
+ waypoint_model.set_bias_flag(checkbutton_bias.get_active());
+ waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
+
+ before->set_sensitive(checkbutton_before.get_active());
+ after->set_sensitive(checkbutton_after.get_active());
+ spin_tension->set_sensitive(checkbutton_tension.get_active());
+ spin_continuity->set_sensitive(checkbutton_continuity.get_active());
+ spin_bias->set_sensitive(checkbutton_bias.get_active());
+ spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
+}
+
+void
+Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
+{
+ waypoint_model=x;
+ updating=true;
+
+ before->set_history((int)waypoint_model.get_before());
+ after->set_history((int)waypoint_model.get_after());
+
+ adj_tension.set_value(waypoint_model.get_tension());
+ adj_continuity.set_value(waypoint_model.get_continuity());
+ adj_bias.set_value(waypoint_model.get_bias());
+ adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
+
+ checkbutton_before.set_active(waypoint_model.get_before_flag());
+ checkbutton_after.set_active(waypoint_model.get_after_flag());
+ checkbutton_tension.set_active(waypoint_model.get_tension_flag());
+ checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
+ checkbutton_bias.set_active(waypoint_model.get_bias_flag());
+ checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());
+
+ updating=false;
+
+ on_change();
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file widgets/widget_waypointmodel.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_GTKMM_WIDGET_WAYPOINTMODEL_H
+#define __SYNFIG_GTKMM_WIDGET_WAYPOINTMODEL_H
+
+/* === H E A D E R S ======================================================= */
+
+//#include <gtk/gtk.h>
+//#include <gtkmm/arrow.h>
+//#include <gtkmm/image.h>
+//#include <gdkmm/pixbufloader.h>
+//#include <gtkmm/viewport.h>
+//#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+//#include <gtkmm/progressbar.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/combo.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/checkbutton.h>
+
+
+#include <synfig/waypoint.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_Time;
+class Widget_WaypointModel;
+
+class Widget_WaypointModel : public Gtk::Table
+{
+ synfig::Waypoint::Model waypoint_model;
+
+ bool updating;
+
+ Gtk::Combo *in,*out;
+ Gtk::OptionMenu *before, *after;
+ Gtk::Menu *before_options,*after_options;
+
+ Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
+ Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
+
+ Gtk::CheckButton checkbutton_after;
+ Gtk::CheckButton checkbutton_before;
+ Gtk::CheckButton checkbutton_tension;
+ Gtk::CheckButton checkbutton_continuity;
+ Gtk::CheckButton checkbutton_bias;
+ Gtk::CheckButton checkbutton_temporal_tension;
+
+ void on_change();
+
+public:
+ Widget_WaypointModel();
+ void set_waypoint_model(synfig::Waypoint::Model &x);
+ const synfig::Waypoint::Model &get_waypoint_model()const { return waypoint_model; }
+}; // END of class Widget_WaypointModel
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
#include <synfigapp/canvasinterface.h>
#include "event_mouse.h"
#include "event_layerclick.h"
-#include "widget_color.h"
+#include "widgets/widget_color.h"
#include <synfig/distance.h>
#include "workarearenderer.h"