/*! \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
*/
/* ========================================================================= */
#include <synfig/exception.h>
#include <ETL/misc>
+#include "general.h"
+
#endif
/* === U S I N G =========================================================== */
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);
{
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);
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<Gdk::GC> gc(Gdk::GC::create(get_window()));
Gdk::Rectangle area(0,0,w,h);
if(!editable_)
show_selected=true;
}
}
-
+
// we do this so that we can be sure that
// the selected marker is shown on top
if(show_selected)
CONTROL_HEIGHT
);
}
-
+
return true;
}
Widget_Gradient::remove_cpoint(float x)
{
gradient_.erase(gradient_.proximity(x));
+ signal_value_changed_();
queue_draw();
}
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(
)
);
}
-
+
menu->popup(0,0);
}
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);
{
end=after->pos;
}
-
+
if(pos>end)
pos=end;
if(pos<begin)
pos=begin;
-
- iter->pos=pos;
+
+ iter->pos=pos;
}
else
{
iter->pos=pos;
gradient_.sort();
}
-
+
// signal_value_changed_();
changed_=true;
queue_draw();
break;
}
}
-
+
return false;
}