[Bf-blender-cvs] [870404455bb] temp-ui-tweaks: UI: Add margin to panels

Pablo Vazquez noreply at git.blender.org
Sat Aug 28 02:21:33 CEST 2021


Commit: 870404455bb74ef0c1eb9bdd504be919d95f54c7
Author: Pablo Vazquez
Date:   Sat Aug 28 02:21:07 2021 +0200
Branches: temp-ui-tweaks
https://developer.blender.org/rB870404455bb74ef0c1eb9bdd504be919d95f54c7

UI: Add margin to panels

Add some breathing space between the panel boundaries and properties/regions.

Make use of the style->panelouter property that hasn't been used in a while.
Also slight tweaks to boxspace and templatespace style properties so they
are multiples of 2 and operations on them round better.

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

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/screen/area.c

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index fd75be5b847..d896f1cd3ed 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1996,6 +1996,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *region, uiBlock *bloc
 void UI_block_draw(const bContext *C, uiBlock *block)
 {
   uiStyle style = *UI_style_get_dpi(); /* XXX pass on as arg */
+  const uiStyle *stylo = UI_style_get_dpi();
 
   /* get menu region or area region */
   ARegion *region = CTX_wm_menu(C);
@@ -2050,6 +2051,8 @@ void UI_block_draw(const bContext *C, uiBlock *block)
           show_background = region->overlap != 0;
         }
       }
+
+      rect.xmin += stylo->panelouter;
     }
     ui_draw_aligned_panel(&style,
                           block,
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index ff9d2f4d770..a173642df98 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1075,9 +1075,10 @@ void UI_panels_draw(const bContext *C, ARegion *region)
 void UI_panel_label_offset(const uiBlock *block, int *r_x, int *r_y)
 {
   Panel *panel = block->panel;
+  const uiStyle *style = UI_style_get();
   const bool is_subpanel = (panel->type && panel->type->parent);
 
-  *r_x = UI_UNIT_X * 1.0f;
+  *r_x = UI_UNIT_X * 1.0f + style->panelouter + U.pixelsize;
   *r_y = UI_UNIT_Y * 1.5f;
 
   if (is_subpanel) {
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 88ab6a377d0..5931e97168e 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -117,12 +117,12 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
   style->widget.shadowcolor = 0.0f;
 
   style->columnspace = 8;
-  style->templatespace = 5;
-  style->boxspace = 5;
+  style->templatespace = 4;
+  style->boxspace = 4;
   style->buttonspacex = 8;
   style->buttonspacey = 2;
   style->panelspace = 8;
-  style->panelouter = 4;
+  style->panelouter = 8;
 
   return style;
 }
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e08a4e946f6..aba43ddc1a3 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2720,6 +2720,10 @@ static void ed_panel_draw(const bContext *C,
   if (open || search_filter_active) {
     short panelContext;
 
+    /* Extra offset and panel width adjustment to accomodate sides margin (style->panelouter). */
+    const int xofs = (pt->flag & PANEL_TYPE_NO_HEADER) ? 0 : style->panelouter;
+    const int wofs = (pt->flag & PANEL_TYPE_NO_HEADER) ? style->panelouter : 0;
+
     /* panel context can either be toolbar region or normal panels region */
     if (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) {
       panelContext = UI_LAYOUT_VERT_BAR;
@@ -2735,9 +2739,9 @@ static void ed_panel_draw(const bContext *C,
         block,
         UI_LAYOUT_VERTICAL,
         panelContext,
-        (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : style->panelspace,
+        (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : style->panelspace + xofs,
         0,
-        (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : w - 2 * style->panelspace,
+        (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : (w - 2 * style->panelspace + wofs - xofs),
         em,
         0,
         style);
@@ -2877,12 +2881,13 @@ void ED_region_panels_layout_ex(const bContext *C,
 
   ScrArea *area = CTX_wm_area(C);
   View2D *v2d = &region->v2d;
+  const uiStyle *style = UI_style_get_dpi();
 
   bool use_category_tabs = (category_override == NULL) && region_uses_category_tabs(area, region);
   /* offset panels for small vertical tab area */
   const char *category = NULL;
   const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
-  int margin_x = 0;
+  int margin_x = style->panelouter;
   const bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
   bool update_tot_size = true;
 
@@ -2897,7 +2902,7 @@ void ED_region_panels_layout_ex(const bContext *C,
     category = region_panels_collect_categories(region, panel_types_stack, &use_category_tabs);
   }
   if (use_category_tabs) {
-    margin_x = category_tabs_width;
+    margin_x = category_tabs_width + style->panelouter;
   }
 
   const int w = BLI_rctf_size_x(&v2d->cur) - margin_x;



More information about the Bf-blender-cvs mailing list