summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-09-14 09:55:45 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-09-19 21:05:29 +0000
commita0d02c911c226677e833ede6c76825b2c12a3897 (patch)
tree858f12d87f4889bea17d86fc3f4ec9ef368be1e4
parentFix partialy issue 425 (the highlight part not new line one) https://gitlab.c... (diff)
downloadinkscape-a0d02c911c226677e833ede6c76825b2c12a3897.tar.gz
inkscape-a0d02c911c226677e833ede6c76825b2c12a3897.zip
Fix issue in toggle menu items like display mode and color mode. Partialy fix https://gitlab.com/inkscape/inkscape/issues/157
-rw-r--r--src/desktop.cpp42
-rw-r--r--src/desktop.h22
-rw-r--r--src/ui/desktop/menubar.cpp33
3 files changed, 76 insertions, 21 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 363fd31ec..777d34f03 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -531,7 +531,7 @@ void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) {
r, g, b, 0, 0,
r, g, b, 0, 0,
0, 0, 0, 1, 0 };
- g_message("%g",grayscale_value_matrix[0]);
+ // g_message("%g",grayscale_value_matrix[0]);
SP_CANVAS_ARENA (drawing)->drawing.setGrayscaleMatrix(grayscale_value_matrix);
}
@@ -542,39 +542,72 @@ void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) {
_widget->setTitle( this->getDocument()->getDocumentName() );
}
-void SPDesktop::displayModeToggle() {
+bool SPDesktop::displayModeToggle() {
+ Inkscape::Verb *verb = Inkscape::Verb::get(SP_VERB_VIEW_MODE_NORMAL);
switch (_display_mode) {
case Inkscape::RENDERMODE_NORMAL:
_setDisplayMode(Inkscape::RENDERMODE_NO_FILTERS);
+ verb = Inkscape::Verb::get(SP_VERB_VIEW_MODE_NO_FILTERS);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayModeNoFilters());
+ }
break;
case Inkscape::RENDERMODE_NO_FILTERS:
_setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
+ verb = Inkscape::Verb::get(SP_VERB_VIEW_MODE_OUTLINE);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayModeOutline());
+ }
+
break;
case Inkscape::RENDERMODE_OUTLINE:
_setDisplayMode(Inkscape::RENDERMODE_VISIBLE_HAIRLINES);
+ verb = Inkscape::Verb::get(SP_VERB_VIEW_MODE_VISIBLE_HAIRLINES);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayModeVisibleHairlines());
+ }
break;
case Inkscape::RENDERMODE_VISIBLE_HAIRLINES:
_setDisplayMode(Inkscape::RENDERMODE_NORMAL);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayModeNormal());
+ }
break;
default:
_setDisplayMode(Inkscape::RENDERMODE_NORMAL);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayModeNormal());
+ }
}
if (_display_mode == Inkscape::RENDERMODE_OUTLINE) {
_split_canvas = false;
}
+ return true;
}
-void SPDesktop::displayColorModeToggle() {
+bool SPDesktop::displayColorModeToggle() {
+ Inkscape::Verb *verb = Inkscape::Verb::get(SP_VERB_VIEW_COLOR_MODE_NORMAL);
switch (_display_color_mode) {
case Inkscape::COLORMODE_NORMAL:
_setDisplayColorMode(Inkscape::COLORMODE_GRAYSCALE);
+ verb = Inkscape::Verb::get(SP_VERB_VIEW_COLOR_MODE_GRAYSCALE);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayColorModeGrayscale());
+ }
break;
case Inkscape::COLORMODE_GRAYSCALE:
_setDisplayColorMode(Inkscape::COLORMODE_NORMAL);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayColorModeNormal());
+ }
break;
// case Inkscape::COLORMODE_PRINT_COLORS_PREVIEW:
default:
_setDisplayColorMode(Inkscape::COLORMODE_NORMAL);
+ if (verb) {
+ _menu_update.emit(verb->get_code(), setDisplayColorModeNormal());
+ }
}
+ return true;
}
// Pass-through LayerModel functions
@@ -1192,6 +1225,7 @@ SPDesktop::flip_relative_keep_point (Geom::Point const &c, CanvasFlip flip)
Geom::Point w = d2w( c ); // Must be before flip.
_current_affine.addFlip( flip );
set_display_area( c, w );
+ return true;
}
@@ -1204,6 +1238,7 @@ SPDesktop::flip_absolute_center_point (Geom::Point const &c, CanvasFlip flip)
_current_affine.setFlip( flip );
Geom::Rect viewbox = canvas->getViewbox();
set_display_area( c, viewbox.midpoint() );
+ return true;
}
@@ -1213,6 +1248,7 @@ SPDesktop::flip_relative_center_point (Geom::Point const &c, CanvasFlip flip)
_current_affine.addFlip( flip );
Geom::Rect viewbox = canvas->getViewbox();
set_display_area( c, viewbox.midpoint() );
+ return true;
}
diff --git a/src/desktop.h b/src/desktop.h
index 735e85682..a84ceec3c 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -267,33 +267,39 @@ public:
void redrawDesktop();
void _setDisplayMode(Inkscape::RenderMode mode);
- void setDisplayModeNormal() {
+ bool setDisplayModeNormal() {
_setDisplayMode(Inkscape::RENDERMODE_NORMAL);
+ return true;
}
- void setDisplayModeNoFilters() {
+ bool setDisplayModeNoFilters() {
_setDisplayMode(Inkscape::RENDERMODE_NO_FILTERS);
+ return true;
}
- void setDisplayModeOutline() {
+ bool setDisplayModeOutline() {
_setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
+ return true;
}
- void setDisplayModeVisibleHairlines() {
+ bool setDisplayModeVisibleHairlines() {
_setDisplayMode(Inkscape::RENDERMODE_VISIBLE_HAIRLINES);
+ return true;
}
- void displayModeToggle();
+ bool displayModeToggle();
Inkscape::RenderMode _display_mode;
Inkscape::RenderMode getMode() const { return _display_mode; }
void _setDisplayColorMode(Inkscape::ColorMode mode);
- void setDisplayColorModeNormal() {
+ bool setDisplayColorModeNormal() {
_setDisplayColorMode(Inkscape::COLORMODE_NORMAL);
+ return true;
}
- void setDisplayColorModeGrayscale() {
+ bool setDisplayColorModeGrayscale() {
_setDisplayColorMode(Inkscape::COLORMODE_GRAYSCALE);
+ return true;
}
// void setDisplayColorModePrintColorsPreview() {
// _setDisplayColorMode(Inkscape::COLORMODE_PRINT_COLORS_PREVIEW);
// }
- void displayColorModeToggle();
+ bool displayColorModeToggle();
Inkscape::ColorMode _display_color_mode;
Inkscape::ColorMode getColorMode() const { return _display_color_mode; }
diff --git a/src/ui/desktop/menubar.cpp b/src/ui/desktop/menubar.cpp
index 8852f344b..75c2198bd 100644
--- a/src/ui/desktop/menubar.cpp
+++ b/src/ui/desktop/menubar.cpp
@@ -42,6 +42,7 @@
// ================= Common ====================
std::vector<std::pair<std::pair<unsigned int, Gtk::CheckMenuItem *>, Inkscape::UI::View::View *>> checkmenuitems;
+std::vector<std::pair<std::pair<unsigned int, Gtk::RadioMenuItem *>, Inkscape::UI::View::View *>> radiomenuitems;
unsigned int lastverb = -1;
;
@@ -88,6 +89,23 @@ static void toggle_checkmenu(unsigned int emitting_verb, bool value)
}
}
+static void toggle_radiomenu(unsigned int emitting_verb, bool value)
+{
+ for (auto menu : radiomenuitems) {
+ if (menu.second == SP_ACTIVE_DESKTOP) {
+ if (emitting_verb == menu.first.first) {
+ if (emitting_verb == lastverb) {
+ lastverb = -1;
+ return;
+ }
+ lastverb = emitting_verb;
+ menu.first.second->property_active() = value;
+ lastverb = -1;
+ }
+ }
+ }
+}
+
// Change label name (used in the Undo/Redo menu items).
static void
set_name(Glib::ustring const &name, Gtk::MenuItem* menuitem)
@@ -168,7 +186,6 @@ build_menu_item_from_verb(SPAction* action,
} else {
menuitem->add(*label);
}
-
menuitem->signal_activate().connect(
sigc::bind<Gtk::MenuItem*, SPAction*>(sigc::ptr_fun(&item_activate), menuitem, action));
menuitem->signal_select().connect( sigc::bind<SPAction*>(sigc::ptr_fun(&select_action), action));
@@ -461,20 +478,15 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V
} else if (menu_ptr->attribute("radio") != nullptr) {
- Gtk::MenuItem* menuitem = build_menu_item_from_verb(action, show_icons_curr, true, &group);
+ Gtk::RadioMenuItem* menuitem = dynamic_cast<Gtk::RadioMenuItem *>(build_menu_item_from_verb(action, show_icons_curr, true, &group));
if (menuitem) {
- // TODO: if necesary update a radio in the future we can follow the previus checkbutton
- if (menu_ptr->attribute("default") != nullptr) {
- auto radiomenuitem = dynamic_cast<Gtk::RadioMenuItem*>(menuitem);
- if (radiomenuitem) {
- radiomenuitem->set_active(true);
- }
- }
+ std::pair<std::pair<unsigned int, Gtk::RadioMenuItem *>, Inkscape::UI::View::View *>
+ checkitem = std::make_pair(std::make_pair(verb->get_code(), menuitem), view);
+ checkmenuitems.push_back(checkitem);
menu->append(*menuitem);
}
} else {
-
Gtk::MenuItem* menuitem = build_menu_item_from_verb(action, show_icons_curr);
if (menuitem) {
menu->append(*menuitem);
@@ -540,6 +552,7 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V
}
}
SP_ACTIVE_DESKTOP->_menu_update.connect(sigc::ptr_fun(&toggle_checkmenu));
+ SP_ACTIVE_DESKTOP->_menu_update.connect(sigc::ptr_fun(&toggle_radiomenu));
}
Gtk::MenuBar*