[Bf-blender-cvs] [e845467d93f] blender-v2.92-release: Fix: Mouse presses in some areas do not set active modifier

Hans Goudey noreply at git.blender.org
Fri Jan 22 18:28:46 CET 2021


Commit: e845467d93fe35e222d14b0bb27472ccb309b321
Author: Hans Goudey
Date:   Fri Jan 22 11:08:58 2021 -0600
Branches: blender-v2.92-release
https://developer.blender.org/rBe845467d93fe35e222d14b0bb27472ccb309b321

Fix: Mouse presses in some areas do not set active modifier

There are a couple of operations that are meant to set the active
modifier that currently don't. The first is a mouse press on the drag
icon on the right of the header, and the second is mouse presses on
modifier sub-panels headers.

This was an oversight in the implementation, especially the second,
because the blank space on the right of a sub-panel header often looks
just like the blank space elsewhere on the modifier's panel that
*does* set the active modifier.

Note that this purposefully doesn't include collapsing and expanding
the modifier as operations that set the active, since regardless of
whether that makes sense, it wasn't in the agreed upon design, which
would ideally not need changing for 2.92.

Differential Revision: https://developer.blender.org/D10155

===================================================================

M	source/blender/editors/interface/interface_panel.c
M	source/blender/modifiers/intern/MOD_ui_common.c

===================================================================

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index e96c0a25d6d..12862363c5b 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -583,7 +583,7 @@ static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *r
 /** \name Panels
  * \{ */
 
-static bool panel_use_active_highlight(const Panel *panel)
+static bool panel_custom_data_active_get(const Panel *panel)
 {
   /* The caller should make sure the panel is active and has a type. */
   BLI_assert(UI_panel_is_active(panel));
@@ -599,6 +599,21 @@ static bool panel_use_active_highlight(const Panel *panel)
   return false;
 }
 
+static void panel_custom_data_active_set(Panel *panel)
+{
+  /* Since the panel is interacted with, it should be active and have a type. */
+  BLI_assert(UI_panel_is_active(panel));
+  BLI_assert(panel->type != NULL);
+
+  if (panel->type->active_property[0] != '\0') {
+    PointerRNA *ptr = UI_panel_custom_data_get(panel);
+    BLI_assert(RNA_struct_find_property(ptr, panel->type->active_property) != NULL);
+    if (ptr != NULL && !RNA_pointer_is_null(ptr)) {
+      RNA_boolean_set(ptr, panel->type->active_property, true);
+    }
+  }
+}
+
 /**
  * Set flag state for a panel and its sub-panels.
  */
@@ -1342,7 +1357,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
                                region_search_filter_active);
   }
 
-  if (panel_use_active_highlight(panel)) {
+  if (panel_custom_data_active_get(panel)) {
     panel_draw_highlight_border(panel, rect, &header_rect);
   }
 }
@@ -2169,6 +2184,12 @@ static void ui_handle_panel_header(const bContext *C,
       ui_panel_drag_collapse_handler_add(C, UI_panel_is_closed(panel));
     }
 
+    /* Set panel custom data (modifier) active when expanding subpanels, but not top-level
+     * panels to allow collapsing and expanding without setting the active element. */
+    if (is_subpanel) {
+      panel_custom_data_active_set(panel);
+    }
+
     set_panels_list_data_expand_flag(C, region);
     panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
     return;
@@ -2607,6 +2628,8 @@ static void panel_activate_state(const bContext *C, Panel *panel, const uiHandle
   }
 
   if (state == PANEL_STATE_DRAG) {
+    panel_custom_data_active_set(panel);
+
     panel_set_flag_recursive(panel, PNL_SELECT, true);
     panel_set_runtime_flag_recursive(panel, PANEL_IS_DRAG_DROP, true);
 
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index c5ee96491b8..821c74496f2 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -460,6 +460,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type,
   BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME);
+  BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME);
 
   panel_type->draw_header = draw_header;
   panel_type->draw = draw;



More information about the Bf-blender-cvs mailing list