summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 31a65c3)
raw | patch | inline | side by side (parent: 31a65c3)
author | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sat, 28 Jul 2007 08:51:54 +0000 (08:51 +0000) | ||
committer | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sat, 28 Jul 2007 08:51:54 +0000 (08:51 +0000) |
* Added settings for feDiffuseLighting.
* Added color buttons for feDiffuseLighting and feSpecularLighting.
* Added color buttons for feDiffuseLighting and feSpecularLighting.
src/ui/dialog/filter-effects-dialog.cpp | patch | blob | history | |
src/ui/dialog/filter-effects-dialog.h | patch | blob | history |
index bd834608e86e52e05c7b602b8597c8f6aa508b46..119dda377f0f022ed07c203343c36ed5d6033a06 100644 (file)
#include <gtk/gtktreeview.h>
#include <gtkmm/cellrenderertext.h>
+#include <gtkmm/colorbutton.h>
#include <gtkmm/paned.h>
#include <gtkmm/scale.h>
#include <gtkmm/scrolledwindow.h>
#include "sp-gaussian-blur.h"
#include "sp-feoffset.h"
#include "style.h"
+#include "svg/svg-color.h"
#include "verbs.h"
#include "xml/node.h"
#include "xml/repr.h"
namespace UI {
namespace Dialog {
+class ColorButton : public Gtk::ColorButton, public AttrWidget
+{
+public:
+ ColorButton(const SPAttributeEnum a)
+ : AttrWidget(a)
+ {
+ Gdk::Color col;
+ col.set_rgb(65535, 65535, 65535);
+ set_color(col);
+ }
+
+ // Returns the color in 'rgb(r,g,b)' form.
+ Glib::ustring get_as_attribute() const
+ {
+ std::ostringstream os;
+ const Gdk::Color c = get_color();
+ const int r = (c.get_red() + 1) / 256 - 1, g = (c.get_green() + 1) / 256 - 1, b = (c.get_blue() + 1) / 256 - 1;
+ os << "rgb(" << r << "," << g << "," << b << ")";
+ return os.str();
+ }
+
+
+ void set_from_attribute(SPObject* o)
+ {
+ const gchar* val = attribute_value(o);
+ if(val) {
+ const guint32 i = sp_svg_read_color(val, 0xFFFFFFFF);
+ const int r = SP_RGBA32_R_U(i) + 1, g = SP_RGBA32_G_U(i) + 1, b = SP_RGBA32_B_U(i) + 1;
+ Gdk::Color col;
+ col.set_rgb(r * 256 - 1, g * 256 - 1, b * 256 - 1);
+ set_color(col);
+ }
+ }
+};
+
/* Displays/Edits the kernel matrix for feConvolveMatrix */
class FilterEffectsDialog::ConvolveMatrix : public Gtk::TreeView, public AttrWidget
{
_current_type = t;
}
- void add(Gtk::ColorButton& cb, const SPAttributeEnum attr, const Glib::ustring& label)
+ ColorButton* add_color(const SPAttributeEnum attr, const Glib::ustring& label)
{
- //generic_add(cb, label);
- //cb.signal_color_set().connect(
- // sigc::bind(sigc::mem_fun(_dialog, &FilterEffectsDialog::set_attr_color), attr, &cb));
+ ColorButton* col = new ColorButton(attr);
+ add_widget(*col, label);
+ _attrwidgets[_current_type].push_back(col);
+ col->signal_color_set().connect(
+ sigc::bind(sigc::mem_fun(_dialog, &FilterEffectsDialog::set_attr_direct), attr, col));
+ return col;
}
// ConvolveMatrix
_convolve_order->signal_value_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed));
_settings->add(SP_ATTR_DIVISOR, _("Divisor"), 0.01, 10, 1, 0.01, 1);
_settings->add(SP_ATTR_BIAS, _("Bias"), -10, 10, 1, 0.01, 1);
+
+ _settings->type(NR_FILTER_DIFFUSELIGHTING);
+ _settings->add_color(SP_PROP_LIGHTING_COLOR, _("Diffuse Color"));
+ _settings->add(SP_ATTR_SURFACESCALE, _("Surface Scale"), -10, 10, 1, 0.01, 1);
+ _settings->add(SP_ATTR_DIFFUSECONSTANT, _("Constant"), 0, 100, 1, 0.01, 1);
+ _settings->add(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length X"), _("Kernel Unit Length Y"), 0.01, 10, 1, 0.01, 1);
_settings->type(NR_FILTER_GAUSSIANBLUR);
_settings->add(SP_ATTR_STDDEVIATION, _("Standard Deviation X"), _("Standard Deviation Y"), 0.01, 100, 1, 0.01, 1);
_settings->add(SP_ATTR_DY, _("Delta Y"), -100, 100, 1, 0.01, 1);
_settings->type(NR_FILTER_SPECULARLIGHTING);
- //_settings->add(_specular_color, SP_PROP_LIGHTING_COLOR, _("Specular Color"));
+ _settings->add_color(SP_PROP_LIGHTING_COLOR, _("Specular Color"));
_settings->add(SP_ATTR_SURFACESCALE, _("Surface Scale"), -10, 10, 1, 0.01, 1);
_settings->add(SP_ATTR_SPECULARCONSTANT, _("Constant"), 0, 100, 1, 0.01, 1);
_settings->add(SP_ATTR_SPECULAREXPONENT, _("Exponent"), 1, 128, 1, 0.01, 1);
+ _settings->add(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length X"), _("Kernel Unit Length Y"), 0.01, 10, 1, 0.01, 1);
_settings->type(NR_FILTER_TURBULENCE);
/*std::vector<Gtk::Widget*> trb_grp;
_convolve_ty->get_adjustment().set_upper(_convolve_order->get_spinslider2().get_value());
}
-void FilterEffectsDialog::set_attr_color(const SPAttributeEnum attr, const Gtk::ColorButton* input)
-{
- if(input->is_sensitive()) {
- std::ostringstream os;
- const Gdk::Color c = input->get_color();
- const int r = 255 * c.get_red() / 65535, g = 255 * c.get_green() / 65535, b = 255 * c.get_blue() / 65535;
- os << "rgb(" << r << "," << g << "," << b << ")";
- set_attr(attr, os.str().c_str());
- }
-}
-
void FilterEffectsDialog::set_attr_direct(const SPAttributeEnum attr, const AttrWidget* input)
{
set_attr(attr, input->get_as_attribute().c_str());
index 9e9a02f47bc1e000c61872386d1eaa3ca01ce0d7..b80ab7686542d2aa3dfe7d5ec9ba427230c8b7bf 100644 (file)
#include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/cellrendererspin.h>
-#include "gtkmm/colorbutton.h"
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/frame.h>
void duplicate_primitive();
void convolve_order_changed();
- void set_attr_color(const SPAttributeEnum attr, const Gtk::ColorButton*);
void set_attr_direct(const SPAttributeEnum attr, const AttrWidget*);
void set_attr_special(const SPAttributeEnum);
void set_attr(const SPAttributeEnum, const gchar* val);