[Bf-blender-cvs] [8e08d80e52d] master: Fix dragging panels changing region size

Julian Eisel noreply at git.blender.org
Thu Apr 30 19:22:17 CEST 2020


Commit: 8e08d80e52d6e1ab15e6b9726b5757fbaa2e6cf6
Author: Julian Eisel
Date:   Thu Apr 30 18:58:05 2020 +0200
Branches: master
https://developer.blender.org/rB8e08d80e52d6e1ab15e6b9726b5757fbaa2e6cf6

Fix dragging panels changing region size

While dragging panels, the region size would change which would feel glitchy.

See D7462 for a demo of the issue.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 709e05c18b6..f4dd2da06fc 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1672,6 +1672,7 @@ void UI_panel_end(const struct ScrArea *area,
 void UI_panels_scale(struct ARegion *region, float new_width);
 void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
 int UI_panel_size_y(const struct Panel *panel);
+bool UI_panel_is_dragging(const struct Panel *panel);
 
 bool UI_panel_category_is_visible(const struct ARegion *region);
 void UI_panel_category_add(struct ARegion *region, const char *name);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index f824670cc57..911250891f0 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -876,6 +876,16 @@ static int get_panel_real_ofsx(Panel *panel)
   }
 }
 
+bool UI_panel_is_dragging(const struct Panel *panel)
+{
+  uiHandlePanelData *data = panel->activedata;
+  if (!data) {
+    return false;
+  }
+
+  return (data->state == PANEL_STATE_DRAG);
+}
+
 typedef struct PanelSort {
   Panel *panel, *orig;
 } PanelSort;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 69cfe72308f..bbc6b9e7c86 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2515,6 +2515,7 @@ void ED_region_panels_layout_ex(const bContext *C,
   int margin_x = 0;
   const bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
   const bool is_context_new = (contextnr != -1) ? UI_view2d_tab_set(v2d, contextnr) : false;
+  bool update_tot_size = true;
 
   /* before setting the view */
   if (vertical) {
@@ -2583,6 +2584,11 @@ void ED_region_panels_layout_ex(const bContext *C,
       }
     }
 
+    if (panel && UI_panel_is_dragging(panel)) {
+      /* Prevent View2d.tot rectangle size changes while dragging panels. */
+      update_tot_size = false;
+    }
+
     ed_panel_draw(C, area, region, &region->panels, pt, panel, w, em, vertical);
   }
 
@@ -2638,8 +2644,10 @@ void ED_region_panels_layout_ex(const bContext *C,
     y = -y;
   }
 
-  /* this also changes the 'cur' */
-  UI_view2d_totRect_set(v2d, x, y);
+  if (update_tot_size) {
+    /* this also changes the 'cur' */
+    UI_view2d_totRect_set(v2d, x, y);
+  }
 
   if (use_category_tabs) {
     region->runtime.category = category;



More information about the Bf-blender-cvs mailing list