changeset 23270:79122fab82ee

Restore all figure settings after clf ("reset") (bug #50527). * scripts/plot/util/private/__set_default_mouse_modes__.m: New script extracted from figure.m * scripts/plot/util/module.mk: Add script to build system. * figure.m: Remove local function __add_default_mouse_modes__ and call __set_default_mouse_modes__ instead. * clf.m: When doing a full reset, call __add_default_menu__ and __set_default_mouse_modes__ to restore these settings.
author Rik <rik@octave.org>
date Sun, 12 Mar 2017 19:12:27 -0700
parents a921b6b772f3
children cc9dcadcef6b
files scripts/plot/util/clf.m scripts/plot/util/figure.m scripts/plot/util/module.mk scripts/plot/util/private/__set_default_mouse_modes__.m
diffstat 4 files changed, 44 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/clf.m	Sun Mar 12 21:32:14 2017 +0100
+++ b/scripts/plot/util/clf.m	Sun Mar 12 19:12:27 2017 -0700
@@ -73,6 +73,8 @@
     ## Select all the children, including the one with hidden handles.
     delete (allchild (hfig));
     reset (hfig);
+    __add_default_menu__ (hfig);
+    __set_default_mouse_modes__ (hfig);
   else
     ## Select only the chilren with visible handles.
     delete (get (hfig, "children"));
--- a/scripts/plot/util/figure.m	Sun Mar 12 21:32:14 2017 +0100
+++ b/scripts/plot/util/figure.m	Sun Mar 12 19:12:27 2017 -0700
@@ -85,14 +85,14 @@
   if (init_new_figure)
     f = __go_figure__ (f, varargin{:});
     __add_default_menu__ (f);
-    __add_default_mouse_modes__ (f);
+    __set_default_mouse_modes__ (f);
   elseif (nargs > 0)
     set (f, varargin{:});
   endif
 
   set (0, "currentfigure", f);
   ## When switching to figure N, make figure visible and on top of stack,
-  ## unless visibility is explicitly switched off
+  ## unless visibility is explicitly switched off.
   if (! init_new_figure && ! any (strcmpi (varargin(1:2:end), "visible")
                                   && strcmpi (varargin(2:2:end), "off")))
     set (f, "visible", "on");
@@ -104,23 +104,6 @@
 
 endfunction
 
-function __add_default_mouse_modes__ (fig)
-
-  set (fig, "__pan_mode__", struct ("Enable", "off",
-                                    "Motion", "both",
-                                    "FigureHandle", fig));
-
-  set (fig, "__rotate_mode__", struct ("Enable", "off",
-                                       "RotateStyle", "box",
-                                       "FigureHandle", fig));
-
-  set (fig, "__zoom_mode__", struct ("Enable", "off",
-                                     "Motion", "both",
-                                     "Direction", "in",
-                                     "FigureHandle", fig));
-
-endfunction
-
 
 %!test
 %! hf = figure ("visible", "off");
--- a/scripts/plot/util/module.mk	Sun Mar 12 21:32:14 2017 +0100
+++ b/scripts/plot/util/module.mk	Sun Mar 12 19:12:27 2017 -0700
@@ -20,7 +20,8 @@
   scripts/plot/util/private/__gnuplot_draw_axes__.m \
   scripts/plot/util/private/__gnuplot_draw_figure__.m \
   scripts/plot/util/private/__opengl_print__.m \
-  scripts/plot/util/private/__print_parse_opts__.m
+  scripts/plot/util/private/__print_parse_opts__.m \
+  scripts/plot/util/private/__set_default_mouse_modes__.m
 
 scripts_plot_util_FCN_FILES = \
   scripts/plot/util/__actual_axis_position__.m \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/util/private/__set_default_mouse_modes__.m	Sun Mar 12 19:12:27 2017 -0700
@@ -0,0 +1,38 @@
+## Copyright (C) 2017 Rik Wehbring
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {} {} __set_default_mouse_modes__.m (@var{fig})
+## Set mouse mode properties of figure to default values.
+##
+## @end deftypefn
+
+function __set_default_mouse_modes__ (fig)
+
+  set (fig, "__pan_mode__", struct ("Enable", "off",
+                                    "Motion", "both",
+                                    "FigureHandle", fig),
+            "__rotate_mode__", struct ("Enable", "off",
+                                       "RotateStyle", "box",
+                                       "FigureHandle", fig),
+            "__zoom_mode__", struct ("Enable", "off",
+                                     "Motion", "both",
+                                     "Direction", "in",
+                                     "FigureHandle", fig));
+
+endfunction