Author: Carlos Lopez <genet...@gmail.com>
Date:   Mon Jan  2 21:06:14 2012 +0100

Add new interpolation type. Non functional yet

---

 synfig-core/src/synfig/interpolation.h             |   16 +++++++-----
 synfig-core/src/synfig/loadcanvas.cpp              |    6 ++++-
 synfig-core/src/synfig/savecanvas.cpp              |    8 +++++-
 synfig-studio/src/gui/canvasview.cpp               |   12 ++++++++-
 synfig-studio/src/gui/widgets/widget_defaults.cpp  |    4 ++-
 .../src/gui/widgets/widget_timeslider.cpp          |   25 ++++++++++++++++++++
 6 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/synfig-core/src/synfig/interpolation.h 
b/synfig-core/src/synfig/interpolation.h
index 63f2ee6..d862123 100644
--- a/synfig-core/src/synfig/interpolation.h
+++ b/synfig-core/src/synfig/interpolation.h
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2012, 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
@@ -38,13 +39,14 @@ namespace synfig {
 
 enum Interpolation
 {
-       INTERPOLATION_TCB,                      // 0
-       INTERPOLATION_CONSTANT,         // 1
-       INTERPOLATION_LINEAR,           // 2
-       INTERPOLATION_HALT,                     // 3
-       INTERPOLATION_MANUAL,           // 4
-       INTERPOLATION_UNDEFINED,        // 5
-       INTERPOLATION_NIL                       // 6
+       INTERPOLATION_TCB,          // 0
+       INTERPOLATION_CONSTANT,     // 1
+       INTERPOLATION_LINEAR,       // 2
+       INTERPOLATION_HALT,         // 3
+       INTERPOLATION_MANUAL,       // 4
+       INTERPOLATION_UNDEFINED,    // 5
+       INTERPOLATION_NIL,          // 6
+       INTERPOLATION_CLAMPED       // 7
 }; // END enum Interpolation
 
 }; // END of namespace synfig
diff --git a/synfig-core/src/synfig/loadcanvas.cpp 
b/synfig-core/src/synfig/loadcanvas.cpp
index 3c03389..43383b6 100644
--- a/synfig-core/src/synfig/loadcanvas.cpp
+++ b/synfig-core/src/synfig/loadcanvas.cpp
@@ -9,7 +9,7 @@
 **     Copyright (c) 2007, 2008 Chris Moore
 **     Copyright (c) 2009 Carlos A. Sosa Navarro
 **     Copyright (c) 2009 Nikita Kitaev
-**  Copyright (c) 2011 Carlos López
+**  Copyright (c) 2011, 2012 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
@@ -1409,6 +1409,8 @@ CanvasParser::parse_animated(xmlpp::Element 
*element,Canvas::Handle canvas)
                                        
waypoint->set_before(INTERPOLATION_MANUAL);
                                else if(val=="auto")
                                        waypoint->set_before(INTERPOLATION_TCB);
+                               else if(val=="clamped")
+                                       
waypoint->set_before(INTERPOLATION_CLAMPED);
                                else
                                        error(child,strprintf(_("\"%s\" not a 
valid value for attribute \"%s\" in <%s>"),val.c_str(),"before","waypoint"));
                        }
@@ -1426,6 +1428,8 @@ CanvasParser::parse_animated(xmlpp::Element 
*element,Canvas::Handle canvas)
                                        
waypoint->set_after(INTERPOLATION_MANUAL);
                                else if(val=="auto")
                                        waypoint->set_after(INTERPOLATION_TCB);
+                               else if(val=="clamped")
+                                       
waypoint->set_after(INTERPOLATION_CLAMPED);
                                else
                                        error(child,strprintf(_("\"%s\" not a 
valid value for attribute \"%s\" in <%s>"),val.c_str(),"before","waypoint"));
                        }
diff --git a/synfig-core/src/synfig/savecanvas.cpp 
b/synfig-core/src/synfig/savecanvas.cpp
index 460575d..0aa738e 100644
--- a/synfig-core/src/synfig/savecanvas.cpp
+++ b/synfig-core/src/synfig/savecanvas.cpp
@@ -7,7 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007, 2008 Chris Moore
-**  Copyright (c) 2011 Carlos López
+**  Copyright (c) 2011, 2012 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
@@ -339,6 +339,9 @@ xmlpp::Element* encode_animated(xmlpp::Element* 
root,ValueNode_Animated::ConstHa
                case INTERPOLATION_TCB:
                        waypoint_node->set_attribute("before","auto");
                        break;
+               case INTERPOLATION_CLAMPED:
+                       waypoint_node->set_attribute("before","clamped");
+                       break;
                default:
                        error("Unknown waypoint type for \"before\" attribute");
                }
@@ -360,6 +363,9 @@ xmlpp::Element* encode_animated(xmlpp::Element* 
root,ValueNode_Animated::ConstHa
                case INTERPOLATION_TCB:
                        waypoint_node->set_attribute("after","auto");
                        break;
+               case INTERPOLATION_CLAMPED:
+                       waypoint_node->set_attribute("after","clamped");
+                       break;
                default:
                        error("Unknown waypoint type for \"after\" attribute");
                }
diff --git a/synfig-studio/src/gui/canvasview.cpp 
b/synfig-studio/src/gui/canvasview.cpp
index 162be65..c48f7d2 100644
--- a/synfig-studio/src/gui/canvasview.cpp
+++ b/synfig-studio/src/gui/canvasview.cpp
@@ -7,7 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2009, 2011 Carlos López
+**     Copyright (c) 2009, 2011, 2012 Carlos López
 **     Copyright (c) 2009, 2011 Nikita Kitaev
 **
 **     This package is free software; you can redistribute it and/or
@@ -3467,6 +3467,16 @@ 
CanvasView::on_waypoint_clicked_canvasview(synfigapp::ValueDesc value_desc,
                        model.set_before(INTERPOLATION_CONSTANT);
                        
interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
                                sigc::bind(sigc::ptr_fun(set_waypoint_model), 
waypoint_set, model, canvas_interface())));
+
+                       model.reset(); model.set_before(INTERPOLATION_CLAMPED);
+                       
interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Clamped"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), 
waypoint_set, model, canvas_interface())));
+                       model.reset(); model.set_after(INTERPOLATION_CLAMPED);
+                       
interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Clamped"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), 
waypoint_set, model, canvas_interface())));
+                       model.set_before(INTERPOLATION_CLAMPED);
+                       
interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Clamped"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), 
waypoint_set, model, canvas_interface())));
                }
 
                // 
------------------------------------------------------------------------
diff --git a/synfig-studio/src/gui/widgets/widget_defaults.cpp 
b/synfig-studio/src/gui/widgets/widget_defaults.cpp
index 9cbdbed..d1aba65 100644
--- a/synfig-studio/src/gui/widgets/widget_defaults.cpp
+++ b/synfig-studio/src/gui/widgets/widget_defaults.cpp
@@ -7,7 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **  Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2008 Carlos López
+**  Copyright (c) 2008, 2011, 2012 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
@@ -296,11 +296,13 @@ Widget_Defaults::Widget_Defaults()
                        
.add_enum_value(INTERPOLATION_CONSTANT,"constant",_("Constant"))
                        .add_enum_value(INTERPOLATION_HALT,"ease",_("Ease 
In/Out"))
                        
.add_enum_value(INTERPOLATION_LINEAR,"linear",_("Linear"))
+                       
.add_enum_value(INTERPOLATION_CLAMPED,"clamped",_("Clamped"))
        );
        widget_interpolation->set_icon(0, 
Gtk::Button().render_icon(Gtk::StockID("synfig-interpolation_type_tcb"),Gtk::ICON_SIZE_MENU));
        widget_interpolation->set_icon(1, 
Gtk::Button().render_icon(Gtk::StockID("synfig-interpolation_type_const"),Gtk::ICON_SIZE_MENU));
        widget_interpolation->set_icon(2, 
Gtk::Button().render_icon(Gtk::StockID("synfig-interpolation_type_ease"),Gtk::ICON_SIZE_MENU));
        widget_interpolation->set_icon(3, 
Gtk::Button().render_icon(Gtk::StockID("synfig-interpolation_type_linear"),Gtk::ICON_SIZE_MENU));
+       // TODO: add icon for Clamped
        attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, 
Gtk::SHRINK|Gtk::FILL, 1, 1);
        widget_interpolation->set_tooltip_text(_("Default Interpolation"));
 
diff --git a/synfig-studio/src/gui/widgets/widget_timeslider.cpp 
b/synfig-studio/src/gui/widgets/widget_timeslider.cpp
index 28d0673..5395bbb 100644
--- a/synfig-studio/src/gui/widgets/widget_timeslider.cpp
+++ b/synfig-studio/src/gui/widgets/widget_timeslider.cpp
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2004 Adrian Bentley
 **     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2012, 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
@@ -81,6 +82,10 @@ Gdk::Color get_interp_color(synfig::Interpolation x)
                return Gdk::Color("#B000B0");
                break;
 
+       case INTERPOLATION_CLAMPED:
+               return Gdk::Color("#c08000");
+               break;
+
        case INTERPOLATION_UNDEFINED: default:
                return Gdk::Color("#808080");
                break;
@@ -200,6 +205,16 @@ studio::render_time_point_to_window(
                window->draw_lines(gc,points);
                break;
 
+       case INTERPOLATION_CLAMPED:
+               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()/2));
+               
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()));
@@ -294,6 +309,16 @@ studio::render_time_point_to_window(
                window->draw_lines(gc,points);
                break;
 
+       case INTERPOLATION_CLAMPED:
+               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()+area.get_height()/2));
+               
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()));


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to