changeset 26194:4f1b3651fa5f

Implement "SizeChangedFcn" for uipanel and uibuttongroup (bug #55085). * graphics.in.h (uibuttongroup::properties, uipanel::properties): Add set method to position property. * graphics.cc (uibuttongroup::properties::set_position, uipanel::properties::set_position): Add new functions that call the resizefcn handle and the sizechangedfcn handle when the size changes.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 08 Dec 2018 16:07:03 +0100
parents 9aff537a5704
children a5094f65012c
files libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h
diffstat 2 files changed, 70 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Mon Dec 10 16:33:48 2018 -0500
+++ b/libinterp/corefcn/graphics.cc	Sat Dec 08 16:07:03 2018 +0100
@@ -10632,6 +10632,37 @@
 }
 
 void
+uibuttongroup::properties::set_position (const octave_value& v)
+{
+  Matrix old_bb, new_bb;
+  bool modified = false;
+
+  old_bb = get_boundingbox (true);
+  modified = position.set (v, false);
+  new_bb = get_boundingbox (true);
+
+  if (old_bb != new_bb)
+    {
+      if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
+        {
+          if (! get_resizefcn ().isempty ())
+            gh_manager::post_callback (__myhandle__, "resizefcn");
+
+          if (! get_sizechangedfcn ().isempty ())
+            gh_manager::post_callback (__myhandle__, "sizechangedfcn");
+
+          update_boundingbox ();
+        }
+    }
+
+  if (modified)
+    {
+      position.run_listeners (POSTSET);
+      mark_modified ();
+    }
+}
+
+void
 uibuttongroup::properties::set_units (const octave_value& val)
 {
   caseless_str old_units = get_units ();
@@ -10803,6 +10834,38 @@
 }
 
 void
+uipanel::properties::set_position (const octave_value& v)
+{
+  Matrix old_bb, new_bb;
+  bool modified = false;
+
+  old_bb = get_boundingbox (true);
+  modified = position.set (v, false);
+  new_bb = get_boundingbox (true);
+
+  if (old_bb != new_bb)
+    {
+      if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
+        {
+          if (! get_resizefcn ().isempty ())
+            gh_manager::post_callback (__myhandle__, "resizefcn");
+
+          if (! get_sizechangedfcn ().isempty ())
+            gh_manager::post_callback (__myhandle__, "sizechangedfcn");
+
+          update_boundingbox ();
+        }
+    }
+
+  if (modified)
+    {
+      position.run_listeners (POSTSET);
+      mark_modified ();
+    }
+}
+
+
+void
 uipanel::properties::set_units (const octave_value& val)
 {
   caseless_str old_units = get_units ();
@@ -11570,8 +11633,11 @@
       if (cname.compare ("deletefcn")
           || cname.compare ("createfcn")
           || (go.isa ("figure")
-              && (cname.compare ("closerequestfcn")
-                  || cname.compare ("resizefcn")
+              && cname.compare ("closerequestfcn"))
+          || ((go.isa ("figure")
+               || go.isa ("uipanel")
+               || go.isa ("uibuttongroup"))
+              && (cname.compare ("resizefcn")
                   || cname.compare ("sizechangedfcn"))))
         busyaction = base_graphics_event::INTERRUPT;
       else if (go.get_properties ().get_busyaction () == "cancel")
--- a/libinterp/corefcn/graphics.in.h	Mon Dec 10 16:33:48 2018 -0500
+++ b/libinterp/corefcn/graphics.in.h	Sat Dec 08 16:07:03 2018 +0100
@@ -5577,7 +5577,7 @@
       radio_property fontweight u , "light|{normal}|demi|bold"
       color_property foregroundcolor , color_values (0, 0, 0)
       color_property highlightcolor , color_values (1, 1, 1)
-      array_property position , default_panel_position ()
+      array_property position S , default_panel_position ()
       // FIXME: "resizefcn" is no longer recommended by Matlab,
       //        and has been replaced with "sizechangedfcn"
       //        Eventually this will need to be hidden, and then removed.
@@ -5677,7 +5677,7 @@
       radio_property fontweight u , "light|{normal}|demi|bold"
       color_property foregroundcolor , color_values (0, 0, 0)
       color_property highlightcolor , color_values (1, 1, 1)
-      array_property position , default_panel_position ()
+      array_property position S , default_panel_position ()
       // FIXME: "resizefcn" is no longer recommended by Matlab,
       //        and has been replaced with "sizechangedfcn"
       //        Eventually this will need to be hidden, and then removed.