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:
authorPablo Vazquez <pablo@blender.org>2021-10-17 19:22:53 +0300
committerPablo Vazquez <pablo@blender.org>2021-10-17 19:31:24 +0300
commit93544b641bd6687c9b0af3e203a4069977116a78 (patch)
tree8ca27d5e8f4a039ad4920c981b50cd61c885ef39 /source/blender/editors/interface/interface_panel.c
parent19740b25c778ccd3fccd0ab33c7efd9f761dc001 (diff)
UI: Visual style update to panels
Back in Blender 2.30, the GUI project brought panels into Blender among other important visual updates. For the first time it was possible to move the wall of buttons around. Providing a clear separation between sections (it even allowed the grouping of panels in tabs!) During the 2.5 redesign, the separation between panels became a line on top of each panel, and panels received theme settings for background and header colors. The default theme used the same color for both. In 2.8 the background color of panels was different from headers in the default theme, so the separator line was removed. While the separator line wasn't elegant (only on top, non-themeable, hard-coded emboss effect), it provided a sort of separation between panels. This patch solves the panels-separation by simply adding a margin space around them (not visible in default theme yet). Even though the margin reduces the width of the working area slightly, it makes room for the upcoming always-visible scrollbars. Other adjustments: * Use arrow icon instead of triangle to collapse/expand * Use rounded corners to match the rest of the UI (editor corners, nodes, etc). {F10953929, size=full} Margin on panels makes 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. There is technically no need to update the themes for them to work, so no theme changes are included in this patch. {F10953931, size=full} {F10953933, size=full} {F10953934, size=full} {F10954003, size=full} ---- A new theme setting under Style controls the roundness of all panels (added it to Style instead of ThemeSpace because I think controlling the panel roundness per editor is a bit overkill): {F11091561, size=full, autoplay, loop} Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D12814
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r--source/blender/editors/interface/interface_panel.c176
1 files changed, 62 insertions, 114 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index a64797af24f..e5f84f63d35 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1112,23 +1112,14 @@ static void panel_draw_highlight_border(const Panel *panel,
const rcti *rect,
const rcti *header_rect)
{
- const bool draw_box_style = panel->type->flag & PANEL_TYPE_DRAW_BOX;
const bool is_subpanel = panel->type->parent != NULL;
if (is_subpanel) {
return;
}
- float radius;
- if (draw_box_style) {
- /* Use the theme for box widgets. */
- const uiWidgetColors *box_wcol = &UI_GetTheme()->tui.wcol_box;
- UI_draw_roundbox_corner_set(UI_CNR_ALL);
- radius = box_wcol->roundness * U.widget_unit;
- }
- else {
- UI_draw_roundbox_corner_set(UI_CNR_NONE);
- radius = 0.0f;
- }
+ const bTheme *btheme = UI_GetTheme();
+ const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f;
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
float color[4];
UI_GetThemeColor4fv(TH_SELECT_ACTIVE, color);
@@ -1172,18 +1163,17 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
/* Draw collapse icon. */
{
- rctf collapse_rect = {
- .xmin = widget_rect.xmin,
- .xmax = widget_rect.xmin + header_height,
- .ymin = widget_rect.ymin,
- .ymax = widget_rect.ymax,
- };
- BLI_rctf_scale(&collapse_rect, 0.25f);
-
- float triangle_color[4];
- rgba_uchar_to_float(triangle_color, title_color);
-
- ui_draw_anti_tria_rect(&collapse_rect, UI_panel_is_closed(panel) ? 'h' : 'v', triangle_color);
+ const float size_y = BLI_rcti_size_y(&widget_rect);
+ GPU_blend(GPU_BLEND_ALPHA);
+ UI_icon_draw_ex(widget_rect.xmin + size_y * 0.2f,
+ widget_rect.ymin + size_y * 0.2f,
+ UI_panel_is_closed(panel) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT,
+ aspect * U.inv_dpi_fac,
+ 0.7f,
+ 0.0f,
+ title_color,
+ false);
+ GPU_blend(GPU_BLEND_NONE);
}
/* Draw text label. */
@@ -1243,7 +1233,6 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
const rcti *rect,
const rcti *header_rect)
{
- 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);
@@ -1251,90 +1240,52 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
return;
}
- const uint pos = GPU_vertformat_attr_add(
- immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const bTheme *btheme = UI_GetTheme();
+ const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f;
- /* Draw with an opaque box backdrop for box style panels. */
- if (draw_box_style) {
- /* Use the theme for box widgets. */
- const uiWidgetColors *box_wcol = &UI_GetTheme()->tui.wcol_box;
-
- if (is_subpanel) {
- /* Use rounded bottom corners for the last subpanel. */
- if (panel->next == NULL) {
- UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
- float color[4];
- UI_GetThemeColor4fv(TH_PANEL_SUB_BACK, color);
- /* Change the width a little bit to line up with sides. */
- UI_draw_roundbox_aa(
- &(const rctf){
- .xmin = rect->xmin + U.pixelsize,
- .xmax = rect->xmax - U.pixelsize,
- .ymin = rect->ymin + U.pixelsize,
- .ymax = rect->ymax,
- },
- true,
- box_wcol->roundness * U.widget_unit,
- color);
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformThemeColor(TH_PANEL_SUB_BACK);
- immRectf(pos, rect->xmin + U.pixelsize, rect->ymin, rect->xmax - U.pixelsize, rect->ymax);
- immUnbindProgram();
- }
- }
- else {
- /* Expand the top a tiny bit to give header buttons equal size above and below. */
- rcti box_rect = {
- .xmin = rect->xmin,
- .xmax = rect->xmax,
- .ymin = is_open ? rect->ymin : header_rect->ymin,
- .ymax = header_rect->ymax + U.pixelsize,
- };
- ui_draw_box_opaque(&box_rect, UI_CNR_ALL);
-
- /* Mimic the border between aligned box widgets for the bottom of the header. */
- if (is_open) {
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- GPU_blend(GPU_BLEND_ALPHA);
-
- /* Top line. */
- immUniformColor4ubv(box_wcol->outline);
- immRectf(pos, rect->xmin, header_rect->ymin - U.pixelsize, rect->xmax, header_rect->ymin);
-
- /* Bottom "shadow" line. */
- immUniformThemeColor(TH_WIDGET_EMBOSS);
- immRectf(pos,
- rect->xmin,
- header_rect->ymin - U.pixelsize,
- rect->xmax,
- header_rect->ymin - U.pixelsize - 1);
-
- GPU_blend(GPU_BLEND_NONE);
- immUnbindProgram();
- }
- }
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- GPU_blend(GPU_BLEND_ALPHA);
-
- /* Panel backdrop. */
- if (is_open || panel->type->flag & PANEL_TYPE_NO_HEADER) {
- immUniformThemeColor(is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK);
- immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- }
-
- /* Panel header backdrops for non sub-panels. */
- if (!is_subpanel) {
- immUniformThemeColor(UI_panel_matches_search_filter(panel) ? TH_MATCH : TH_PANEL_HEADER);
- immRectf(pos, rect->xmin, header_rect->ymin, rect->xmax, header_rect->ymax);
- }
-
- GPU_blend(GPU_BLEND_NONE);
- immUnbindProgram();
- }
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ GPU_blend(GPU_BLEND_ALPHA);
+
+ /* Panel backdrop. */
+ if (is_open || panel->type->flag & PANEL_TYPE_NO_HEADER) {
+ float panel_backcolor[4];
+ UI_draw_roundbox_corner_set(is_open ? UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT : UI_CNR_ALL);
+ UI_GetThemeColor4fv((is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK), panel_backcolor);
+
+ UI_draw_roundbox_4fv(
+ &(const rctf){
+ .xmin = rect->xmin,
+ .xmax = rect->xmax,
+ .ymin = rect->ymin,
+ .ymax = rect->ymax,
+ },
+ true,
+ radius,
+ panel_backcolor);
+ }
+
+ /* Panel header backdrops for non sub-panels. */
+ if (!is_subpanel) {
+ float panel_headercolor[4];
+ 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);
+
+ /* Change the width a little bit to line up with the sides. */
+ UI_draw_roundbox_4fv(
+ &(const rctf){
+ .xmin = rect->xmin,
+ .xmax = rect->xmax,
+ .ymin = header_rect->ymin,
+ .ymax = header_rect->ymax,
+ },
+ true,
+ radius,
+ panel_headercolor);
+ }
+
+ GPU_blend(GPU_BLEND_NONE);
+ immUnbindProgram();
}
/**
@@ -1789,9 +1740,9 @@ 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 use_box = ps->panel->type->flag & PANEL_TYPE_DRAW_BOX;
+ const bool no_header = ps->panel->type->flag & PANEL_TYPE_NO_HEADER;
ps->panel->runtime.region_ofsx = region_offset_x;
- ps->new_offset_x = region_offset_x + ((use_box) ? UI_PANEL_BOX_STYLE_MARGIN : 0);
+ ps->new_offset_x = region_offset_x + (no_header ? 0 : UI_PANEL_MARGIN_X);
}
/* Y offset. */
@@ -1799,10 +1750,7 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
PanelSort *ps = &panel_sort[i];
y -= get_panel_real_size_y(ps->panel);
- const bool use_box = ps->panel->type->flag & PANEL_TYPE_DRAW_BOX;
- if (use_box) {
- y -= UI_PANEL_BOX_STYLE_MARGIN;
- }
+ 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)) {