From cfc323db26c926791a2afd1e8bc2aae8828ef6bb Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 18 Feb 2019 10:28:34 +0300 Subject: [PATCH] comctl32/updown: Make sure buttons rectangles are consistent with each other. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/updown.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dlls/comctl32/updown.c b/dlls/comctl32/updown.c index 8dec7a4807a..a48f1e437ca 100644 --- a/dlls/comctl32/updown.c +++ b/dlls/comctl32/updown.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -170,13 +171,16 @@ static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr) * rect - will hold the rectangle * arrow - FLAG_INCR to get the "increment" rect (up or right) * FLAG_DECR to get the "decrement" rect (down or left) - * If both flags are present, the envelope is returned. */ -static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, int arrow) +static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, unsigned int arrow) { HTHEME theme = GetWindowTheme (infoPtr->Self); const int border = theme ? DEFAULT_BUDDYBORDER_THEMED : DEFAULT_BUDDYBORDER; const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER; + int size; + + assert(arrow && (arrow & (FLAG_INCR | FLAG_DECR)) != (FLAG_INCR | FLAG_DECR)); + GetClientRect (infoPtr->Self, rect); /* @@ -200,21 +204,20 @@ static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, int arr /* * We're calculating the midpoint to figure-out where the - * separation between the buttons will lay. We make sure that we - * round the uneven numbers by adding 1. + * separation between the buttons will lay. */ if (infoPtr->dwStyle & UDS_HORZ) { - int len = rect->right - rect->left + 1; /* compute the width */ + size = (rect->right - rect->left) / 2; if (arrow & FLAG_INCR) - rect->left = rect->left + len/2; - if (arrow & FLAG_DECR) - rect->right = rect->left + len/2 - (theme ? 0 : 1); + rect->left = rect->right - size; + else if (arrow & FLAG_DECR) + rect->right = rect->left + size; } else { - int len = rect->bottom - rect->top + 1; /* compute the height */ + size = (rect->bottom - rect->top) / 2; if (arrow & FLAG_INCR) - rect->bottom = rect->top + len/2 - (theme ? 0 : 1); - if (arrow & FLAG_DECR) - rect->top = rect->top + len/2; + rect->bottom = rect->top + size; + else if (arrow & FLAG_DECR) + rect->top = rect->bottom - size; } }