[Bf-blender-cvs] [06f7b6827d0] master: UI: fix panel header contents alignment.

Harley Acheson noreply at git.blender.org
Mon Jan 14 15:31:07 CET 2019


Commit: 06f7b6827d0d74e1ee870b30ddae4f3afb3067ce
Author: Harley Acheson
Date:   Mon Jan 14 15:02:21 2019 +0100
Branches: master
https://developer.blender.org/rB06f7b6827d0d74e1ee870b30ddae4f3afb3067ce

UI: fix panel header contents alignment.

The contents is now properly centered at all zoom levels.

Differential Revision: https://developer.blender.org/D4176

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

M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_panel.c

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

diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index b0136feaa30..0a69ff6e38b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -163,7 +163,7 @@ extern const short ui_radial_dir_to_angle[8];
 
 /* internal panel drawing defines */
 #define PNL_GRID    (UI_UNIT_Y / 5) /* 4 default */
-#define PNL_HEADER  (UI_UNIT_Y + 4) /* 24 default */
+#define PNL_HEADER  (UI_UNIT_Y * 1.2)  /* 24 default */
 
 /* bit button defines */
 /* Bit operations */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 469720c2d30..7fec94b15f7 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -621,11 +621,10 @@ static void ui_draw_panel_dragwidget(uint pos, uint col, const rctf *rect)
 void UI_panel_label_offset(uiBlock *block, int *x, int *y)
 {
 	Panel *panel = block->panel;
-	uiStyle *style = UI_style_get_dpi();
 	const bool is_subpanel = (panel->type && panel->type->parent);
 
-	*x = UI_UNIT_X * 1.1f;
-	*y = (UI_UNIT_Y * 1.1f) + style->panelspace;
+	*x = UI_UNIT_X * 1.0f;
+	*y = UI_UNIT_Y * 1.5f;
 
 	if (is_subpanel) {
 		*x += 5.0f / block->aspect;
@@ -646,9 +645,9 @@ static void ui_draw_aligned_panel_header(
 
 	/* + 0.001f to avoid flirting with float inaccuracy */
 	if (panel->control & UI_PNL_CLOSE)
-		pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f;
+		pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f;
 	else
-		pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
+		pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f;
 
 	/* draw text label */
 	panel_title_color_get(show_background, col_title);
@@ -657,7 +656,7 @@ static void ui_draw_aligned_panel_header(
 	hrect = *rect;
 	if (dir == 'h') {
 		hrect.xmin = rect->xmin + pnl_icons;
-		hrect.ymin += 2.0f / block->aspect;
+		hrect.ymin -= 2.0f / block->aspect;
 		UI_fontstyle_draw(
 		        fontstyle, &hrect, activename, col_title,
 		        &(struct uiFontStyleDraw_Params) { .align = UI_STYLE_TEXT_LEFT, });
@@ -763,7 +762,7 @@ void ui_draw_aligned_panel(
 			col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
 
 			/* itemrect smaller */
-			itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
+			itemrect.xmax = headrect.xmax - (0.2f * UI_UNIT_X);
 			itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
 			itemrect.ymin = headrect.ymin;
 			itemrect.ymax = headrect.ymax;
@@ -835,7 +834,7 @@ void ui_draw_aligned_panel(
 	/* draw collapse icon */
 
 	/* itemrect smaller */
-	itemrect.xmin = titlerect.xmin + 3.0f / block->aspect;
+	itemrect.xmin = titlerect.xmin;
 	itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&titlerect);
 	itemrect.ymin = titlerect.ymin;
 	itemrect.ymax = titlerect.ymax;



More information about the Bf-blender-cvs mailing list