X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fui%2Fdialog%2Ffilter-effects-dialog.cpp;h=4ea5faf138a1c9b68d655f72e1bc9298877f2436;hb=fb2c6b206989f303ea4a7e97876eaebf674aa07d;hp=fe2e8f1c6fc66283f19813fdb8d62e70080e3a0e;hpb=e1340809e493886df96a707098af3f6923069ff8;p=inkscape.git diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index fe2e8f1c6..4ea5faf13 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -37,6 +37,7 @@ #include "selection.h" #include "sp-feblend.h" #include "sp-fecolormatrix.h" +#include "sp-fecomponenttransfer.h" #include "sp-fecomposite.h" #include "sp-feconvolvematrix.h" #include "sp-fedisplacementmap.h" @@ -291,7 +292,7 @@ public: { 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; + const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257; os << "rgb(" << r << "," << g << "," << b << ")"; return os.str(); } @@ -302,9 +303,9 @@ public: 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; + const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i); Gdk::Color col; - col.set_rgb(r * 256 - 1, g * 256 - 1, b * 256 - 1); + col.set_rgb(r * 257, g * 257, b * 257); set_color(col); } } @@ -315,7 +316,7 @@ class FilterEffectsDialog::MatrixAttr : public Gtk::Frame, public AttrWidget { public: MatrixAttr(const SPAttributeEnum a) - : AttrWidget(a) + : AttrWidget(a), _locked(false) { _model = Gtk::ListStore::create(_columns); _tree.set_model(_model); @@ -325,6 +326,31 @@ public: set_shadow_type(Gtk::SHADOW_IN); } + std::vector get_values() const + { + std::vector vec; + for(Gtk::TreeIter iter = _model->children().begin(); + iter != _model->children().end(); ++iter) { + for(unsigned c = 0; c < _tree.get_columns().size(); ++c) + vec.push_back((*iter)[_columns.cols[c]]); + } + return vec; + } + + void set_values(const std::vector& v) + { + unsigned i = 0; + for(Gtk::TreeIter iter = _model->children().begin(); + iter != _model->children().end(); ++iter) { + for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { + if(i >= v.size()) + return; + (*iter)[_columns.cols[c]] = v[i]; + ++i; + } + } + } + Glib::ustring get_as_attribute() const { std::ostringstream os; @@ -370,6 +396,9 @@ private: void update(SPObject* o, const int rows, const int cols) { + if(_locked) + return; + _model->clear(); _tree.remove_all_columns(); @@ -388,7 +417,7 @@ private: for(int i = 0; i < cols; ++i) { _tree.append_column_numeric_editable("", _columns.cols[i], "%.2f"); dynamic_cast( - _tree.get_column(i)->get_first_cell_renderer())->signal_edited().connect( + _tree.get_column_cell_renderer(i))->signal_edited().connect( sigc::mem_fun(*this, &MatrixAttr::rebind)); } @@ -402,9 +431,12 @@ private: void rebind(const Glib::ustring&, const Glib::ustring&) { + _locked = true; signal_attr_changed()(); + _locked = false; } + bool _locked; Gtk::TreeView _tree; Glib::RefPtr _model; MatrixColumns _columns; @@ -419,11 +451,15 @@ public: _matrix(SP_ATTR_VALUES), _saturation(0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES), _angle(0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), - _label(_("None"), Gtk::ALIGN_LEFT) + _label(_("None"), Gtk::ALIGN_LEFT), + _use_stored(false), + _saturation_store(0), + _angle_store(0) { _matrix.signal_attr_changed().connect(signal_attr_changed().make_slot()); _saturation.signal_attr_changed().connect(signal_attr_changed().make_slot()); _angle.signal_attr_changed().connect(signal_attr_changed().make_slot()); + signal_attr_changed().connect(sigc::mem_fun(*this, &ColorMatrixValues::update_store)); _matrix.show(); _saturation.show(); @@ -442,11 +478,17 @@ public: switch(col->type) { case COLORMATRIX_SATURATE: add(_saturation); - _saturation.set_from_attribute(o); + if(_use_stored) + _saturation.set_value(_saturation_store); + else + _saturation.set_from_attribute(o); break; case COLORMATRIX_HUEROTATE: add(_angle); - _angle.set_from_attribute(o); + if(_use_stored) + _angle.set_value(_angle_store); + else + _angle.set_from_attribute(o); break; case COLORMATRIX_LUMINANCETOALPHA: add(_label); @@ -454,9 +496,13 @@ public: case COLORMATRIX_MATRIX: default: add(_matrix); - _matrix.set_from_attribute(o); + if(_use_stored) + _matrix.set_values(_matrix_store); + else + _matrix.set_from_attribute(o); break; } + _use_stored = true; } } @@ -468,11 +514,33 @@ public: else return dynamic_cast(w)->get_as_attribute(); } + + void clear_store() + { + _use_stored = false; + } private: + void update_store() + { + const Widget* w = get_child(); + if(w == &_matrix) + _matrix_store = _matrix.get_values(); + else if(w == &_saturation) + _saturation_store = _saturation.get_value(); + else if(w == &_angle) + _angle_store = _angle.get_value(); + } + MatrixAttr _matrix; SpinSlider _saturation; SpinSlider _angle; Gtk::Label _label; + + // Store separate values for the different color modes + bool _use_stored; + std::vector _matrix_store; + double _saturation_store; + double _angle_store; }; class FilterEffectsDialog::Settings @@ -480,7 +548,7 @@ class FilterEffectsDialog::Settings public: typedef sigc::slot SetAttrSlot; - Settings(FilterEffectsDialog& d, SetAttrSlot slot, const int maxtypes) + Settings(FilterEffectsDialog& d, Gtk::Box& b, SetAttrSlot slot, const int maxtypes) : _dialog(d), _set_attr_slot(slot), _current_type(-1), _max_types(maxtypes) { _groups.resize(_max_types); @@ -488,7 +556,7 @@ public: for(int i = 0; i < _max_types; ++i) { _groups[i] = new Gtk::VBox; - d._settings_box.add(*_groups[i]); + b.add(*_groups[i]); } } @@ -509,7 +577,8 @@ public: for(unsigned i = 0; i < _groups.size(); ++i) _groups[i]->hide(); } - _groups[t]->show_all(); + if(t >= 0) + _groups[t]->show_all(); _dialog.set_attrs_locked(true); for(unsigned i = 0; i < _attrwidgets[_current_type].size(); ++i) @@ -528,7 +597,7 @@ public: } // LightSource - LightSourceControl* add_lightsource(const Glib::ustring& label); + LightSourceControl* add_lightsource(); // CheckBox CheckButtonAttr* add_checkbutton(const SPAttributeEnum attr, const Glib::ustring& label, @@ -649,18 +718,20 @@ private: and all widgets within the setting group are aligned automatically. */ void add_widget(Gtk::Widget* w, const Glib::ustring& label) { - Gtk::Label *lbl = Gtk::manage(new Gtk::Label(label + (label == "" ? "" : ":"), Gtk::ALIGN_LEFT)); + Gtk::Label *lbl = 0; Gtk::HBox *hb = Gtk::manage(new Gtk::HBox); hb->set_spacing(12); - hb->pack_start(*lbl, false, false); + + if(label != "") { + lbl = Gtk::manage(new Gtk::Label(label + (label == "" ? "" : ":"), Gtk::ALIGN_LEFT)); + hb->pack_start(*lbl, false, false); + _dialog._sizegroup->add_widget(*lbl); + lbl->show(); + } + hb->pack_start(*w); _groups[_current_type]->pack_start(*hb); - - _dialog._sizegroup->add_widget(*lbl); - hb->show(); - lbl->show(); - w->show(); } @@ -679,18 +750,26 @@ public: LightSourceControl(FilterEffectsDialog& d) : AttrWidget(SP_ATTR_INVALID), _dialog(d), - _settings(d, sigc::mem_fun(_dialog, &FilterEffectsDialog::set_child_attr_direct), LIGHT_ENDSOURCE), - _light_source(LightSourceConverter) + _settings(d, _box, sigc::mem_fun(_dialog, &FilterEffectsDialog::set_child_attr_direct), LIGHT_ENDSOURCE), + _light_label(_("Light Source:"), Gtk::ALIGN_LEFT), + _light_source(LightSourceConverter), + _locked(false) { - _box.add(_light_source); - _box.reorder_child(_light_source, 0); + _light_box.pack_start(_light_label, false, false); + _light_box.pack_start(_light_source); + _light_box.show_all(); + _light_box.set_spacing(12); + _dialog._sizegroup->add_widget(_light_label); + + _box.add(_light_box); + _box.reorder_child(_light_box, 0); _light_source.signal_changed().connect(sigc::mem_fun(*this, &LightSourceControl::on_source_changed)); // FIXME: these range values are complete crap _settings.type(LIGHT_DISTANT); _settings.add_spinslider(SP_ATTR_AZIMUTH, _("Azimuth"), 0, 360, 1, 1, 0); - _settings.add_spinslider(SP_ATTR_AZIMUTH, _("Elevation"), 0, 360, 1, 1, 0); + _settings.add_spinslider(SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0); _settings.type(LIGHT_POINT); _settings.add_multispinbutton(SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location"), -99999, 99999, 1, 100, 0); @@ -714,6 +793,11 @@ protected: } void set_from_attribute(SPObject* o) { + if(_locked) + return; + + _locked = true; + SPObject* child = o->children; if(SP_IS_FEDISTANTLIGHT(child)) @@ -722,31 +806,44 @@ protected: _light_source.set_active(1); else if(SP_IS_FESPOTLIGHT(child)) _light_source.set_active(2); + else + _light_source.set_active(-1); update(); + + _locked = false; } private: void on_source_changed() { + if(_locked) + return; + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); if(prim) { + _locked = true; + SPObject* child = prim->children; const int ls = _light_source.get_active_row_number(); // Check if the light source type has changed - if(!(ls == 0 && SP_IS_FEDISTANTLIGHT(child)) && + if(!(ls == -1 && !child) && + !(ls == 0 && SP_IS_FEDISTANTLIGHT(child)) && !(ls == 1 && SP_IS_FEPOINTLIGHT(child)) && !(ls == 2 && SP_IS_FESPOTLIGHT(child))) { if(child) sp_repr_unparent(child->repr); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); - Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); - repr->setAttribute("inkscape:collect", "always"); - prim->repr->appendChild(repr); - Inkscape::GC::release(repr); + if(ls != -1) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); + Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); + prim->repr->appendChild(repr); + } + sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); update(); } + + _locked = false; } } @@ -754,7 +851,7 @@ private: { _box.hide_all(); _box.show(); - _light_source.show_all(); + _light_box.show_all(); SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); if(prim && prim->children) @@ -764,14 +861,17 @@ private: FilterEffectsDialog& _dialog; Gtk::VBox _box; Settings _settings; + Gtk::HBox _light_box; + Gtk::Label _light_label; ComboBoxEnum _light_source; + bool _locked; }; -FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_lightsource(const Glib::ustring& label) +FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_lightsource() { LightSourceControl* ls = new LightSourceControl(_dialog); add_attr_widget(ls); - add_widget(&ls->get_box(), label); + add_widget(&ls->get_box(), ""); return ls; } @@ -792,7 +892,7 @@ Glib::RefPtr create_popup_menu(Gtk::Widget& parent, sigc::slot /*** FilterModifier ***/ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) - : _dialog(d), _add(Gtk::Stock::ADD), _observer(new SignalObserver) + : _dialog(d), _add(Gtk::Stock::NEW), _observer(new SignalObserver) { Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow); pack_start(*sw); @@ -953,6 +1053,8 @@ void FilterEffectsDialog::FilterModifier::update_filters() const gchar* id = SP_OBJECT_ID(f); row[_columns.label] = lbl ? lbl : (id ? id : "filter"); } + + update_selection(desktop->selection); } SPFilter* FilterEffectsDialog::FilterModifier::get_selected_filter() @@ -1064,7 +1166,8 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter() void FilterEffectsDialog::FilterModifier::rename_filter() { SPFilter* filter = get_selected_filter(); - Gtk::Dialog m("", _dialog, true); + Gtk::Window *window = dynamic_cast(_dialog.get_vbox()->get_ancestor(GTK_TYPE_WINDOW)); + Gtk::Dialog m("", *window, true); m.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); m.add_button(_("_Rename"), Gtk::RESPONSE_OK); m.set_default_response(Gtk::RESPONSE_OK); @@ -1141,7 +1244,7 @@ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) set_reorderable(true); set_model(_model); - append_column(_("_Type"), _columns.type); + append_column(_("_Effect"), _columns.type); _observer->signal_changed().connect(signal_primitive_changed().make_slot()); get_selection()->signal_changed().connect(sigc::mem_fun(*this, &PrimitiveList::on_primitive_selection_changed)); @@ -1186,6 +1289,7 @@ void FilterEffectsDialog::PrimitiveList::on_primitive_selection_changed() { _observer->set(get_selected()); signal_primitive_changed()(); + _dialog._color_matrix_values->clear_store(); } /* Add all filter primitives in the current to the list. @@ -1361,31 +1465,49 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Gtk::TreeIter& in const int text_start_x, const int x1, const int y1, const int row_count) { - int src_id; - const Gtk::TreeIter res = find_result(input, attr, src_id); - Glib::RefPtr gc = get_style()->get_black_gc(); + int src_id = 0; + Gtk::TreeIter res = find_result(input, attr, src_id); + Glib::RefPtr darkgc = get_style()->get_black_gc(); + Glib::RefPtr lightgc = get_style()->get_dark_gc(Gtk::STATE_NORMAL); + Glib::RefPtr gc; + + const bool is_first = input == get_model()->children().begin(); + const bool is_merge = SP_IS_FEMERGE((SPFilterPrimitive*)(*input)[_columns.primitive]); + const bool use_default = !res && !is_merge; - if(res == input) { + if(res == input || (use_default && is_first)) { // Draw straight connection to a standard input + // Draw a lighter line for an implicit connection to a standard input const int tw = _connection_cell.get_text_width(); gint end_x = text_start_x + tw * (src_id + 1) + (int)(tw * 0.5f) + 1; + gc = (use_default && is_first) ? lightgc : darkgc; get_bin_window()->draw_rectangle(gc, true, end_x-2, y1-2, 5, 5); get_bin_window()->draw_line(gc, x1, y1, end_x, y1); } - else if(res != _model->children().end()) { - Gdk::Rectangle rct; - - get_cell_area(get_model()->get_path(_model->children().begin()), *get_column(1), rct); - const int fheight = CellRendererConnection::size; + else { + // Draw an 'L'-shaped connection to another filter primitive + // If no connection is specified, draw a light connection to the previous primitive + gc = use_default ? lightgc : darkgc; - get_cell_area(get_model()->get_path(res), *get_column(1), rct); - const int row_index = find_index(res); - const int x2 = rct.get_x() + fheight * (row_count - row_index) - fheight / 2; - const int y2 = rct.get_y() + rct.get_height(); + if(use_default) { + res = input; + --res; + } - // Draw an 'L'-shaped connection to another filter primitive - get_bin_window()->draw_line(gc, x1, y1, x2, y1); - get_bin_window()->draw_line(gc, x2, y1, x2, y2); + if(res) { + Gdk::Rectangle rct; + + get_cell_area(get_model()->get_path(_model->children().begin()), *get_column(1), rct); + const int fheight = CellRendererConnection::size; + + get_cell_area(get_model()->get_path(res), *get_column(1), rct); + const int row_index = find_index(res); + const int x2 = rct.get_x() + fheight * (row_count - row_index) - fheight / 2; + const int y2 = rct.get_y() + rct.get_height(); + + get_bin_window()->draw_line(gc, x1, y1, x2, y1); + get_bin_window()->draw_line(gc, x2, y1, x2, y2); + } } } @@ -1423,10 +1545,15 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; + bool found = false; for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) { - if(c == attr && SP_IS_FEMERGENODE(o)) + if(c == attr && SP_IS_FEMERGENODE(o)) { image = SP_FEMERGENODE(o)->input; + found = true; + } } + if(!found) + return target; } else { if(attr == SP_ATTR_IN) @@ -1496,6 +1623,8 @@ bool FilterEffectsDialog::PrimitiveList::on_button_press_event(GdkEventButton* e } if(_in_drag) { + _scroll_connection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &PrimitiveList::on_scroll_timeout), 150); + _autoscroll = 0; get_selection()->select(path); return true; } @@ -1505,6 +1634,28 @@ bool FilterEffectsDialog::PrimitiveList::on_button_press_event(GdkEventButton* e bool FilterEffectsDialog::PrimitiveList::on_motion_notify_event(GdkEventMotion* e) { + const int speed = 10; + const int limit = 15; + + Gdk::Rectangle vis; + get_visible_rect(vis); + int vis_x, vis_y; + tree_to_widget_coords(vis.get_x(), vis.get_y(), vis_x, vis_y); + const int top = vis_y + vis.get_height(); + + // When autoscrolling during a connection drag, set the speed based on + // where the mouse is in relation to the edges. + if(e->y < vis_y) + _autoscroll = -(int)(speed + (vis_y - e->y) / 5); + else if(e->y < vis_y + limit) + _autoscroll = -speed; + else if(e->y > top) + _autoscroll = (int)(speed + (e->y - top) / 5); + else if(e->y > top - limit) + _autoscroll = speed; + else + _autoscroll = 0; + queue_draw(); return Gtk::TreeView::on_motion_notify_event(e); @@ -1514,6 +1665,8 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* { SPFilterPrimitive *prim = get_selected(), *target; + _scroll_connection.disconnect(); + if(_in_drag && prim) { Gtk::TreePath path; Gtk::TreeViewColumn* col; @@ -1576,7 +1729,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* } } // Add new input? - if(!handled && c == _in_drag) { + if(!handled && c == _in_drag && in_val) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); Inkscape::XML::Node *repr = xml_doc->createElement("svg:feMergeNode"); repr->setAttribute("inkscape:collect", "always"); @@ -1657,7 +1810,7 @@ void FilterEffectsDialog::PrimitiveList::sanitize_connections(const Gtk::TreeIte } // Reorder the filter primitives to match the list order -void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr&) +void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr& dc) { SPFilter* filter = _dialog._filter_modifier.get_selected_filter(); int ndx = 0; @@ -1665,12 +1818,19 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtrchildren().begin(); iter != _model->children().end(); ++iter, ++ndx) { SPFilterPrimitive* prim = (*iter)[_columns.primitive]; - if(prim) { + if(prim && prim == _drag_prim) { SP_OBJECT_REPR(prim)->setPosition(ndx); - if(_drag_prim == prim) { - sanitize_connections(iter); - get_selection()->select(iter); - } + break; + } + } + + for(Gtk::TreeModel::iterator iter = _model->children().begin(); + iter != _model->children().end(); ++iter, ++ndx) { + SPFilterPrimitive* prim = (*iter)[_columns.primitive]; + if(prim && prim == _drag_prim) { + sanitize_connections(iter); + get_selection()->select(iter); + break; } } @@ -1679,6 +1839,27 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtrdocument, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); } +// If a connection is dragged towards the top or bottom of the list, the list should scroll to follow. +bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() +{ + if(_autoscroll) { + Gtk::Adjustment& a = *dynamic_cast(get_parent())->get_vadjustment(); + double v; + + v = a.get_value() + _autoscroll; + if(v < 0) + v = 0; + if(v > a.get_upper() - a.get_page_size()) + v = a.get_upper() - a.get_page_size(); + + a.set_value(v); + + queue_draw(); + } + + return true; +} + int FilterEffectsDialog::PrimitiveList::primitive_count() const { return _model->children().size(); @@ -1686,16 +1867,17 @@ int FilterEffectsDialog::PrimitiveList::primitive_count() const /*** FilterEffectsDialog ***/ -FilterEffectsDialog::FilterEffectsDialog() - : Dialog ("dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS), +FilterEffectsDialog::FilterEffectsDialog(Behavior::BehaviorFactory behavior_factory) + : Dialog (behavior_factory, "dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS), _filter_modifier(*this), _primitive_list(*this), _add_primitive_type(FPConverter), - _add_primitive(Gtk::Stock::ADD), - _empty_settings(_("No primitive selected"), Gtk::ALIGN_LEFT), - _locked(false) + _add_primitive(_("Add Effect:")), + _empty_settings(_("No effect selected"), Gtk::ALIGN_LEFT), + _locked(false), + _attr_lock(false) { - _settings = new Settings(*this, sigc::mem_fun(*this, &FilterEffectsDialog::set_attr_direct), + _settings = new Settings(*this, _settings_box, sigc::mem_fun(*this, &FilterEffectsDialog::set_attr_direct), NR_FILTER_ENDPRIMITIVETYPE); _sizegroup = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL); _sizegroup->set_ignore_hidden(); @@ -1704,7 +1886,7 @@ FilterEffectsDialog::FilterEffectsDialog() Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned); Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); Gtk::HBox* hb_prims = Gtk::manage(new Gtk::HBox); - Gtk::Frame* fr_settings = Gtk::manage(new Gtk::Frame(_("Settings"))); + Gtk::Frame* fr_settings = Gtk::manage(new Gtk::Frame(_("Effect parameters"))); Gtk::Alignment* al_settings = Gtk::manage(new Gtk::Alignment); get_vbox()->add(*hpaned); hpaned->pack1(_filter_modifier); @@ -1712,8 +1894,8 @@ FilterEffectsDialog::FilterEffectsDialog() _primitive_box.pack_start(*sw_prims); _primitive_box.pack_start(*hb_prims, false, false); sw_prims->add(_primitive_list); - hb_prims->pack_end(_add_primitive, false, false); hb_prims->pack_end(_add_primitive_type, false, false); + hb_prims->pack_end(_add_primitive, false, false); get_vbox()->pack_start(*fr_settings, false, false); fr_settings->add(*al_settings); al_settings->add(_settings_box); @@ -1764,6 +1946,14 @@ void FilterEffectsDialog::init_settings_widgets() _color_matrix_values = _settings->add_colormatrixvalues(_("Value(s)")); colmat->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::update_color_matrix)); + _settings->type(NR_FILTER_COMPONENTTRANSFER); + _settings->add_combo(SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter); + _ct_slope = _settings->add_spinslider(SP_ATTR_SLOPE, _("Slope"), -100, 100, 1, 0.01, 1); + _ct_intercept = _settings->add_spinslider(SP_ATTR_INTERCEPT, _("Intercept"), -100, 100, 1, 0.01, 1); + _ct_amplitude = _settings->add_spinslider(SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 100, 1, 0.01, 1); + _ct_exponent = _settings->add_spinslider(SP_ATTR_EXPONENT, _("Exponent"), 0, 100, 1, 0.01, 1); + _ct_offset = _settings->add_spinslider(SP_ATTR_OFFSET, _("Offset"), -100, 100, 1, 0.01, 1); + _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter); _k1 = _settings->add_spinslider(SP_ATTR_K1, _("K1"), -10, 10, 1, 0.01, 1); @@ -1785,12 +1975,16 @@ void FilterEffectsDialog::init_settings_widgets() _settings->add_spinslider(SP_ATTR_SURFACESCALE, _("Surface Scale"), -10, 10, 1, 0.01, 1); _settings->add_spinslider(SP_ATTR_DIFFUSECONSTANT, _("Constant"), 0, 100, 1, 0.01, 1); _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length"), 0.01, 10, 1, 0.01, 1); - _settings->add_lightsource(_("Light Source")); + _settings->add_lightsource(); _settings->type(NR_FILTER_DISPLACEMENTMAP); _settings->add_spinslider(SP_ATTR_SCALE, _("Scale"), 0, 100, 1, 0.01, 1); _settings->add_combo(SP_ATTR_XCHANNELSELECTOR, _("X Channel"), DisplacementMapChannelConverter); _settings->add_combo(SP_ATTR_YCHANNELSELECTOR, _("Y Channel"), DisplacementMapChannelConverter); + + _settings->type(NR_FILTER_FLOOD); + _settings->add_color(SP_PROP_FLOOD_COLOR, _("Flood Color")); + _settings->add_spinslider(SP_PROP_FLOOD_OPACITY, _("Opacity"), 0, 1, 0.1, 0.01, 2); _settings->type(NR_FILTER_GAUSSIANBLUR); _settings->add_dualspinslider(SP_ATTR_STDDEVIATION, _("Standard Deviation"), 0.01, 100, 1, 0.01, 1); @@ -1809,10 +2003,11 @@ void FilterEffectsDialog::init_settings_widgets() _settings->add_spinslider(SP_ATTR_SPECULARCONSTANT, _("Constant"), 0, 100, 1, 0.01, 1); _settings->add_spinslider(SP_ATTR_SPECULAREXPONENT, _("Exponent"), 1, 128, 1, 0.01, 1); _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length"), 0.01, 10, 1, 0.01, 1); - _settings->add_lightsource(_("Light Source")); + _settings->add_lightsource(); _settings->type(NR_FILTER_TURBULENCE); _settings->add_checkbutton(SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch"); + _settings->add_combo(SP_ATTR_TYPE, _("Type"), TurbulenceTypeConverter); _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency"), 0, 100, 1, 0.01, 1); _settings->add_spinslider(SP_ATTR_NUMOCTAVES, _("Octaves"), 1, 10, 1, 1, 0); _settings->add_spinslider(SP_ATTR_SEED, _("Seed"), 0, 1000, 1, 1, 0); @@ -1825,7 +2020,6 @@ void FilterEffectsDialog::add_primitive() if(filter) { SPFilterPrimitive* prim = filter_add_primitive(filter, _add_primitive_type.get_active_data()->id); - _primitive_list.update(); _primitive_list.select(prim); sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); @@ -1882,6 +2076,8 @@ void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input) void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val) { if(!_locked) { + _attr_lock = true; + SPFilter *filter = _filter_modifier.get_selected_filter(); const gchar* name = (const gchar*)sp_attribute_name(attr); if(filter && name && o) { @@ -1895,11 +2091,18 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons sp_document_maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, _("Set filter primitive attribute")); } + + _attr_lock = false; } } void FilterEffectsDialog::update_settings_view() { + update_settings_sensitivity(); + + if(_attr_lock) + return; + SPFilterPrimitive* prim = _primitive_list.get_selected(); if(prim) { @@ -1911,8 +2114,6 @@ void FilterEffectsDialog::update_settings_view() _settings_box.show(); _empty_settings.show(); } - - update_settings_sensitivity(); } void FilterEffectsDialog::update_settings_sensitivity() @@ -1923,6 +2124,18 @@ void FilterEffectsDialog::update_settings_sensitivity() _k2->set_sensitive(use_k); _k3->set_sensitive(use_k); _k4->set_sensitive(use_k); + + if(SP_IS_FECOMPONENTTRANSFER(prim)) { + SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(prim); + const bool linear = ct->type == COMPONENTTRANSFER_TYPE_LINEAR; + const bool gamma = ct->type == COMPONENTTRANSFER_TYPE_GAMMA; + //_ct_table->set_sensitive(ct->type == COMPONENTTRANSFER_TYPE_TABLE || ct->type == COMPONENTTRANSFER_TYPE_DISCRETE); + _ct_slope->set_sensitive(linear); + _ct_intercept->set_sensitive(linear); + _ct_amplitude->set_sensitive(gamma); + _ct_exponent->set_sensitive(gamma); + _ct_offset->set_sensitive(gamma); + } } void FilterEffectsDialog::update_color_matrix()