[Bf-blender-cvs] [f3a2f735a29] modifier-panels-ui: Add margin and rounded corners to list panels
Hans Goudey
noreply at git.blender.org
Tue Apr 14 22:29:52 CEST 2020
Commit: f3a2f735a29c2589d43f21b29084c3209f17b793
Author: Hans Goudey
Date: Tue Apr 14 15:29:37 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rBf3a2f735a29c2589d43f21b29084c3209f17b793
Add margin and rounded corners to list panels
This helps differentiate them from regular panels and makes it clearer
that they are separate from each other.
Also added a list panel subpanel flag to avoid always searching parents to
see if a panel belongs to a list panel.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/screen/area.c
M source/blender/makesdna/DNA_screen_types.h
M source/blender/modifiers/intern/MOD_ui_common.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 0bbd42979f7..cb74107fd5b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -238,6 +238,9 @@ enum {
#define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
+#define UI_LIST_PANEL_MARGIN (U.widget_unit * 0.15f)
+#define UI_LIST_PANEL_ROUNDNESS (U.widget_unit * 0.3f)
+
/* but->drawflag - these flags should only affect how the button is drawn. */
/* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions
* (except for the 'align' ones)!
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 1cffc3d5b16..cb428aa15d5 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -848,6 +848,8 @@ void ui_draw_aligned_panel(uiStyle *style,
* 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;
+ const bool is_list_panel = (panel->type &&
+ panel->type->flag & (PNL_RECREATE | PNL_RECREATE_SUBPANEL));
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
if (show_background) {
@@ -875,28 +877,44 @@ void ui_draw_aligned_panel(uiStyle *style,
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ /* Draw the header backdrop. */
if (show_background && !is_subpanel) {
float minx = rect->xmin;
float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax;
float y = headrect.ymax;
- GPU_blend(true);
+ /* List panels have some roundness and a shaded header color to differentiate them. */
+ if (is_list_panel) {
+ /* Round all corners if the panel is closed. */
+ if (is_closed_y) {
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ }
+ else {
+ UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
+ }
- /* draw with background color */
- immUniformThemeColor(TH_PANEL_HEADER);
- immRectf(pos, minx, headrect.ymin, maxx, y);
+ UI_GetThemeColorShadeAlpha4fv(TH_PANEL_HEADER, -30, 125, color);
+ UI_draw_roundbox_aa(true, minx, headrect.ymin, maxx, y, UI_LIST_PANEL_ROUNDNESS, color);
+ }
+ else {
+ GPU_blend(true);
- immBegin(GPU_PRIM_LINES, 4);
+ /* draw with background color */
+ immUniformThemeColor(TH_PANEL_HEADER);
+ immRectf(pos, minx, headrect.ymin, maxx, y);
- immVertex2f(pos, minx, y);
- immVertex2f(pos, maxx, y);
+ immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, minx, y);
- immVertex2f(pos, maxx, y);
+ immVertex2f(pos, minx, y);
+ immVertex2f(pos, maxx, y);
- immEnd();
+ immVertex2f(pos, minx, y);
+ immVertex2f(pos, maxx, y);
- GPU_blend(false);
+ immEnd();
+
+ GPU_blend(false);
+ }
}
immUnbindProgram();
@@ -968,11 +986,18 @@ void ui_draw_aligned_panel(uiStyle *style,
else {
/* in some occasions, draw a border */
if (panel->flag & PNL_SELECT) {
+ float radius;
if (panel->control & UI_PNL_SOLID) {
UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ radius = 8.0f;
+ }
+ else if (is_list_panel) {
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ radius = UI_LIST_PANEL_ROUNDNESS;
}
else {
UI_draw_roundbox_corner_set(UI_CNR_NONE);
+ radius = 0.0f;
}
UI_GetThemeColorShade4fv(TH_BACK, -120, color);
@@ -981,7 +1006,7 @@ void ui_draw_aligned_panel(uiStyle *style,
0.5f + rect->ymin,
0.5f + rect->xmax,
0.5f + headrect.ymax + 1,
- 8,
+ radius,
color);
}
@@ -990,9 +1015,18 @@ void ui_draw_aligned_panel(uiStyle *style,
GPU_blend(true);
if (show_background) {
- /* panel backdrop */
- immUniformThemeColor(panel_col);
- immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ /* Round the bottom corners as long as this isn't a subpanel between other subpanels. */
+ if (is_list_panel && !(is_subpanel && panel->next)) {
+ UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
+ UI_GetThemeColor4fv(panel_col, color);
+ UI_draw_roundbox_aa(
+ true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, UI_LIST_PANEL_ROUNDNESS, color);
+ }
+ else {
+ /* panel backdrop */
+ immUniformThemeColor(panel_col);
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ }
}
if (panel->control & UI_PNL_SCALE) {
@@ -1264,6 +1298,12 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
ps->panel->ofsx = 0;
ps->panel->ofsy = -get_panel_size_y(ps->panel);
ps->panel->ofsx += ps->panel->runtime.region_ofsx;
+ /* Extra margin if the first panel happens to be a list panel. */
+ bool first_is_list_panel = (ps->panel->type && ps->panel->type->flag & PNL_RECREATE);
+ if (first_is_list_panel) {
+ ps->panel->ofsx += UI_LIST_PANEL_MARGIN;
+ ps->panel->ofsy -= UI_LIST_PANEL_MARGIN;
+ }
for (a = 0; a < tot - 1; a++, ps++) {
psnext = ps + 1;
@@ -1271,6 +1311,13 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
if (align == BUT_VERTICAL) {
psnext->panel->ofsx = ps->panel->ofsx;
psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel);
+ /* Extra margin for list panels. */
+ if (psnext->panel->type && psnext->panel->type->flag & PNL_RECREATE) {
+ psnext->panel->ofsy -= UI_LIST_PANEL_MARGIN;
+ if (!first_is_list_panel) {
+ psnext->panel->ofsx = UI_LIST_PANEL_MARGIN;
+ }
+ }
}
else {
psnext->panel->ofsx = get_panel_real_ofsx(ps->panel);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 71d577ba419..a3d61ee15aa 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2621,6 +2621,8 @@ void ED_region_panels_layout_ex(const bContext *C,
}
if (has_recreate_panel) {
+ /* List panels have some margin to differentiate them from regular panels. */
+ w -= UI_LIST_PANEL_MARGIN * 2.0f;
for (Panel *panel = region->panels.first; panel; panel = panel->next) {
if (panel->type != NULL) { /* Some panels don't have a type.. */
if (panel->type->flag & PNL_RECREATE) {
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 4005eb9bd1f..e2f23fb5792 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -552,8 +552,10 @@ enum {
#define PNL_LAYOUT_VERT_BAR (1 << 2)
/** Delete panel after drawing, don't search for panel by type. */
#define PNL_RECREATE (1 << 3)
+/* Convenience flag to avoid searching through parents to tell if it belongs to a list panel. */
+#define PNL_RECREATE_SUBPANEL (1 << 4)
/** This panel marks the start of a recreate panel list. Not recreated on list change. */
-#define PNL_RECREATE_LIST_START (1 << 4)
+#define PNL_RECREATE_LIST_START (1 << 5)
/* Fallback panel category (only for old scripts which need updating) */
#define PNL_CATEGORY_FALLBACK "Misc"
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index 56aff2737ea..699c16f5321 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -374,7 +374,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type,
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = modifier_ui_poll;
- panel_type->flag = PNL_DEFAULT_CLOSED;
+ panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_RECREATE_SUBPANEL);
BLI_assert(parent != NULL);
strcpy(panel_type->parent_id, parent->idname);
More information about the Bf-blender-cvs
mailing list