Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-11-25 19:26:53 +0300
committerJulian Eisel <julian@blender.org>2021-11-25 19:26:53 +0300
commit4a3f99ad5a2e6e87156baa5c6f2184df8ea09683 (patch)
tree295575c89f2435f8a74ca99a7a2d2d9430f81421 /source/blender/editors/interface/interface_panel.c
parent3652f5f758aafa2103519c3c0663ba8643b554c1 (diff)
parent5a11c6e558c6581cc07d2a1d67db460241255f09 (diff)
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r--source/blender/editors/interface/interface_panel.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 18fa620f0d9..3c937c545ea 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1334,6 +1334,26 @@ void ui_draw_aligned_panel(const uiStyle *style,
}
}
+bool UI_panel_should_show_background(const ARegion *region, const PanelType *panel_type)
+{
+ if (region->alignment == RGN_ALIGN_FLOAT) {
+ return false;
+ }
+
+ if (panel_type && panel_type->flag & PANEL_TYPE_NO_HEADER) {
+ if (region->regiontype == RGN_TYPE_TOOLS) {
+ /* We never want a background around active tools. */
+ return false;
+ }
+ else {
+ /* Without a header there is no background except for region overlap. */
+ return region->overlap != 0;
+ }
+ }
+
+ return true;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1746,17 +1766,22 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
const int region_offset_x = panel_region_offset_x_get(region);
for (int i = 0; i < active_panels_len; i++) {
PanelSort *ps = &panel_sort[i];
- const bool no_header = ps->panel->type->flag & PANEL_TYPE_NO_HEADER;
+ const bool show_background = UI_panel_should_show_background(region, ps->panel->type);
ps->panel->runtime.region_ofsx = region_offset_x;
- ps->new_offset_x = region_offset_x + (no_header ? 0 : UI_PANEL_MARGIN_X);
+ ps->new_offset_x = region_offset_x + (show_background ? UI_PANEL_MARGIN_X : 0);
}
/* Y offset. */
for (int i = 0, y = 0; i < active_panels_len; i++) {
PanelSort *ps = &panel_sort[i];
+ const bool show_background = UI_panel_should_show_background(region, ps->panel->type);
+
y -= get_panel_real_size_y(ps->panel);
- y -= UI_PANEL_MARGIN_Y;
+ /* Separate panel boxes a bit further (if they are drawn). */
+ if (show_background) {
+ y -= UI_PANEL_MARGIN_Y;
+ }
ps->new_offset_y = y;
/* The header still draws offset by the size of closed panels, so apply the offset here. */
if (UI_panel_is_closed(ps->panel)) {
@@ -1802,6 +1827,7 @@ static void ui_panels_size(ARegion *region, int *r_x, int *r_y)
{
int sizex = 0;
int sizey = 0;
+ bool has_panel_with_background = false;
/* Compute size taken up by panels, for setting in view2d. */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
@@ -1811,6 +1837,9 @@ static void ui_panels_size(ARegion *region, int *r_x, int *r_y)
sizex = max_ii(sizex, pa_sizex);
sizey = min_ii(sizey, pa_sizey);
+ if (UI_panel_should_show_background(region, panel->type)) {
+ has_panel_with_background = true;
+ }
}
}
@@ -1820,6 +1849,11 @@ static void ui_panels_size(ARegion *region, int *r_x, int *r_y)
if (sizey == 0) {
sizey = -UI_PANEL_WIDTH;
}
+ /* Extra margin after the list so the view scrolls a few pixels further than the panel border.
+ * Also makes the bottom match the top margin. */
+ if (has_panel_with_background) {
+ sizey -= UI_PANEL_MARGIN_Y;
+ }
*r_x = sizex;
*r_y = sizey;