Skip to content

Commit 6b275ef

Browse files
committed
Use half-open hit tests for switch row clamp
Adjacent rows shared the same boundary because in_rect() used closed intervals on both edges, which made the switch-specific nextafterf() workaround necessary. Use half-open rect bounds and clamp the expanded switch hit rect to row_height so boundary ownership is consistent and the switch fix no longer relies on fragile edge adjustment.
1 parent acc0636 commit 6b275ef

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/input.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,11 +1296,9 @@ bool iui_switch(iui_context *ctx,
12961296
/* Expand touch target for accessibility (48dp minimum per MD3) */
12971297
iui_rect_t touch_rect = track_rect;
12981298
iui_expand_touch_target_h(&touch_rect, IUI_SWITCH_TOUCH_TARGET);
1299-
if (touch_rect.height > ctx->layout.height) {
1300-
float touch_bottom =
1301-
nextafterf(ctx->layout.y + ctx->layout.height, ctx->layout.y);
1299+
if (touch_rect.height > ctx->row_height) {
13021300
touch_rect.y = ctx->layout.y;
1303-
touch_rect.height = touch_bottom - touch_rect.y;
1301+
touch_rect.height = ctx->row_height;
13041302
}
13051303

13061304
iui_state_t state = iui_get_component_state(ctx, touch_rect, false);

src/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ static inline iui_vec2 iui_vec2_add(iui_vec2 a, iui_vec2 b)
507507

508508
static inline bool in_rect(const iui_rect_t *rect, iui_vec2 pos)
509509
{
510-
return ((pos.x >= rect->x) && (pos.x <= rect->x + rect->width) &&
511-
(pos.y >= rect->y) && (pos.y <= rect->y + rect->height));
510+
return ((pos.x >= rect->x) && (pos.x < rect->x + rect->width) &&
511+
(pos.y >= rect->y) && (pos.y < rect->y + rect->height));
512512
}
513513

514514
static inline void expand_rect(iui_rect_t *rect, float amount)

0 commit comments

Comments
 (0)