[Bf-blender-cvs] [4b8c830] ui-align-rework: Fix (hack around :| ) the one-pixel issue with stiched but not aligned to LEFT/TOP buttons.

Bastien Montagne noreply at git.blender.org
Thu Oct 22 16:32:27 CEST 2015


Commit: 4b8c830ffcc0382c5082381b601ba326b353b5e3
Author: Bastien Montagne
Date:   Thu Oct 22 16:19:09 2015 +0200
Branches: ui-align-rework
https://developer.blender.org/rB4b8c830ffcc0382c5082381b601ba326b353b5e3

Fix (hack around :| ) the one-pixel issue with stiched but not aligned to LEFT/TOP buttons.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_widgets.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index ba3e3a6..29fec09 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -203,6 +203,12 @@ enum {
 	UI_BUT_ALIGN_RIGHT       = (1 << 16),
 	UI_BUT_ALIGN_DOWN        = (1 << 17),
 	UI_BUT_ALIGN             = (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN),
+
+	/* Warning - HACK! Needed for buttons which are not TOP/LEFT aligned, but have some top/left corner stiched to some
+	 *                 other TOP/LEFT-aligned button, because of 'corrective' hack in widget_roundbox_set()... */
+	UI_BUT_ALIGN_STITCH_TOP  = (1 << 18),
+	UI_BUT_ALIGN_STITCH_LEFT = (1 << 19),
+	UI_BUT_ALIGN_ALL         = (UI_BUT_ALIGN | UI_BUT_ALIGN_STITCH_TOP | UI_BUT_ALIGN_STITCH_LEFT),
 };
 
 /* scale fixed button widths by this to account for DPI */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b31e3a8..54e791d 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3034,11 +3034,11 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
 			delta = max_ff(fabsf(*butal->borders[side] - *butal_other->borders[side_opp]), FLT_MIN);
 			if (delta < max_delta) {
 				/* We are only interested in neighbors that are at least as close as already found ones. */
-				if ((delta <= butal->dists[side]) || (delta < butal_other->dists[side_opp])) {
+				if (delta <= butal->dists[side]) {
 					const bool butal_can_align = ui_but_can_align(butal->but);
 					const bool butal_other_can_align = ui_but_can_align(butal_other->but);
 
-					if ((delta < butal->dists[side]) || (delta < butal_other->dists[side_opp])) {
+					if (delta < butal->dists[side]) {
 						/* We found a closer neighbor.
 						 * If both buttons are alignable, we set them as each other neighbors.
 						 * Else, we have an unalignable one, we need to reset the other's matching neighbor to NULL
@@ -3140,6 +3140,13 @@ static void block_align_stitch_neighbors(
 			*butal_neighbor->borders[side_opp] = co;
 			butal_neighbor->dists[side_opp] = 0.0f;
 		}
+		/* See definition of UI_BUT_ALIGN_STITCH_LEFT/TOP for reason of this... */
+		else if (side == LEFT) {
+			butal->but->drawflag |= UI_BUT_ALIGN_STITCH_LEFT;
+		}
+		else if (side == TOP) {
+			butal->but->drawflag |= UI_BUT_ALIGN_STITCH_TOP;
+		}
 		*butal->borders[side] = co;
 		butal->dists[side] = 0.0f;
 		/* Clearing one of the 'flags pair' here should be enough to prevent this loop running on
@@ -3183,7 +3190,7 @@ void ui_block_align_calc(uiBlock *block)
 	/* First loop: we count number of buttons belonging to an align group, and clear their align flag. */
 	for (but = block->buttons.first; but; but = but->next) {
 		/* Clear old align flags. */
-		but->drawflag &= ~UI_BUT_ALIGN;
+		but->drawflag &= ~UI_BUT_ALIGN_ALL;
 
 		if (but->alignnr == 0) {
 			continue;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 38cb71a..e6c19ed 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3548,9 +3548,9 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
 	if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) {
 
 		/* ui_block_position has this correction too, keep in sync */
-		if (but->drawflag & UI_BUT_ALIGN_TOP)
+		if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP))
 			rect->ymax += U.pixelsize;
-		if (but->drawflag & UI_BUT_ALIGN_LEFT)
+		if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT))
 			rect->xmin -= U.pixelsize;
 		
 		switch (but->drawflag & UI_BUT_ALIGN) {




More information about the Bf-blender-cvs mailing list