diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-03-02 01:58:58 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-03-02 01:58:58 +0000 |
| commit | 972dd59aac4f42bfb77a95cc89cda88c78228527 (patch) | |
| tree | da98d21416f1222421e81be6005db0c14ce370a0 /src | |
| parent | various minor things (diff) | |
| download | inkscape-972dd59aac4f42bfb77a95cc89cda88c78228527.tar.gz inkscape-972dd59aac4f42bfb77a95cc89cda88c78228527.zip | |
Fix for 927074 : Simplify Path Effects dialog
(bzr r11037)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.cpp | 139 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.h | 122 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 116 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.h | 20 | ||||
| -rw-r--r-- | src/verbs.cpp | 2 |
6 files changed, 332 insertions, 69 deletions
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index f64db1c65..3f76114f7 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -56,6 +56,8 @@ ink_common_sources += \ ui/dialog/layer-properties.h \ ui/dialog/layers.cpp \ ui/dialog/layers.h \ + ui/dialog/livepatheffect-add.cpp \ + ui/dialog/livepatheffect-add.h \ ui/dialog/livepatheffect-editor.cpp \ ui/dialog/livepatheffect-editor.h \ ui/dialog/memory.cpp \ diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp new file mode 100644 index 000000000..d53c85e33 --- /dev/null +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -0,0 +1,139 @@ +/** + * @file + * Dialog for adding a live path effect. + * + * Author: + * + * Copyright (C) 2012 Authors + * Released under GNU GPL. Read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <glibmm/i18n.h> +#include <gtkmm/stock.h> + +#include "desktop.h" +#include "livepatheffect-add.h" +#include "live_effects/effect-enum.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +LivePathEffectAdd::LivePathEffectAdd() : + add_button(Gtk::Stock::ADD), + close_button(Gtk::Stock::CANCEL), + converter(Inkscape::LivePathEffect::LPETypeConverter), + applied(false) +{ + set_title(_("Add Path Effect")); + + /** + * Scrolled Window + */ + scrolled_window.add(effectlist_treeview); + scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + scrolled_window.set_shadow_type(Gtk::SHADOW_IN); + scrolled_window.set_size_request(250, 200); + + /** + * Effect Store and Tree + */ + effectlist_store = Gtk::ListStore::create(_columns); + effectlist_store->set_sort_column (_columns.name, Gtk::SORT_ASCENDING ); + + effectlist_treeview.set_model(effectlist_store); + effectlist_treeview.set_headers_visible(false); + effectlist_treeview.append_column("Name", _columns.name); + + /** + * Initialize Effect list + */ + for(int i = 0; i < static_cast<int>(converter._length); ++i) { + Gtk::TreeModel::Row row = *(effectlist_store->append()); + const Util::EnumData<LivePathEffect::EffectType>* data = &converter.data(i); + row[_columns.name] = _( converter.get_label(data->id).c_str() ); + row[_columns.data] = data; + + if (i == 0) { + Glib::RefPtr<Gtk::TreeSelection> select = effectlist_treeview.get_selection(); + select->select(row); + } + } + + /** + * Buttons + */ + close_button.set_use_stock(true); + close_button.set_flags(Gtk::CAN_DEFAULT); + add_button.set_use_underline(true); + add_button.set_flags(Gtk::CAN_DEFAULT); + + Gtk::VBox *mainVBox = get_vbox(); + mainVBox->pack_start(scrolled_window, true, true); + add_action_widget(close_button, Gtk::RESPONSE_CLOSE); + add_action_widget(add_button, Gtk::RESPONSE_APPLY); + + /** + * Signal handlers + */ + close_button.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectAdd::onClose)); + add_button.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectAdd::onAdd)); + signal_delete_event().connect( sigc::bind_return(sigc::hide(sigc::mem_fun(*this, &LivePathEffectAdd::onClose)), true ) ); + + add_button.grab_default(); + + show_all_children(); +} + +void LivePathEffectAdd::onAdd() +{ + applied = true; + onClose(); +} + +void LivePathEffectAdd::onClose() +{ + hide(); +} + +const Util::EnumData<LivePathEffect::EffectType>* +LivePathEffectAdd::getActiveData() +{ + Gtk::TreeModel::iterator iter = instance().effectlist_treeview.get_selection()->get_selected(); + if ( iter ) { + Gtk::TreeModel::Row row = *iter; + return row[instance()._columns.data]; + } + + return 0; +} + + +void LivePathEffectAdd::show(SPDesktop *desktop) +{ + LivePathEffectAdd &dial = instance(); + dial.applied=false; + dial.set_modal(true); + desktop->setWindowTransient (dial.gobj()); + dial.property_destroy_with_parent() = true; + dial.run(); +} + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h new file mode 100644 index 000000000..4fe1d41a6 --- /dev/null +++ b/src/ui/dialog/livepatheffect-add.h @@ -0,0 +1,122 @@ +/** + * @file + * Dialog for adding a live path effect. + * + * Author: + * + * Copyright (C) 2012 Authors + * Released under GNU GPL. Read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H +#define INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H + +#include <gtkmm/dialog.h> +#include <gtkmm/entry.h> +#include <gtkmm/label.h> +#include <gtkmm/table.h> +#include <gtkmm/liststore.h> +#include <gtkmm/treeview.h> +#include <gtkmm/scrolledwindow.h> +#include "ui/widget/combo-enums.h" +#include "live_effects/effect-enum.h" + +class SPDesktop; + +namespace Inkscape { +namespace UI { +namespace Dialog { + +/** + * A dialog widget to list the live path effects that can be added + * + */ +class LivePathEffectAdd : public Gtk::Dialog { +public: + LivePathEffectAdd(); + virtual ~LivePathEffectAdd() {} + + /** + * Show the dialog + */ + static void show(SPDesktop *desktop); + + /** + * Returns true is the "Add" button was pressed + */ + static bool isApplied() { + return instance().applied; + } + + /** + * Return the data associated with the currently selected item + */ + static const Util::EnumData<LivePathEffect::EffectType>* getActiveData(); + +protected: + /** + * Close button was clicked + */ + + void onClose(); + /** + * Add button was clicked + */ + void onAdd(); + +private: + + Gtk::TreeView effectlist_treeview; + Gtk::ScrolledWindow scrolled_window; + Gtk::Button add_button; + Gtk::Button close_button; + + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + ModelColumns() + { + add(name); + //add(desc); + add(data); + } + virtual ~ModelColumns() {} + + Gtk::TreeModelColumn<Glib::ustring> name; + /** + * TODO - Get detailed descriptions of each Effect to show in the dialog + */ + //Gtk::TreeModelColumn<Glib::ustring> desc; + Gtk::TreeModelColumn<const Util::EnumData<LivePathEffect::EffectType>*> data; + }; + + ModelColumns _columns; + Glib::RefPtr<Gtk::ListStore> effectlist_store; + const Util::EnumDataConverter<LivePathEffect::EffectType>& converter; + + bool applied; + + static LivePathEffectAdd &instance() { + static LivePathEffectAdd instance_; + return instance_; + } + LivePathEffectAdd(LivePathEffectAdd const &); // no copy + LivePathEffectAdd &operator=(LivePathEffectAdd const &); // no assign +}; + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index ecc7d4137..c662abe8f 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -42,7 +42,7 @@ #include "ui/widget/imagetoggler.h" #include "verbs.h" #include "xml/node.h" - +#include "livepatheffect-add.h" namespace Inkscape { class Application; @@ -68,24 +68,24 @@ static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint } -/*####################### +/* * LivePathEffectEditor + * + * TRANSLATORS: this dialog is accessible via menu Path - Path Effect Editor... + * */ LivePathEffectEditor::LivePathEffectEditor() : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), lpe_list_locked(false), - combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter), effectwidget(NULL), - explain_label("", Gtk::ALIGN_CENTER), - // TRANSLATORS: this dialog is accessible via menu Path - Path Effect Editor... - effectapplication_frame(_("Apply new effect")), - effectcontrol_frame(_("Current effect")), + status_label("", Gtk::ALIGN_CENTER), + effectcontrol_frame(""), effectlist_frame(_("Effect list")), + button_add(Gtk::Stock::ADD), + button_remove(Gtk::Stock::REMOVE), button_up(Gtk::Stock::GO_UP), button_down(Gtk::Stock::GO_DOWN), - button_apply(Gtk::Stock::ADD), - button_remove(Gtk::Stock::REMOVE), current_desktop(NULL), current_lpeitem(NULL) { @@ -94,45 +94,36 @@ LivePathEffectEditor::LivePathEffectEditor() //Add the TreeView, inside a ScrolledWindow, with the button underneath: scrolled_window.add(effectlist_view); - //Only show the scrollbars when they are necessary: scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - scrolled_window.set_size_request(0, 50); + scrolled_window.set_shadow_type(Gtk::SHADOW_IN); + scrolled_window.set_size_request(210, 70); effectapplication_hbox.set_spacing(4); effectcontrol_vbox.set_spacing(4); - effectlist_vbox.set_spacing(4); - - effectapplication_hbox.pack_start(combo_effecttype, true, true); - effectapplication_hbox.pack_start(button_apply, true, true); - effectapplication_frame.add(effectapplication_hbox); + effectlist_vbox.set_spacing(4); effectlist_vbox.pack_start(scrolled_window, Gtk::PACK_EXPAND_WIDGET); - effectlist_vbox.pack_end(toolbar, Gtk::PACK_SHRINK); - // effectlist_vbox.pack_end(button_hbox, Gtk::PACK_SHRINK); - effectlist_frame.add(effectlist_vbox); - - effectcontrol_vbox.pack_start(explain_label, true, true); + effectlist_vbox.pack_end(toolbar_hbox, Gtk::PACK_SHRINK); effectcontrol_frame.add(effectcontrol_vbox); - // button_hbox.pack_start(button_up, true, true); - // button_hbox.pack_start(button_down, true, true); - // button_hbox.pack_end(button_remove, true, true); - toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS); - // Add toolbar items to toolbar - toolbar.append(button_up); - toolbar.append(button_down); - toolbar.append(button_remove); - - - // Add toolbar - //add_toolbar(toolbar); - toolbar.show_all(); //Show the toolbar and all its child widgets. - + button_add.set_tooltip_text(_("Add path effect")); + button_remove.set_tooltip_text(_("Delete current path effect")); + button_up.set_tooltip_text(_("Raise the current path effect")); + button_down.set_tooltip_text(_("Lower the current path effect")); + + // Add toolbar items to toolbar + toolbar_hbox.set_layout (Gtk::BUTTONBOX_END); + toolbar_hbox.set_child_min_width( 16 ); + toolbar_hbox.add( button_add ); + toolbar_hbox.set_child_secondary( button_add , true); + toolbar_hbox.add( button_remove ); + toolbar_hbox.set_child_secondary( button_remove , true); + toolbar_hbox.add( button_up ); + toolbar_hbox.add( button_down ); //Create the Tree model: effectlist_store = Gtk::ListStore::create(columns); effectlist_view.set_model(effectlist_store); - effectlist_view.set_headers_visible(false); // Handle tree selections @@ -153,20 +144,19 @@ LivePathEffectEditor::LivePathEffectEditor() //Add the effect name column: effectlist_view.append_column("Effect", columns.col_name); - contents->pack_start(effectapplication_frame, false, false); - contents->pack_start(effectlist_frame, true, true); + contents->pack_start(effectlist_vbox, true, true); + contents->pack_start(status_label, false, false); contents->pack_start(effectcontrol_frame, false, false); + effectcontrol_frame.hide(); + // connect callback functions to buttons - button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply)); + button_add.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onAdd)); button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove)); - button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp)); button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown)); show_all_children(); - - //button_remove.hide(); } LivePathEffectEditor::~LivePathEffectEditor() @@ -192,13 +182,16 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectwidget = NULL; } - explain_label.set_markup("<b>" + effect.getName() + "</b>"); + effectcontrol_frame.set_label(effect.getName()); + effectwidget = effect.newWidget(); if (effectwidget) { effectcontrol_vbox.pack_start(*effectwidget, true, true); } button_remove.show(); + status_label.hide(); + effectcontrol_frame.show(); effectcontrol_vbox.show_all_children(); // fixme: add resizing of dialog } @@ -223,8 +216,10 @@ LivePathEffectEditor::showText(Glib::ustring const &str) effectwidget = NULL; } - explain_label.set_label(str); - //button_remove.hide(); + status_label.show(); + status_label.set_label(str); + + effectcontrol_frame.hide(); // fixme: do resizing of dialog ? } @@ -232,8 +227,8 @@ LivePathEffectEditor::showText(Glib::ustring const &str) void LivePathEffectEditor::set_sensitize_all(bool sensitive) { - combo_effecttype.set_sensitive(sensitive); - button_apply.set_sensitive(sensitive); + //combo_effecttype.set_sensitive(sensitive); + button_add.set_sensitive(sensitive); button_remove.set_sensitive(sensitive); effectlist_view.set_sensitive(sensitive); button_up.set_sensitive(sensitive); @@ -274,11 +269,13 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) showText(_("Unknown effect is applied")); } } else { - showText(_("No effect applied")); + showText(_("Click button to add an effect")); button_remove.set_sensitive(false); + button_up.set_sensitive(false); + button_down.set_sensitive(false); } } else { - showText(_("Item is not a path or shape")); + showText(_("Select a path or shape")); set_sensitize_all(false); } } else { @@ -286,7 +283,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) set_sensitize_all(false); } } else { - showText(_("Empty selection")); + showText(_("Select a path or shape")); set_sensitize_all(false); } } @@ -359,19 +356,27 @@ LivePathEffectEditor::setDesktop(SPDesktop *desktop) ########################################################################*/ // TODO: factor out the effect applying code which can be called from anywhere. (selection-chemistry.cpp also needs it) - void -LivePathEffectEditor::onApply() +LivePathEffectEditor::onAdd() { + using Inkscape::UI::Dialog::LivePathEffectAdd; + LivePathEffectAdd::show(current_desktop); + + if ( !LivePathEffectAdd::isApplied()) { + return; + } + + const Util::EnumData<LivePathEffect::EffectType>* data = LivePathEffectAdd::getActiveData(); + if (!data) { + return; + } + Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item && SP_IS_LPE_ITEM(item) ) { SPDocument *doc = current_desktop->doc(); - const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data(); - if (!data) return; - // If item is a SPRect, convert it to path first: if ( SP_IS_RECT(item) ) { sp_selected_path_to_curves(current_desktop, false); @@ -404,6 +409,7 @@ LivePathEffectEditor::onRemove() effect_list_reload(SP_LPE_ITEM(item)); } } + } void LivePathEffectEditor::onUp() diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index a2672da6d..9c749a812 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -21,6 +21,7 @@ #include <gtkmm/treeview.h> #include <gtkmm/scrolledwindow.h> #include <gtkmm/toolbar.h> +#include <gtkmm/buttonbox.h> class SPDesktop; @@ -61,9 +62,8 @@ private: void effect_list_reload(SPLPEItem *lpeitem); // callback methods for buttons on grids page. - void onApply(); + void onAdd(); void onRemove(); - void onUp(); void onDown(); @@ -85,11 +85,10 @@ private: bool lpe_list_locked; - Inkscape::UI::Widget::ComboBoxEnum<LivePathEffect::EffectType> combo_effecttype; + //Inkscape::UI::Widget::ComboBoxEnum<LivePathEffect::EffectType> combo_effecttype; Gtk::Widget * effectwidget; - Gtk::Label explain_label; - Gtk::Frame effectapplication_frame; + Gtk::Label status_label; Gtk::Frame effectcontrol_frame; Gtk::Frame effectlist_frame; Gtk::HBox effectapplication_hbox; @@ -103,16 +102,11 @@ private: void on_visibility_toggled( Glib::ustring const& str ); - Gtk::Toolbar toolbar; + Gtk::HButtonBox toolbar_hbox; + Gtk::ToolButton button_add; + Gtk::ToolButton button_remove; Gtk::ToolButton button_up; Gtk::ToolButton button_down; - Gtk::Button button_apply; - Gtk::ToolButton button_remove; - /*Gtk::HButtonBox button_hbox; - Gtk::Button button_up; - Gtk::Button button_down; - Gtk::Button button_apply; - Gtk::Button button_remove;*/ SPDesktop * current_desktop; diff --git a/src/verbs.cpp b/src/verbs.cpp index 3636ef654..0248999d1 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2644,7 +2644,7 @@ Verb *Verb::_base_verbs[] = { N_("Query information about extensions"), NULL), new DialogVerb(SP_VERB_DIALOG_LAYERS, "DialogLayers", N_("Layer_s..."), N_("View Layers"), INKSCAPE_ICON("dialog-layers")), - new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffect Editor..."), + new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffects ..."), N_("Manage, edit, and apply path effects"), NULL), new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter _Editor..."), N_("Manage, edit, and apply SVG filters"), NULL), |
