Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / ui / dialog / filter-effects-dialog.cpp
index 3a5c285208dcf024d0c56d538869c3d4adc38f88..d577a6cc427b787a64b8d24b114adf255f99f6d9 100644 (file)
@@ -209,17 +209,19 @@ template< typename T> class ComboWithTooltip : public Gtk::EventBox
 public:
     ComboWithTooltip<T>(T default_value, const Util::EnumDataConverter<T>& c, const SPAttributeEnum a = SP_ATTR_INVALID, char* tip_text = NULL)
     {
-        if (tip_text) _tt.set_tip(*this, tip_text);
+        if (tip_text) {
+            _tt.set_tip(*this, tip_text);
+        }
         combo = new ComboBoxEnum<T>(default_value, c, a);
         add(*combo);
         show_all();
     }
-    
+
     ~ComboWithTooltip()
     {
         delete combo;
     }
-    
+
     ComboBoxEnum<T>* get_attrwidget()
     {
         return combo;
@@ -315,7 +317,7 @@ public:
         }
         _s1.set_value(n.getNumber());
         _s2.set_value(n.getOptNumber());
-        
+
     }
 private:
     Gtk::SpinButton _s1, _s2;
@@ -609,7 +611,7 @@ public:
     {
         pack_start(_entry, false, false);
         pack_start(_fromFile, false, false);
-        //pack_start(_fromSVGElement, false, false);
+        pack_start(_fromSVGElement, false, false);
 
         _fromFile.set_label(_("Image File"));
         _fromFile.signal_clicked().connect(sigc::mem_fun(*this, &FileOrElementChooser::select_file));
@@ -869,7 +871,7 @@ public:
         std::vector<double> default_values;
         default_values.push_back(def1);
         default_values.push_back(def2);
-        
+
         std::vector<char*> tips;
         tips.push_back(tip1);
         tips.push_back(tip2);
@@ -1467,7 +1469,7 @@ int FilterEffectsDialog::PrimitiveList::init_text()
     _vertical_layout = Pango::Layout::create(context);
 
     int maxfont = 0;
-    for(int i = 0; i < FPInputConverter.end; ++i) {
+    for(unsigned int i = 0; i < FPInputConverter._length; ++i) {
         _vertical_layout->set_text(_(FPInputConverter.get_label((FilterPrimitiveInput)i).c_str()));
         int fontw, fonth;
         _vertical_layout->get_pixel_size(fontw, fonth);
@@ -1591,8 +1593,8 @@ bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose* e)
         int vis_x, vis_y;
         tree_to_widget_coords(vis.get_x(), vis.get_y(), vis_x, vis_y);
 
-        text_start_x = rct.get_x() + rct.get_width() - _connection_cell.get_text_width() * (FPInputConverter.end + 1) + 1;
-        for(int i = 0; i < FPInputConverter.end; ++i) {
+        text_start_x = rct.get_x() + rct.get_width() - _connection_cell.get_text_width() * (FPInputConverter._length + 1) + 1;
+        for(unsigned int i = 0; i < FPInputConverter._length; ++i) {
             _vertical_layout->set_text(_(FPInputConverter.get_label((FilterPrimitiveInput)i).c_str()));
             const int x = text_start_x + _connection_cell.get_text_width() * (i + 1);
             get_bin_window()->draw_rectangle(get_style()->get_bg_gc(Gtk::STATE_NORMAL), true, x, vis_y, _connection_cell.get_text_width(), vis.get_height());
@@ -1898,13 +1900,14 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
             Gdk::Rectangle rct;
             get_cell_area(path, *col, rct);
             const int twidth = _connection_cell.get_text_width();
-            const int sources_x = rct.get_width() - twidth * FPInputConverter.end;
+            const int sources_x = rct.get_width() - twidth * FPInputConverter._length;
             if(cx > sources_x) {
                 int src = (cx - sources_x) / twidth;
-                if(src < 0)
+                if (src < 0) {
                     src = 0;
-                else if(src >= FPInputConverter.end)
-                    src = FPInputConverter.end - 1;
+                } else if(src >= static_cast<int>(FPInputConverter._length)) {
+                    src = FPInputConverter._length - 1;
+                }
                 result = FPInputConverter.get_key((FilterPrimitiveInput)src);
                 in_val = result.c_str();
             }
@@ -1917,7 +1920,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
                         // Make sure the target has a result
                         const gchar *gres = repr->attribute("result");
                         if(!gres) {
-                            result = "result" + Glib::Ascii::dtostr(SP_FILTER(prim->parent)->_image_number_next);
+                            result = sp_filter_get_new_result_name(SP_FILTER(prim->parent));
                             repr->setAttribute("result", result.c_str());
                             in_val = result.c_str();
                         }
@@ -2086,15 +2089,15 @@ int FilterEffectsDialog::PrimitiveList::primitive_count() const
 
 FilterEffectsDialog::FilterEffectsDialog()
     : UI::Widget::Panel("", "dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS),
-      _filter_modifier(*this),
-      _primitive_list(*this),
       _add_primitive_type(FPConverter),
       _add_primitive(_("Add Effect:")),
       _empty_settings(_("No effect selected"), Gtk::ALIGN_LEFT),
       _no_filter_selected(_("No filter selected"), Gtk::ALIGN_LEFT),
       _settings_initialized(false),
       _locked(false),
-      _attr_lock(false)
+      _attr_lock(false),
+      _filter_modifier(*this),
+      _primitive_list(*this)
 {
     _settings = new Settings(*this, _settings_tab1, sigc::mem_fun(*this, &FilterEffectsDialog::set_attr_direct),
                              NR_FILTER_ENDPRIMITIVETYPE);
@@ -2116,15 +2119,16 @@ FilterEffectsDialog::FilterEffectsDialog()
     hpaned->pack1(_filter_modifier);
     hpaned->pack2(_primitive_box);
     _primitive_box.pack_start(*sw_prims);
-    _primitive_box.pack_start(*infobox,false, false);
     _primitive_box.pack_start(*hb_prims, false, false);
+    _primitive_box.pack_start(*infobox,false, false);
     sw_prims->add(_primitive_list);
     infobox->pack_start(_infobox_icon, false, false);
     infobox->pack_start(_infobox_desc, false, false);
     _infobox_desc.set_line_wrap(true);
+    _infobox_desc.set_size_request(200, -1);
 
-    hb_prims->pack_end(_add_primitive_type, false, false);
-    hb_prims->pack_end(_add_primitive, false, false);
+    hb_prims->pack_start(_add_primitive, false, false);
+    hb_prims->pack_start(_add_primitive_type, false, false);
     _getContents()->pack_start(_settings_tabs, false, false);
     _settings_tabs.append_page(_settings_tab1, _("Effect parameters"));
     _settings_tabs.append_page(_settings_tab2, _("Filter General Settings"));
@@ -2177,7 +2181,7 @@ void FilterEffectsDialog::init_settings_widgets()
 
     _empty_settings.set_sensitive(false);
     _settings_tab1.pack_start(_empty_settings);
-    
+
     _no_filter_selected.set_sensitive(false);
     _settings_tab2.pack_start(_no_filter_selected);
     _settings_initialized = true;
@@ -2196,6 +2200,7 @@ void FilterEffectsDialog::init_settings_widgets()
 
     _settings->type(NR_FILTER_COMPONENTTRANSFER);
     _settings->add_notimplemented();
+    //TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html
     /*_settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, 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);
@@ -2211,8 +2216,9 @@ void FilterEffectsDialog::init_settings_widgets()
     _k4 = _settings->add_spinslider(0, SP_ATTR_K4, _("K4"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
 
     _settings->type(NR_FILTER_CONVOLVEMATRIX);
-    _convolve_order = _settings->add_dualspinbutton("3", SP_ATTR_ORDER, _("Size"), 1, 5, 1, 1, 0, _("width of the convolve matrix"), _("height of the convolve matrix"));
+    _convolve_order = _settings->add_dualspinbutton((char*)"3", SP_ATTR_ORDER, _("Size"), 1, 5, 1, 1, 0, _("width of the convolve matrix"), _("height of the convolve matrix"));
     _convolve_target = _settings->add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, SP_ATTR_TARGETX, SP_ATTR_TARGETY, _("Target"), 0, 4, 1, 1, 0, _("X coordinate of the target point in the convolve matrix. The convolution is applied to pixels around this point."), _("Y coordinate of the target point in the convolve matrix. The convolution is applied to pixels around this point."));
+    //TRANSLATORS: for info on "Kernel", see http://en.wikipedia.org/wiki/Kernel_(matrix)
     _convolve_matrix = _settings->add_matrix(SP_ATTR_KERNELMATRIX, _("Kernel"), _("This matrix describes the convolve operation that is applied to the input image in order to calculate the pixel colors at the output. Different arrangements of values in this matrix result in various possible visual effects. An identity matrix would lead to a motion blur effect (parallel to the matrix diagonal) while a matrix filled with a constant non-zero value would lead to a common blur effect."));
     _convolve_order->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed));
     //TODO: svg spec: The default value is the sum of all values in kernelMatrix, with the exception that if the sum is zero, then the divisor is set to 1.
@@ -2479,7 +2485,7 @@ void FilterEffectsDialog::update_settings_view()
         _infobox_icon.hide();
         _infobox_desc.hide();
     }
-    
+
     SPFilterPrimitive* prim = _primitive_list.get_selected();
 
     if(prim) {