Code

add view mode toggle, store current mode for the session in prefs
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 3 Nov 2006 01:51:51 +0000 (01:51 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 3 Nov 2006 01:51:51 +0000 (01:51 +0000)
src/desktop.cpp
src/desktop.h
src/preferences-skeleton.h
src/verbs.cpp
src/verbs.h

index df13bed37361adcf4ad94adb223ac9494ff82da2..7b0c1f6fcb8f2f6d6e3d29f6aee27a86aab29df8 100644 (file)
@@ -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.
  */
index 948fd53bc304a4310a04402eb751001917045f42..708ca8fd5a3ae34caadad4226c1ef7a6a66721b4 100644 (file)
@@ -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;
index ec8ca44289d7e8d81844e303f698612431489c95..32614fc7b864a2e208d9022a888669fe30b4f102 100644 (file)
@@ -194,6 +194,8 @@ static char const preferences_skeleton[] =
 "    <group id=\"compassangledisplay\" value=\"0\"/>\n"
 "    <group id=\"maskobject\" topmost=\"1\" remove=\"1\"/>\n"
 "    <group id=\"blurquality\" value=\"0\"/>\n"
+"    <group id=\"startmode\" outline=\"0\"/>\n"
+"    <group id=\"outlinemode\" value=\"0\"/>\n"
 "    <group id=\"wireframecolors\" "
 "           onlight=\"255\"" // 000000ff
 "           ondark=\"4294967295\"" //ffffffff
index d741d5a8fca5b36eb93db8aa3cf3a446dd717803..58003bbdb21f12bdf60e5def174f238eb904c524 100644 (file)
@@ -1535,6 +1535,9 @@ ZoomVerb::perform(SPAction *action, void *data, void *pdata)
         case SP_VERB_VIEW_MODE_OUTLINE:
             dt->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"),
index 2055ac2eee82ae84e0b4fefbf7f302621c599d28..f20806c02364229ae1595f9f5ce315eedf82fd24 100644 (file)
@@ -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,