[Bf-blender-cvs] [ae42e4be1df] temp-ui-tweaks: UI: Match subpanels look with regular panels

Pablo Vazquez noreply at git.blender.org
Wed Sep 15 01:52:41 CEST 2021


Commit: ae42e4be1df05e9b174b8afece7b89f2a62f766b
Author: Pablo Vazquez
Date:   Wed Sep 15 01:45:54 2021 +0200
Branches: temp-ui-tweaks
https://developer.blender.org/rBae42e4be1df05e9b174b8afece7b89f2a62f766b

UI: Match subpanels look with regular panels

By having coloured headers and offset the background.

TODO: Add margin to the bottom on the last subpanel.

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

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_panel.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 d896f1cd3ed..ca9c5bde37e 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1995,8 +1995,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *region, uiBlock *bloc
 /* uses local copy of style, to scale things down, and allow widgets to change stuff */
 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();
+  const uiStyle *style = UI_style_get_dpi(); /* XXX pass on as arg */
 
   /* get menu region or area region */
   ARegion *region = CTX_wm_menu(C);
@@ -2012,10 +2011,10 @@ void UI_block_draw(const bContext *C, uiBlock *block)
   GPU_blend(GPU_BLEND_ALPHA);
 
   /* scale fonts */
-  ui_fontscale(&style.paneltitle.points, block->aspect);
-  ui_fontscale(&style.grouplabel.points, block->aspect);
-  ui_fontscale(&style.widgetlabel.points, block->aspect);
-  ui_fontscale(&style.widget.points, block->aspect);
+  ui_fontscale(&style->paneltitle.points, block->aspect);
+  ui_fontscale(&style->grouplabel.points, block->aspect);
+  ui_fontscale(&style->widgetlabel.points, block->aspect);
+  ui_fontscale(&style->widget.points, block->aspect);
 
   /* scale block min/max to rect */
   rcti rect;
@@ -2033,10 +2032,10 @@ void UI_block_draw(const bContext *C, uiBlock *block)
     ui_draw_pie_center(block);
   }
   else if (block->flag & UI_BLOCK_POPOVER) {
-    ui_draw_popover_back(region, &style, block, &rect);
+    ui_draw_popover_back(region, style, block, &rect);
   }
   else if (block->flag & UI_BLOCK_LOOP) {
-    ui_draw_menu_back(&style, block, &rect);
+    ui_draw_menu_back(style, block, &rect);
   }
   else if (block->panel) {
     bool show_background = region->alignment != RGN_ALIGN_FLOAT;
@@ -2052,9 +2051,13 @@ void UI_block_draw(const bContext *C, uiBlock *block)
         }
       }
 
-      rect.xmin += stylo->panelouter;
+      if (block->panel->type->parent != NULL) {
+        rect.xmin += style->panelouter;
+      }
+
+      rect.xmin += style->panelouter;
     }
-    ui_draw_aligned_panel(&style,
+    ui_draw_aligned_panel(style,
                           block,
                           &rect,
                           UI_panel_category_is_visible(region),
@@ -2074,7 +2077,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
       /* XXX: figure out why invalid coordinates happen when closing render window */
       /* and material preview is redrawn in main window (temp fix for bug T23848) */
       if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
-        ui_draw_but(C, region, &style, but, &rect);
+        ui_draw_but(C, region, style, but, &rect);
       }
     }
   }
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 0e6dc675cf5..a7f2afebe3b 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1082,7 +1082,7 @@ void UI_panel_label_offset(const uiBlock *block, int *r_x, int *r_y)
   *r_y = UI_UNIT_Y * 1.5f;
 
   if (is_subpanel) {
-    *r_x += (0.7f * UI_UNIT_X);
+    *r_x += style->panelouter;
   }
 }
 
@@ -1161,7 +1161,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
 
   /* Offset triangle and text to the right for subpanels. */
   const rcti widget_rect = {
-      .xmin = header_rect->xmin + (is_subpanel ? scaled_unit * 0.7f : 0),
+      .xmin = header_rect->xmin,
       .xmax = header_rect->xmax,
       .ymin = header_rect->ymin,
       .ymax = header_rect->ymax,
@@ -1255,11 +1255,6 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
   const bool draw_box_style = panel->type->flag & PANEL_TYPE_DRAW_BOX;
   const bool is_subpanel = panel->type->parent != NULL;
   const bool is_open = !UI_panel_is_closed(panel);
-
-  if (is_subpanel && !is_open) {
-    return;
-  }
-
   const uint pos = GPU_vertformat_attr_add(
       immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
@@ -1267,6 +1262,7 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
   if (draw_box_style) {
     /* Use the theme for box widgets. */
     const uiWidgetColors *box_wcol = &UI_GetTheme()->tui.wcol_box;
+    const uiStyle *style = UI_style_get_dpi();
 
     if (is_subpanel) {
       /* Use rounded bottom corners for the last subpanel. */
@@ -1353,22 +1349,27 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
     }
 
     /* Panel header backdrops for non sub-panels. */
-    if (!is_subpanel) {
+    if (is_subpanel) {
+      UI_GetThemeColor4fv(UI_panel_matches_search_filter(panel) ? TH_MATCH : TH_PANEL_SUB_BACK,
+                          panel_headercolor);
+    }
+    else {
       UI_GetThemeColor4fv(UI_panel_matches_search_filter(panel) ? TH_MATCH : TH_PANEL_HEADER,
                           panel_headercolor);
-      UI_draw_roundbox_corner_set(is_open ? UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT : UI_CNR_ALL);
-      UI_draw_roundbox_4fv(
-          &(const rctf){
-              .xmin = rect->xmin,
-              .xmax = rect->xmax,
-              .ymin = header_rect->ymin,
-              .ymax = header_rect->ymax - margin_y,
-          },
-          true,
-          PNL_CNR_RAD,
-          panel_headercolor);
     }
 
+    UI_draw_roundbox_corner_set(is_open ? UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT : UI_CNR_ALL);
+    UI_draw_roundbox_4fv(
+        &(const rctf){
+            .xmin = rect->xmin,
+            .xmax = rect->xmax,
+            .ymin = header_rect->ymin,
+            .ymax = header_rect->ymax - margin_y,
+        },
+        true,
+        PNL_CNR_RAD,
+        panel_headercolor);
+
     GPU_blend(GPU_BLEND_NONE);
     immUnbindProgram();
   }
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 6215e7b976e..16cca1edce3 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2654,7 +2654,7 @@ static void ed_panel_draw(const bContext *C,
 
   bool open;
   panel = UI_panel_begin(region, lb, block, pt, panel, &open);
-
+  const bool is_subpanel = (panel->type && panel->type->parent != NULL);
   const bool search_filter_active = search_filter != NULL && search_filter[0] != '\0';
 
   /* bad fixed values */
@@ -2719,8 +2719,12 @@ static void ed_panel_draw(const bContext *C,
     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;
+    int xofs = (pt->flag & PANEL_TYPE_NO_HEADER) ? 0 : style->panelouter;
+
+    if (is_subpanel) {
+      xofs += style->panelouter;
+    }
 
     /* panel context can either be toolbar region or normal panels region */
     if (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) {
@@ -2769,7 +2773,7 @@ static void ed_panel_draw(const bContext *C,
                       &panel->children,
                       child_pt,
                       child_panel,
-                      w,
+                      w - style->panelouter,
                       em,
                       unique_panel_str,
                       search_filter);



More information about the Bf-blender-cvs mailing list