Code

Fixes for transient dialogs in win32.
[inkscape.git] / src / ui / dialog / filter-effects-dialog.h
index 3509e21ad63244d0d993ff508a7fa4e33235a24f..743ce02395784cb6ebbed8950366a7e6c6fdd18a 100644 (file)
@@ -16,8 +16,6 @@
 #include <gtkmm/alignment.h>
 #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>
@@ -29,8 +27,7 @@
 #include "attributes.h"
 #include "dialog.h"
 #include "sp-filter.h"
-#include "sp-feconvolvematrix.h"
-#include "ui/widget/filter-effect-chooser.h"
+#include "ui/widget/combo-enums.h"
 #include "ui/widget/spin-slider.h"
 
 using namespace Inkscape::UI::Widget;
@@ -39,26 +36,59 @@ namespace Inkscape {
 namespace UI {
 namespace Dialog {
 
+class DualSpinButton;
+class MultiSpinButton;
 class FilterEffectsDialog : public Dialog {
 public:
+
+    FilterEffectsDialog(Behavior::BehaviorFactory behavior_factory);
     ~FilterEffectsDialog();
 
-    static FilterEffectsDialog *create() { return new FilterEffectsDialog(); }
+    static FilterEffectsDialog *create(Behavior::BehaviorFactory behavior_factory)
+    { return new FilterEffectsDialog(behavior_factory); }
+
+    void set_attrs_locked(const bool);
 private:
-    class FilterModifier : public Gtk::VBox, public FilterEffectChooser
+    class SignalObserver;
+
+    class FilterModifier : public Gtk::VBox
     {
     public:
-        FilterModifier();
+        FilterModifier(FilterEffectsDialog&);
+        ~FilterModifier();
 
-        virtual SPFilter* get_selected_filter();
-        virtual void select_filter(const SPFilter*);
-        virtual Glib::SignalProxy0<void> signal_selection_changed();
+        SPFilter* get_selected_filter();
+        void select_filter(const SPFilter*);
+
+        sigc::signal<void>& signal_filter_changed()
+        {
+            return _signal_filter_changed;
+        }
     private:
+        class Columns : public Gtk::TreeModel::ColumnRecord
+        {
+        public:
+            Columns()
+            {
+                add(filter);
+                add(label);
+                add(sel);
+            }
+
+            Gtk::TreeModelColumn<SPFilter*> filter;
+            Gtk::TreeModelColumn<Glib::ustring> label;
+            Gtk::TreeModelColumn<int> sel;
+        };
+
         class CellRendererSel : public Gtk::CellRenderer
         {
         public:
             CellRendererSel();
-            Glib::PropertyProxy<int> property_sel();
+
+            Glib::PropertyProxy<int> property_sel()
+            {
+                return _sel.get_proxy();
+            }
         protected:
             virtual void get_size_vfunc(Gtk::Widget&, const Gdk::Rectangle*,
                                     int*, int*, int*, int*) const;
@@ -69,20 +99,38 @@ private:
             const int _size;
             Glib::Property<int> _sel;
         };
+
+        static void on_activate_desktop(Application*, SPDesktop*, FilterModifier*);
+        void on_document_replaced(SPDesktop*, SPDocument*)
+        {
+            update_filters();
+        }
+       
+        static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*);
         
-        static void on_inkscape_change_selection(Inkscape::Application *, Inkscape::Selection *,
-                                                 FilterModifier*);
+        void update_selection(Selection *);
+        void on_filter_selection_changed();
 
+        void update_filters();
+        void filter_list_button_press(GdkEventButton*);
         void filter_list_button_release(GdkEventButton*);
         void add_filter();
         void remove_filter();
         void duplicate_filter();
-        void filter_name_edited(const Glib::ustring& path, const Glib::ustring& text);
+        void rename_filter();
+
+        sigc::connection _doc_replaced;
+        sigc::connection _resource_changed;
 
+        FilterEffectsDialog& _dialog;
         Gtk::TreeView _list;
+        Glib::RefPtr<Gtk::ListStore> _model;
+        Columns _columns;
         CellRendererSel _cell_sel;
         Gtk::Button _add;
         Glib::RefPtr<Gtk::Menu> _menu;
+        sigc::signal<void> _signal_filter_changed;
+        std::auto_ptr<SignalObserver> _observer;
     };
 
     class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
@@ -107,7 +155,6 @@ private:
     public:
         CellRendererConnection();
         Glib::PropertyProxy<void*> property_primitive();
-        static int input_count(const SPFilterPrimitive* prim);
 
         static const int size = 24;
         
@@ -127,7 +174,7 @@ private:
     public:
         PrimitiveList(FilterEffectsDialog&);
 
-        Glib::SignalProxy0<void> signal_selection_changed();
+        sigc::signal<void>& signal_primitive_changed();
 
         void update();
         void set_menu(Glib::RefPtr<Gtk::Menu>);
@@ -147,11 +194,13 @@ private:
 
         bool do_connection_node(const Gtk::TreeIter& row, const int input, std::vector<Gdk::Point>& points,
                                 const int ix, const int iy);
-        const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const SPAttributeEnum attr);
+        const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const int attr, int& src_id);
         int find_index(const Gtk::TreeIter& target);
-        void draw_connection(const Gtk::TreeIter&, const SPAttributeEnum attr, const int text_start_x,
+        void draw_connection(const Gtk::TreeIter&, const int attr, const int text_start_x,
                              const int x1, const int y1, const int row_count);
         void sanitize_connections(const Gtk::TreeIter& prim_iter);
+        void on_primitive_selection_changed();
+        bool on_scroll_timeout();
 
         FilterEffectsDialog& _dialog;
         Glib::RefPtr<Gtk::ListStore> _model;
@@ -161,6 +210,10 @@ private:
         Glib::RefPtr<Pango::Layout> _vertical_layout;
         int _in_drag;
         SPFilterPrimitive* _drag_prim;
+        sigc::signal<void> _signal_primitive_changed;
+        sigc::connection _scroll_connection;
+        int _autoscroll;
+        std::auto_ptr<SignalObserver> _observer;
     };
 
     FilterEffectsDialog();
@@ -170,13 +223,14 @@ private:
     void add_primitive();
     void remove_primitive();
     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);
+    void set_attr_direct(const AttrWidget*);
+    void set_child_attr_direct(const AttrWidget*);
+    void set_attr(SPObject*, const SPAttributeEnum, const gchar* val);
     void update_settings_view();
     void update_settings_sensitivity();
+    void update_color_matrix();
 
     // Filter effect selection
     FilterModifier _filter_modifier;
@@ -192,11 +246,27 @@ private:
     Gtk::Label _empty_settings;
 
     class Settings;
-    class ConvolveMatrix;
+    class MatrixAttr;
+    class ColorMatrixValues;
+    class LightSourceControl;
     Settings* _settings;
+    Glib::RefPtr<Gtk::SizeGroup> _sizegroup;
+
+    // Color Matrix
+    ColorMatrixValues* _color_matrix_values;
+
+    // Convolve Matrix
+    MatrixAttr* _convolve_matrix;
+    DualSpinButton* _convolve_order;
+    MultiSpinButton* _convolve_target;
 
     // For controlling setting sensitivity
     Gtk::Widget* _k1, *_k2, *_k3, *_k4;
+    Gtk::Widget* _ct_table, *_ct_slope, *_ct_intercept, *_ct_amplitude, *_ct_exponent, *_ct_offset;
+
+    // To prevent unwanted signals
+    bool _locked;
+    bool _attr_lock;
 
     FilterEffectsDialog(FilterEffectsDialog const &d);
     FilterEffectsDialog& operator=(FilterEffectsDialog const &d);