[Bf-blender-cvs] [54ac90625f7] modifier-panels-ui: UI: Fix last panel dragging affecting region scroll
Hans Goudey
noreply at git.blender.org
Sat Apr 18 00:21:11 CEST 2020
Commit: 54ac90625f7c88333dc0529b53ada026e975f66f
Author: Hans Goudey
Date: Fri Apr 17 12:01:50 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rB54ac90625f7c88333dc0529b53ada026e975f66f
UI: Fix last panel dragging affecting region scroll
When finding the total height of the region's panels for scrolling, we
should use starting position of the drag, because a drag and drop doesn't
change the resulting height of the region.
===================================================================
M source/blender/editors/interface/interface_panel.c
===================================================================
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index b8f87a4300c..8141e17f3d5 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -853,15 +853,28 @@ int UI_panel_size_y(const Panel *panel)
return get_panel_real_size_y(panel);
}
-/* this function is needed because uiBlock and Panel itself don't
- * change sizey or location when closed */
-static int get_panel_real_ofsy(Panel *panel)
+/**
+ * Return the offset of the panel, checking if the panel is opened or closed. This function is
+ * needed because the #uiBlock and #Panel don't change sizey or location when closed.
+ *
+ * \param include_drag: When finding the total height of the region's panels for scrolling, we
+ * should use starting position of the drag, because a drag and drop doesn't change the resulting
+ * height of the region. This enables that behavior.
+ */
+static int get_panel_real_ofsy(Panel *panel, bool include_drag)
{
+ int offset = panel->ofsy;
+ if (!include_drag) {
+ uiHandlePanelData *data = panel->activedata;
+ if (data && data->state == PANEL_STATE_DRAG) {
+ offset = data->startofsy;
+ }
+ }
if (panel->flag & PNL_CLOSEDY) {
- return panel->ofsy + panel->sizey;
+ return offset + panel->sizey;
}
else {
- return panel->ofsy;
+ return offset;
}
}
@@ -1046,7 +1059,7 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
if (align == BUT_VERTICAL) {
psnext->panel->ofsx = ps->panel->ofsx;
- psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel);
+ psnext->panel->ofsy = get_panel_real_ofsy(ps->panel, true) - get_panel_size_y(psnext->panel);
}
else {
psnext->panel->ofsx = get_panel_real_ofsx(ps->panel);
@@ -1102,7 +1115,7 @@ static void ui_panels_size(ScrArea *area, ARegion *region, int *r_x, int *r_y)
if (align == BUT_VERTICAL) {
pa_sizex = panel->ofsx + panel->sizex;
- pa_sizey = get_panel_real_ofsy(panel);
+ pa_sizey = get_panel_real_ofsy(panel, false);
}
else {
pa_sizex = get_panel_real_ofsx(panel) + panel->sizex;
More information about the Bf-blender-cvs
mailing list