changeset 28298:e55ff14249c3

Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336). * graphics.in.h (base_properties): Add new property "contextmenu". Hide legacy property "uicontextmenu". (base_properties::get_uicontextmenu, base_properties::set_uicontextmenu): Add functions that redirect to "contextmenu" value. (axes::properties, scatter::properties): Remove property "contextmenu". * graphics.cc (base_properties::update_contextmenu): Rename from base_properties::update_uicontextmenu. (uicontextmenu::~uicontextmenu): Remove self from "contextmenu" property. * hdl2struct.m, struct2hdl.m: Update for new base property. * doc/interpreter/genpropdoc.m: Move description of "uicontextmenu" property to "contextmenu".
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 16 May 2020 18:45:34 +0200
parents a01ad9893641
children a8f6a7083428
files doc/interpreter/genpropdoc.m libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h scripts/plot/util/hdl2struct.m scripts/plot/util/struct2hdl.m
diffstat 5 files changed, 43 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/genpropdoc.m	Thu May 14 11:32:06 2020 +0200
+++ b/doc/interpreter/genpropdoc.m	Sat May 16 18:45:34 2020 +0200
@@ -166,6 +166,11 @@
         s.doc = "If __prop__ is @qcode{\"on\"}, the __objname__ is \
 clipped in its parent axes limits.";
 
+      case "contextmenu"
+        s.doc = "Graphics handle of the uicontextmenu object that is \
+currently associated to this __objname__ object.";
+        s.valid = valid_handle;
+
       case "createfcn"
         s.doc = "Callback function executed immediately after __objname__ \
 has been created.  Function is set by using default property on root object, \
@@ -225,11 +230,6 @@
         s.valid = valid_string;
         s.printdefault = false;
 
-      case "uicontextmenu"
-        s.doc = "Graphics handle of the uicontextmenu object that is \
-currently associated to this __objname__ object.";
-        s.valid = valid_handle;
-
       case "userdata"
         s.doc = "User-defined data to associate with the graphics object.";
         s.valid = "Any Octave data";
--- a/libinterp/corefcn/graphics.cc	Thu May 14 11:32:06 2020 +0200
+++ b/libinterp/corefcn/graphics.cc	Sat May 16 18:45:34 2020 +0200
@@ -1787,18 +1787,18 @@
 }
 
 /*
-## Test validation of uicontextmenu property
+## Test validation of contextmenu property
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   hax = axes ("parent", hf);
 %!   hpa = patch ("parent", hax);
 %!   try
-%!     set (hax, "uicontextmenu", hpa);
+%!     set (hax, "contextmenu", hpa);
 %!   catch
 %!     err = lasterr ();
 %!   end_try_catch
-%!   assert (err, 'set: invalid graphics object type for property "uicontextmenu"');
+%!   assert (err, 'set: invalid graphics object type for property "contextmenu"');
 %! unwind_protect_cleanup
 %!   delete (hf);
 %! end_unwind_protect
@@ -3501,15 +3501,15 @@
 }
 
 void
-base_properties::update_uicontextmenu (void) const
-{
-  if (uicontextmenu.get ().isempty ())
+base_properties::update_contextmenu (void) const
+{
+  if (contextmenu.get ().isempty ())
     return;
 
   gh_manager& gh_mgr
-    = octave::__get_gh_manager__ ("base_properties::update_uicontextmenu");
-
-  graphics_object go = gh_mgr.get_object (uicontextmenu.get ());
+    = octave::__get_gh_manager__ ("base_properties::update_contextmenu");
+
+  graphics_object go = gh_mgr.get_object (contextmenu.get ());
 
   if (go && go.isa ("uicontextmenu"))
     {
@@ -10931,8 +10931,8 @@
       graphics_object go = gh_mgr.get_object (*it);
 
       if (go.valid_object ()
-          && go.get ("uicontextmenu") == xproperties.get___myhandle__ ())
-        go.set ("uicontextmenu", Matrix ());
+          && go.get ("contextmenu") == xproperties.get___myhandle__ ())
+        go.set ("contextmenu", Matrix ());
     }
 }
 
--- a/libinterp/corefcn/graphics.in.h	Thu May 14 11:32:06 2020 +0200
+++ b/libinterp/corefcn/graphics.in.h	Sat May 16 18:45:34 2020 +0200
@@ -2308,6 +2308,18 @@
 
   void set___modified__ (const octave_value& val) { __modified__ = val; }
 
+  // Redirect calls to "uicontextmenu" to "contextmenu".
+
+  graphics_handle get_uicontextmenu (void) const
+  {
+    return get_contextmenu ();
+  }
+
+  void set_uicontextmenu (const octave_value& val)
+  {
+    set_contextmenu (val);
+  }
+
   void reparent (const graphics_handle& new_parent) { parent = new_parent; }
 
   // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent
@@ -2318,7 +2330,7 @@
   virtual void update_axis_limits (const std::string& axis_type,
                                    const graphics_handle& h) const;
 
-  virtual void update_uicontextmenu (void) const;
+  virtual void update_contextmenu (void) const;
 
   virtual void delete_children (bool clear = false, bool from_root = false)
   {
@@ -2378,6 +2390,7 @@
     callback_property buttondownfcn , Matrix ()
     children_property children gf , Matrix ()
     bool_property clipping , "on"
+    handle_property contextmenu u , graphics_handle ()
     callback_property createfcn , Matrix ()
     callback_property deletefcn , Matrix ()
     radio_property handlevisibility u , "{on}|callback|off"
@@ -2389,7 +2402,7 @@
     bool_property selectionhighlight , "on"
     string_property tag s , ""
     string_property type frs , ty
-    handle_property uicontextmenu u , graphics_handle ()
+    handle_property uicontextmenu gsh , graphics_handle ()
     any_property userdata , Matrix ()
     bool_property visible u , "on"
 
@@ -2425,7 +2438,7 @@
 
   virtual void init (void)
   {
-    uicontextmenu.add_constraint ("uicontextmenu");
+    contextmenu.add_constraint ("uicontextmenu");
   }
 };
 
@@ -3647,8 +3660,6 @@
       array_property colororder , default_colororder ()
       double_property colororderindex , 1.0
       radio_property colorscale , "{linear}|log"
-      // FIXME: "contextmenu" should be synonymous to "uicontextmenu". Make it read-only for now.
-      handle_property contextmenu r , graphics_handle ()
       array_property currentpoint , Matrix (2, 3, 0.0)
       row_vector_property dataaspectratio mu , Matrix (1, 3, 1.0)
       radio_property dataaspectratiomode u , "{auto}|manual"
@@ -3705,7 +3716,6 @@
       radio_property titlefontweight u , "{bold}|normal"
       // FIXME: Should be a "axestoolbar" object. Make it read-only for now.
       handle_property toolbar r , graphics_handle ()
-      // FIXME: Move the hidden property "uicontextmenu" here.
       radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters"
       array_property view u , default_axes_view ()
       // FIXME: Should be a "ruler" object. Make it read-only for now.
@@ -5116,7 +5126,6 @@
       array_property cdata mu , Matrix ()
       radio_property cdatamode u , "{auto}|manual"
       string_property cdatasource , ""
-      array_property contextmenu , Matrix ()
       array_property datatiptemplate , Matrix ()
       string_property displayname , ""
       array_property latitudedata , Matrix ()
@@ -5666,6 +5675,7 @@
 
 // ---------------------------------------------------------------------
 
+// FIXME: This class has been renamed to "contextmenu" in Matlab R2020a.
 class OCTINTERP_API uicontextmenu : public base_graphics_object
 {
 public:
--- a/scripts/plot/util/hdl2struct.m	Thu May 14 11:32:06 2020 +0200
+++ b/scripts/plot/util/hdl2struct.m	Sat May 16 18:45:34 2020 +0200
@@ -139,12 +139,13 @@
   persistent excluded;
 
   if (isempty (excluded))
-    excluded = cell2struct (repmat ({[]}, 1, 15),
+    excluded = cell2struct (repmat ({[]}, 1, 16),
                             {"beingdeleted", "busyaction", "buttondownfcn", ...
-                             "children", "clipping", "createfcn", ...
-                             "deletefcn", "handlevisibility", "hittest", ...
-                             "interruptible", "parent", "selected" , ...
-                             "selectionhighlight", "type", "uicontextmenu"}, 2);
+                             "children", "clipping", "contextmenu", ...
+                             "createfcn", "deletefcn", "handlevisibility", ...
+                             "hittest", "interruptible", "parent", ...
+                             "selected" , "selectionhighlight", "type", ...
+                             "uicontextmenu"}, 2);
   endif
 
   obj = get (h);
--- a/scripts/plot/util/struct2hdl.m	Thu May 14 11:32:06 2020 +0200
+++ b/scripts/plot/util/struct2hdl.m	Sat May 16 18:45:34 2020 +0200
@@ -158,12 +158,10 @@
       endif
     endif
     ## remove read only properties
-    ## FIXME: Remove "contextmenu", "interactions", "layout", "legend",
-    ## "toolbar", "xaxis", "yaxis", and "zaxis" from this list once they are
-    ## implemented.
-    ro_props = {"contextmenu", "interactions", "layout", "legend", ...
-                "nextseriesindex", "tightinset", "toolbar", "xaxis", ...
-                "yaxis", "zaxis"};
+    ## FIXME: Remove "interactions", "layout", "legend", "toolbar", "xaxis",
+    ## "yaxis", and "zaxis" from this list once they are implemented.
+    ro_props = {"interactions", "layout", "legend", "nextseriesindex", ...
+                "tightinset", "toolbar", "xaxis", "yaxis", "zaxis"};
     has_ro_props = cellfun (@(x) isfield (s.properties, x), ro_props);
     if (any (has_ro_props))
       s.properties = rmfield (s.properties, ro_props(has_ro_props));