X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fwidget_gradient.cpp;h=80738cb98aedc4b381af872fca4f62a598e51409;hb=72f82d29ebd4fd20144d4d674c5e8e443f24f6b0;hp=da075896c040c47c42b83d1b87f2f0dde82f5aa3;hpb=3a3c4bca3a17137bec5d7960560934b91ef4146e;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp b/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp index da07589..80738cb 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp @@ -1,20 +1,22 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file widget_gradient.cpp ** \brief Template File ** -** $Id: widget_gradient.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** 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. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** 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 */ /* ========================================================================= */ @@ -31,7 +33,7 @@ #include "widget_gradient.h" #include "app.h" #include -#include +#include #include #endif @@ -40,7 +42,7 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; using namespace studio; /* === M A C R O S ========================================================= */ @@ -50,7 +52,7 @@ using namespace studio; /* === P R O C E D U R E S ================================================= */ void -studio::render_gradient_to_window(const Glib::RefPtr& window,const Gdk::Rectangle& ca,const sinfg::Gradient &gradient) +studio::render_gradient_to_window(const Glib::RefPtr& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient) { int height = ca.get_height(); int width = ca.get_width()-4; @@ -72,13 +74,13 @@ studio::render_gradient_to_window(const Glib::RefPtr& window,cons 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); - + 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); @@ -87,8 +89,8 @@ studio::render_gradient_to_window(const Glib::RefPtr& window,cons { 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); - + 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); @@ -111,18 +113,18 @@ Widget_Gradient::Widget_Gradient(): add_events(Gdk::BUTTON1_MOTION_MASK); } - + Widget_Gradient::~Widget_Gradient() { } #define CONTROL_HEIGHT 16 bool -Widget_Gradient::redraw(GdkEventExpose*bleh) +Widget_Gradient::redraw(GdkEventExpose */*bleh*/) { const int h(get_height()); const int w(get_width()); - + Glib::RefPtr gc(Gdk::GC::create(get_window())); Gdk::Rectangle area(0,0,w,h); if(!editable_) @@ -161,7 +163,7 @@ Widget_Gradient::redraw(GdkEventExpose*bleh) show_selected=true; } } - + // we do this so that we can be sure that // the selected marker is shown on top if(show_selected) @@ -181,7 +183,7 @@ Widget_Gradient::redraw(GdkEventExpose*bleh) CONTROL_HEIGHT ); } - + return true; } @@ -202,6 +204,7 @@ void Widget_Gradient::remove_cpoint(float x) { gradient_.erase(gradient_.proximity(x)); + signal_value_changed_(); queue_draw(); } @@ -209,7 +212,8 @@ 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( @@ -234,12 +238,12 @@ Widget_Gradient::popup_menu(float x) ) ); } - + menu->popup(0,0); } void -Widget_Gradient::set_value(const sinfg::Gradient& x) +Widget_Gradient::set_value(const synfig::Gradient& x) { gradient_=x; if(gradient_.size()) @@ -248,7 +252,7 @@ Widget_Gradient::set_value(const sinfg::Gradient& x) } void -Widget_Gradient::set_selected_cpoint(const sinfg::Gradient::CPoint &x) +Widget_Gradient::set_selected_cpoint(const synfig::Gradient::CPoint &x) { selected_cpoint=x; signal_cpoint_selected_(selected_cpoint); @@ -256,7 +260,7 @@ Widget_Gradient::set_selected_cpoint(const sinfg::Gradient::CPoint &x) } void -Widget_Gradient::update_cpoint(const sinfg::Gradient::CPoint &x) +Widget_Gradient::update_cpoint(const synfig::Gradient::CPoint &x) { try { @@ -266,7 +270,7 @@ Widget_Gradient::update_cpoint(const sinfg::Gradient::CPoint &x) gradient_.sort(); queue_draw(); } - catch(sinfg::Exception::NotFound) + catch(synfig::Exception::NotFound) { // Yotta... } @@ -283,14 +287,14 @@ Widget_Gradient::on_event(GdkEvent *event) 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) { Gradient::iterator iter(gradient_.find(selected_cpoint)); - + if(event->button.state&GDK_SHIFT_MASK) { float begin(-100000000),end(100000000); @@ -305,20 +309,20 @@ Widget_Gradient::on_event(GdkEvent *event) { end=after->pos; } - + if(pos>end) pos=end; if(pospos=pos; + + iter->pos=pos; } else { iter->pos=pos; gradient_.sort(); } - + // signal_value_changed_(); changed_=true; queue_draw(); @@ -358,6 +362,6 @@ Widget_Gradient::on_event(GdkEvent *event) break; } } - + return false; }