UI: Draw background for headerless panels with region-overlap
authorCampbell Barton <ideasman42@gmail.com>
Thu, 16 May 2019 08:06:55 +0000 (18:06 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 16 May 2019 08:07:38 +0000 (18:07 +1000)
These were drawing without a backdrop.

source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_panel.c

index 7c60ac7..f334d4a 100644 (file)
@@ -1687,6 +1687,12 @@ void UI_block_draw(const bContext *C, uiBlock *block)
   }
   else if (block->panel) {
     bool show_background = ar->alignment != RGN_ALIGN_FLOAT;
+    if (show_background) {
+      if (block->panel->type && (block->panel->type->flag & PNL_NO_HEADER)) {
+        /* Without a header there is no background except for region overlap. */
+        show_background = ar->overlap != 0;
+      }
+    }
     ui_draw_aligned_panel(&style, block, &rect, UI_panel_category_is_visible(ar), show_background);
   }
 
index 46b1279..aa7ff01 100644 (file)
@@ -649,8 +649,17 @@ void ui_draw_aligned_panel(uiStyle *style,
                           /* FIXME(campbell): currently no background means floating panel which
                            * can't be dragged. This may be changed in future. */
                           show_background);
+  const int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
 
   if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+    if (show_background) {
+      uint pos = GPU_vertformat_attr_add(
+          immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+      immUniformThemeColor(panel_col);
+      immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+      immUnbindProgram();
+    }
     return;
   }
 
@@ -781,8 +790,6 @@ void ui_draw_aligned_panel(uiStyle *style,
 
     if (show_background) {
       /* panel backdrop */
-      int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
-
       immUniformThemeColor(panel_col);
       immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
     }