[gimp] app: in GimpToolWidgetGroup, improve focus behavior when adding/removing widgets



commit 95d2c92ff244e884b5001df3a3bceaed0f262e10
Author: Ell <ell_se yahoo com>
Date:   Sun Sep 23 12:34:12 2018 -0400

    app: in GimpToolWidgetGroup, improve focus behavior when adding/removing widgets
    
    When a focused widget is added to a group, make it the new focus-
    widget of the group, instead of unsetting its focus if another
    widget already has focus.
    
    When removing the focused widget from a group, set a different
    widget as the group's focus widget (if one exists), instead of
    unsetting the focus widget, so that nonempty groups always have a
    focus widget.

 app/display/gimptoolwidgetgroup.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/app/display/gimptoolwidgetgroup.c b/app/display/gimptoolwidgetgroup.c
index 593b361db3..f6d2f5606c 100644
--- a/app/display/gimptoolwidgetgroup.c
+++ b/app/display/gimptoolwidgetgroup.c
@@ -447,6 +447,13 @@ gimp_tool_widget_group_children_add (GimpContainer       *container,
   gimp_canvas_group_add_item (canvas_group,
                               gimp_tool_widget_get_item (child));
 
+  if (gimp_tool_widget_get_focus (child) && priv->focus_widget)
+    {
+      gimp_tool_widget_set_focus (priv->focus_widget, FALSE);
+
+      priv->focus_widget = NULL;
+    }
+
   if (! priv->focus_widget)
     {
       priv->focus_widget = child;
@@ -482,6 +489,15 @@ gimp_tool_widget_group_children_remove (GimpContainer       *container,
       priv->hover_widget = NULL;
     }
 
+  if (! priv->focus_widget)
+    {
+      priv->focus_widget =
+        GIMP_TOOL_WIDGET (gimp_container_get_first_child (container));
+
+      if (priv->focus_widget)
+        gimp_tool_widget_set_focus (priv->focus_widget, TRUE);
+    }
+
   gimp_canvas_group_remove_item (canvas_group,
                                  gimp_tool_widget_get_item (child));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]