diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-04 02:32:34 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-04 02:32:34 +0000 |
| commit | fc3d193cc08668ac4aa99343e6dc386c74f2912e (patch) | |
| tree | 09f5a6e553e0ed680fc3d4c733ae7c648a947bfd /src | |
| parent | Merge branch 'master' into powerMaskImprovements (diff) | |
| parent | Merge branch 'master' into menuInverseClipMask (diff) | |
| download | inkscape-fc3d193cc08668ac4aa99343e6dc386c74f2912e.tar.gz inkscape-fc3d193cc08668ac4aa99343e6dc386c74f2912e.zip | |
Merge branch 'master' into powerMaskImprovements
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-powerclip.cpp | 19 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerclip.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-powermask.cpp | 18 | ||||
| -rw-r--r-- | src/live_effects/lpe-powermask.h | 3 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 34 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.h | 3 | ||||
| -rw-r--r-- | src/verbs.cpp | 15 | ||||
| -rw-r--r-- | src/verbs.h | 2 |
8 files changed, 90 insertions, 6 deletions
diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 40a9cdbfb..18276270d 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -395,6 +395,25 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i); + if (lpeitem) { + Effect::createAndApply(POWERCLIP, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("is_inverse", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("inverse", "true"); + lpe->getRepr()->setAttribute("flatten", "false"); + lpe->getRepr()->setAttribute("hide_clip", "false"); + dynamic_cast<LPEPowerClip *>(lpe)->convertShapes(); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 38485b798..6f99d220f 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -38,6 +38,8 @@ private: bool convert_shapes; }; +void sp_inverse_powerclip(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape #endif diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 0d48b1b77..883467b6a 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -303,6 +303,24 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } +void sp_inverse_powermask(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i); + if (lpeitem) { + Effect::createAndApply(POWERMASK, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("invert", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("hide_mask", "false"); + lpe->getRepr()->setAttribute("background", "true"); + lpe->getRepr()->setAttribute("background_color", "#ffffffff"); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index eb2640867..e81b34fe3 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -36,6 +36,9 @@ private: guint32 previous_color; }; +void sp_inverse_powermask(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape + #endif diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 2380ba56f..727fdf4f2 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -108,13 +108,14 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : preview_document(0), instanceConns() { - /******************** Table *************************/ - table = new Gtk::Grid(); + + /******************** Table *************************/ + auto table = new Gtk::Grid(); table->set_margin_left(3); table->set_margin_right(3); table->set_margin_top(4); // panel is a cloked Gtk::VBox - _getContents()->pack_start(* Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; /******************** Symbol Sets *************************/ @@ -125,6 +126,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : symbol_set->append(_("All symbols sets")); symbol_set->set_active_text(_("Current Document")); symbol_set->set_hexpand(); + table->attach(*Gtk::manage(symbol_set),1,row,1,1); sigc::connection connSet = symbol_set->signal_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::rebuild)); @@ -187,13 +189,16 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : scroller->add(*Gtk::manage(icon_view)); scroller->set_hexpand(); scroller->set_vexpand(); +#if GTK_CHECK_VERSION(3,2,4) overlay = new Gtk::Overlay(); overlay->set_hexpand(); overlay->set_vexpand(); overlay->add(* scroller); scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); - +#else + table->attach(*Gtk::manage(scroller),0,row,2,1); +#endif ++row; /******************** Progress *******************************/ @@ -319,6 +324,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : SPDefs *defs = current_document->getDefs(); /*************************Overlays******************************/ +#if GTK_CHECK_VERSION(3,2,4) //Loading overlay_opacity = new Gtk::Image(); overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); @@ -348,7 +354,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->add_overlay(* overlay_icon); overlay->add_overlay(* overlay_title); overlay->add_overlay(* overlay_desc); - +#endif sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); @@ -369,7 +375,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); desk_track.connect(GTK_WIDGET(gobj())); +#if GTK_CHECK_VERSION(3,2,4) overlay->hide(); +#endif } SymbolsDialog::~SymbolsDialog() @@ -930,6 +938,7 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); +#if GTK_CHECK_VERSION(3,2,4) if (current == _("All symbols sets") && search->get_text() != _("Loading documents...")) { @@ -954,17 +963,22 @@ bool SymbolsDialog::callbackSymbols(){ overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); } } +#endif if (current == _("All symbols sets") && search->get_text() == _("Loading documents...") ) { +#if GTK_CHECK_VERSION(3,2,4) overlay_opacity->show(); +#endif if (!all_docs_processed) { +#if GTK_CHECK_VERSION(3,2,4) overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("</span>")); overlay_icon->show(); overlay_title->show(); overlay_icon->set_from_icon_name("searching", iconsize); overlay_desc->show(); +#endif } size_t counter = 0; for(auto const &symbol_document_map : symbol_sets) { @@ -981,19 +995,23 @@ bool SymbolsDialog::callbackSymbols(){ progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); return true; } +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->hide(); overlay_title->hide(); overlay_desc->hide(); +#endif progress_bar->set_fraction(1.0); all_docs_processed = true; addSymbols(); search->set_text("Documents done, searchig inside..."); return true; } else if (l.size()) { +#if GTK_CHECK_VERSION(3,2,4) overlay_opacity->show(); overlay_icon->hide(); overlay_title->hide(); overlay_desc->hide(); +#endif for (auto symbol_data = l.begin(); symbol_data != l.end();) { Glib::ustring doc_title = symbol_data->first; SPSymbol * symbol = symbol_data->second; @@ -1028,6 +1046,7 @@ bool SymbolsDialog::callbackSymbols(){ return true; } } +#if GTK_CHECK_VERSION(3,2,4) if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); @@ -1038,6 +1057,7 @@ bool SymbolsDialog::callbackSymbols(){ } else { overlay_opacity->hide(); } +#endif sensitive = false; search->set_text(search_str); sensitive = true; @@ -1067,12 +1087,14 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { l = container_symbols_tmp; container_symbols_tmp.clear(); if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); overlay_title->show(); overlay_desc->show(); +#endif sensitive = false; search->set_text(search_str); sensitive = true; @@ -1100,12 +1122,14 @@ void SymbolsDialog::addSymbols() { l = container_symbols; container_symbols.clear(); if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); +#endif sensitive = false; search->set_text(search_str); sensitive = true; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 13ba9caf9..ebd56d5e0 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -128,12 +128,13 @@ private: Gtk::Button* more; Gtk::Button* fewer; Gtk::HBox* tools; +#if GTK_CHECK_VERSION(3,2,4) Gtk::Overlay* overlay; +#endif Gtk::Image* overlay_icon; Gtk::Image* overlay_opacity; Gtk::Label* overlay_title; Gtk::Label* overlay_desc; - Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; Gtk::IconSize iconsize; diff --git a/src/verbs.cpp b/src/verbs.cpp index c1c108415..d0975af16 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -85,6 +85,9 @@ #include "ui/icon-names.h" #include "ui/tools/node-tool.h" #include "ui/dialog/save-template-dialog.h" +#include "live_effects/effect.h" +#include "live_effects/lpe-powerclip.h" +#include "live_effects/lpe-powermask.h" using Inkscape::DocumentUndo; using Inkscape::UI::Dialog::ActionAlign; @@ -1592,6 +1595,10 @@ void ObjectVerb::perform( SPAction *action, void *data) case SP_VERB_OBJECT_SET_MASK: sel->setMask(false, false); break; + case SP_VERB_OBJECT_SET_INVERSE_MASK: + sel->setMask(false, false); + Inkscape::LivePathEffect::sp_inverse_powermask(sp_action_get_selection(action)); + break; case SP_VERB_OBJECT_EDIT_MASK: sel->editMask(false); break; @@ -1601,6 +1608,10 @@ void ObjectVerb::perform( SPAction *action, void *data) case SP_VERB_OBJECT_SET_CLIPPATH: sel->setMask(true, false); break; + case SP_VERB_OBJECT_SET_INVERSE_CLIPPATH: + sel->setMask(true, false); + Inkscape::LivePathEffect::sp_inverse_powerclip(sp_action_get_selection(action)); + break; case SP_VERB_OBJECT_CREATE_CLIP_GROUP: sel->setClipGroup(); break; @@ -2873,12 +2884,16 @@ Verb *Verb::_base_verbs[] = { INKSCAPE_ICON("object-flip-vertical")), new ObjectVerb(SP_VERB_OBJECT_SET_MASK, "ObjectSetMask", N_("_Set"), N_("Apply mask to selection (using the topmost object as mask)"), NULL), + new ObjectVerb(SP_VERB_OBJECT_SET_INVERSE_MASK, "ObjectSetInverseMask", N_("_Set Inverse (LPE)"), + N_("Apply inverse mask to selection (using the topmost object as mask)"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_MASK, "ObjectEditMask", N_("_Edit"), N_("Edit mask"), INKSCAPE_ICON("path-mask-edit")), new ObjectVerb(SP_VERB_OBJECT_UNSET_MASK, "ObjectUnSetMask", N_("_Release"), N_("Remove mask from selection"), NULL), new ObjectVerb(SP_VERB_OBJECT_SET_CLIPPATH, "ObjectSetClipPath", N_("_Set"), N_("Apply clipping path to selection (using the topmost object as clipping path)"), NULL), + new ObjectVerb(SP_VERB_OBJECT_SET_INVERSE_CLIPPATH, "ObjectSetInverseClipPath", N_("_Set Inverse (LPE)"), + N_("Apply inverse clipping path to selection (using the topmost object as clipping path)"), NULL), new ObjectVerb(SP_VERB_OBJECT_CREATE_CLIP_GROUP, "ObjectCreateClipGroup", N_("Create Cl_ip Group"), N_("Creates a clip group using the selected objects as a base"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_CLIPPATH, "ObjectEditClipPath", N_("_Edit"), diff --git a/src/verbs.h b/src/verbs.h index 7df2d1399..611a8131c 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -192,9 +192,11 @@ enum { SP_VERB_OBJECT_FLIP_HORIZONTAL, SP_VERB_OBJECT_FLIP_VERTICAL, SP_VERB_OBJECT_SET_MASK, + SP_VERB_OBJECT_SET_INVERSE_MASK, SP_VERB_OBJECT_EDIT_MASK, SP_VERB_OBJECT_UNSET_MASK, SP_VERB_OBJECT_SET_CLIPPATH, + SP_VERB_OBJECT_SET_INVERSE_CLIPPATH, SP_VERB_OBJECT_CREATE_CLIP_GROUP, SP_VERB_OBJECT_EDIT_CLIPPATH, SP_VERB_OBJECT_UNSET_CLIPPATH, |
