diff options
| author | Jabiertxof <jtx@jtx> | 2017-06-06 00:27:41 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-06-06 00:27:41 +0000 |
| commit | 6fecef42f41d5641cbadf34bc640e796635da7c5 (patch) | |
| tree | ea1b3ae0e98e83a489f4008bcebd99d787c18eaa | |
| parent | Show glyphs with alternative styles in "Feature Settings" section of "Variant... (diff) | |
| download | inkscape-6fecef42f41d5641cbadf34bc640e796635da7c5.tar.gz inkscape-6fecef42f41d5641cbadf34bc640e796635da7c5.zip | |
Add contextual buttons to Hide/lock and Unhide/unlock items
(bzr r15732)
| -rw-r--r-- | src/document.cpp | 8 | ||||
| -rw-r--r-- | src/document.h | 4 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 85 | ||||
| -rw-r--r-- | src/ui/interface.h | 4 | ||||
| -rw-r--r-- | src/ui/tools/measure-tool.cpp | 2 |
5 files changed, 95 insertions, 8 deletions
diff --git a/src/document.cpp b/src/document.cpp index 2141f65e9..3a7d4408f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1553,11 +1553,11 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin * Assumes box is normalized (and g_asserts it!) * */ -std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups) const +std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive, bool into_groups) const { std::vector<SPItem*> x; g_return_val_if_fail(this->priv != NULL, x); - return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within, false, into_groups); + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within, take_insensitive, into_groups); } /* @@ -1567,11 +1567,11 @@ std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect con * */ -std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups) const +std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive, bool into_groups) const { std::vector<SPItem*> x; g_return_val_if_fail(this->priv != NULL, x); - return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps, false, into_groups); + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps, take_insensitive, into_groups); } std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points, bool all_layers, size_t limit) const diff --git a/src/document.h b/src/document.h index db50f1717..92f53559f 100644 --- a/src/document.h +++ b/src/document.h @@ -282,8 +282,8 @@ public: bool addResource(char const *key, SPObject *object); bool removeResource(char const *key, SPObject *object); const std::vector<SPObject *> getResourceList(char const *key) const; - std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; - std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; + std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive = false, bool into_groups = false) const; + std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive = false, bool into_groups = false) const; SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; std::vector<SPItem*> getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points, bool all_layers = true, size_t limit = 0) const ; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 5e85065d1..33e98a81c 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1438,13 +1438,58 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE)); positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other + Geom::Rect b(_desktop->point(),_desktop->point() + Geom::Point(1,1)); + std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true); + bool has_down_hidden = false; + bool has_down_locked = false; + for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){ + if((*down)->isHidden()) { + has_down_hidden = true; + } + if((*down)->isLocked()) { + has_down_locked = true; + } + } + AddSeparator(); + Gtk::MenuItem* mi; + + mi = Gtk::manage(new Gtk::MenuItem(_("Hide selected objects"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::HideSelected)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + mi = Gtk::manage(new Gtk::MenuItem(_("Unhide objects below"),1)); + mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnHideBelow), down_items)); + if (!has_down_hidden) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + mi = Gtk::manage(new Gtk::MenuItem(_("Lock selected objects"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LockSelected)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + mi = Gtk::manage(new Gtk::MenuItem(_("Unlock objects below"),1)); + mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnLockBelow), down_items)); + if (!has_down_locked) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); /* Item menu */ if (item!=NULL) { AddSeparator(); MakeObjectMenu(); } - + AddSeparator(); /* layer menu */ SPGroup *group=NULL; if (item) { @@ -1507,6 +1552,44 @@ void ContextMenu::LeaveGroup(void) _desktop->setCurrentLayer(_desktop->currentLayer()->parent); } +void ContextMenu::LockSelected(void) +{ + auto itemlist = _desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { + (*i)->setLocked(true); + } +} + +void ContextMenu::HideSelected(void) +{ + auto itemlist =_desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { + (*i)->setHidden(true); + } +} + +void ContextMenu::UnLockBelow(std::vector<SPItem *> items) +{ + _desktop->selection->clear(); + for(auto i=items.begin();i!=items.end(); ++i) { + if ((*i)->isLocked()) { + (*i)->setLocked(false); + _desktop->selection->add(*i); + } + } +} + +void ContextMenu::UnHideBelow(std::vector<SPItem *> items) +{ + _desktop->selection->clear(); + for(auto i=items.begin();i!=items.end(); ++i) { + if ((*i)->isHidden()) { + (*i)->setHidden(false); + _desktop->selection->add(*i); + } + } +} + void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) { SPAction *action; diff --git a/src/ui/interface.h b/src/ui/interface.h index 52074f0f0..a41c36cc3 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -172,6 +172,10 @@ class ContextMenu : public Gtk::Menu void EnterGroup(Gtk::MenuItem* mi); void LeaveGroup(void); + void LockSelected(void); + void HideSelected(void); + void UnLockBelow(std::vector<SPItem *> items); + void UnHideBelow(std::vector<SPItem *> items); ////////////////////////////////////////// //callbacks for the context menu entries of an SP_TYPE_ITEM object void ItemProperties(void); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index f3185649b..98b2c7d03 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1260,7 +1260,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, std::vector<SPItem*> items; SPDocument *doc = desktop->getDocument(); Geom::Rect rect(start_p, end_p); - items = doc->getItemsPartiallyInBox(desktop->dkey, rect, true); + items = doc->getItemsPartiallyInBox(desktop->dkey, rect, false, true); Inkscape::LayerModel *layer_model = NULL; SPObject *current_layer = NULL; if(desktop){ |
