changeset 28251:be19ade4acc3

Ignore default "backgroundcolor" for uicontrol edit/listbox objects for Matlab compatibility (bug #58261). * BaseControl.cc (updatePalette): For "edit"/"listbox" objects, check if "backgroundcolor" property is default ([0.94 0.94 0.94]) and replace with white ([1 1 1]) if found.
author Rik <rik@octave.org>
date Mon, 27 Apr 2020 10:14:03 -0700
parents afc53bd3d71b
children 014e80a92d4f
files libgui/graphics/BaseControl.cc
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/BaseControl.cc	Mon Apr 27 09:10:40 2020 -0700
+++ b/libgui/graphics/BaseControl.cc	Mon Apr 27 10:14:03 2020 -0700
@@ -50,10 +50,17 @@
     if (props.style_is ("edit")
         || props.style_is ("listbox"))
       {
+        Matrix bg_color = props.get_backgroundcolor_rgb ();
+        // Matlab compatibility: Default color is ignored, and rendered as
+        // white ([1.0, 1.0, 1.0]).  See bug #58261.
+        if (bg_color(0) == bg_color(1) && bg_color(0) == bg_color(2)
+            && (std::abs (bg_color(1) - 0.94) < .005))
+          bg_color.fill (1.0);
+
         p.setColor (QPalette::Active, QPalette::Base,
-                    Utils::fromRgb (props.get_backgroundcolor_rgb ()));
+                    Utils::fromRgb (bg_color));
         p.setColor (QPalette::Inactive, QPalette::Base,
-                    Utils::fromRgb (props.get_backgroundcolor_rgb ()));
+                    Utils::fromRgb (bg_color));
         p.setColor (QPalette::Active, QPalette::Text,
                     Utils::fromRgb (props.get_foregroundcolor_rgb ()));
         p.setColor (QPalette::Inactive, QPalette::Text,