[PATCH] comctl32/updown: Make sure buttons rectangles are consistent with each other.
Nikolay Sivov
nsivov at codeweavers.com
Mon Feb 18 01:28:34 CST 2019
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 8dec7a4807..a48f1e437c 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 <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
@@ -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;
}
}
--
2.20.1
More information about the wine-devel
mailing list