From: buliabyak Date: Fri, 3 Nov 2006 01:51:51 +0000 (+0000) Subject: add view mode toggle, store current mode for the session in prefs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4927ecf824d76f1c2f570c8296d59f24f9a6d5b5;p=inkscape.git add view mode toggle, store current mode for the session in prefs --- diff --git a/src/desktop.cpp b/src/desktop.cpp index df13bed37..7b0c1f6fc 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -190,12 +190,10 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) if (prefs_get_int_attribute("options.startmode", "outline", 0)) { // Start in outline mode - SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_OUTLINE; - canvas->rendermode = RENDERMODE_OUTLINE; // canvas needs that for choosing the best buffer size + setDisplayModeOutline(); } else { // Start in normal mode, default - SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_NORMAL; - canvas->rendermode = RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size + setDisplayModeNormal(); } grid = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL); @@ -347,6 +345,7 @@ SPDesktop::~SPDesktop() {} void SPDesktop::setDisplayModeNormal() { + prefs_set_int_attribute("options.outlinemode", "value", 0); SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_NORMAL; canvas->rendermode = RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw @@ -354,11 +353,20 @@ void SPDesktop::setDisplayModeNormal() void SPDesktop::setDisplayModeOutline() { + prefs_set_int_attribute("options.outlinemode", "value", 1); SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_OUTLINE; canvas->rendermode = RENDERMODE_OUTLINE; // canvas needs that for choosing the best buffer size sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw } +void SPDesktop::displayModeToggle() +{ + if (prefs_get_int_attribute("options.outlinemode", "value", prefs_get_int_attribute("options.startmode", "outline", 0))) + setDisplayModeNormal(); + else + setDisplayModeOutline(); +} + /** * Returns current root (=bottom) layer. */ diff --git a/src/desktop.h b/src/desktop.h index 948fd53bc..708ca8fd5 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -161,6 +161,7 @@ struct SPDesktop : public Inkscape::UI::View::View void setDisplayModeNormal(); void setDisplayModeOutline(); + void displayModeToggle(); void set_active (bool new_active); SPObject *currentRoot() const; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index ec8ca4428..32614fc7b 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -194,6 +194,8 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" " setDisplayModeOutline(); break; + case SP_VERB_VIEW_MODE_TOGGLE: + dt->displayModeToggle(); + break; case SP_VERB_VIEW_ICON_PREVIEW: show_panel( Inkscape::UI::Dialogs::IconPreviewPanel::getInstance(), "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW ); break; @@ -2255,6 +2258,8 @@ Verb *Verb::_base_verbs[] = { N_("Switch to normal display mode"), NULL), new ZoomVerb(SP_VERB_VIEW_MODE_OUTLINE, "ViewModeOutline", N_("_Outline"), N_("Switch to outline (wireframe) display mode"), NULL), + new ZoomVerb(SP_VERB_VIEW_MODE_TOGGLE, "ViewModeToggle", N_("Toggle Display Mode"), + N_("Toggle between normal and outline display modes"), NULL), new ZoomVerb(SP_VERB_VIEW_ICON_PREVIEW, "ViewIconPreview", N_("Ico_n Preview..."), N_("Open a window to preview objects at different icon resolutions"), "view_icon_preview"), diff --git a/src/verbs.h b/src/verbs.h index 2055ac2ee..f20806c02 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -179,6 +179,7 @@ enum { SP_VERB_VIEW_NEW_PREVIEW, SP_VERB_VIEW_MODE_NORMAL, SP_VERB_VIEW_MODE_OUTLINE, + SP_VERB_VIEW_MODE_TOGGLE, SP_VERB_VIEW_ICON_PREVIEW, SP_VERB_ZOOM_PAGE, SP_VERB_ZOOM_PAGE_WIDTH,