Skip to content

Commit 992f45c

Browse files
committed
ui: adjust navigation indicator margins and hit areas
- Increased the edge margin for navigation buttons from 24px to 32px to ensure they are not too close to the screen edges. - Refactored hover and hit-test calculations (`ComputeEdgeHoverForPane`, `HitTestNavButtonInPane`, and edge hover bounds in `main.cpp`) to use fixed scaled margins (`32.0f * g_uiScale`) and explicit threshold areas (`64.0f * g_uiScale`) instead of dynamic width percentages (`w * 0.15`). - Increased the internal button click radius to 24px (while the visual button radius remains 16px) to expand the interactive hit area toward the window center, solving the issue of buttons being difficult to click.
1 parent f0b072f commit 992f45c

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

QuickView/UIRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ void UIRenderer::DrawNavIndicators(ID2D1DeviceContext* dc) {
20162016
float circleRadius = 16.0f * s;
20172017
float arrowSize = 8.0f * s;
20182018
float strokeWidth = 2.0f * s;
2019-
float margin = 24.0f * s;
2019+
float margin = 32.0f * s;
20202020

20212021
ComPtr<ID2D1SolidColorBrush> brushCircle, brushArrow;
20222022
dc->CreateSolidColorBrush(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.5f), &brushCircle);

QuickView/main.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,9 @@ static int ComputeEdgeHoverForPane(const POINT& pt, const D2D1_RECT_F& paneRect)
11791179
if (w <= 50.0f || h <= 100.0f) return 0;
11801180
if (pt.x < paneRect.left || pt.x > paneRect.right || pt.y < paneRect.top || pt.y > paneRect.bottom) return 0;
11811181

1182-
const bool inHRange = (pt.x < paneRect.left + w * 0.15f) ||
1183-
(pt.x > paneRect.right - w * 0.15f);
1182+
const float edgeMargin = 64.0f * g_uiScale;
1183+
const bool inHRange = (pt.x < paneRect.left + edgeMargin) ||
1184+
(pt.x > paneRect.right - edgeMargin);
11841185
bool inVRange = false;
11851186
if (g_config.NavIndicator == 0) {
11861187
inVRange = (pt.y > paneRect.top + h * 0.20f) && (pt.y < paneRect.bottom - h * 0.20f);
@@ -1189,7 +1190,7 @@ static int ComputeEdgeHoverForPane(const POINT& pt, const D2D1_RECT_F& paneRect)
11891190
}
11901191

11911192
if (inHRange && inVRange) {
1192-
return (pt.x < paneRect.left + w * 0.15f) ? -1 : 1;
1193+
return (pt.x < paneRect.left + edgeMargin) ? -1 : 1;
11931194
}
11941195
return 0;
11951196
}
@@ -1201,20 +1202,21 @@ static int HitTestNavButtonInPane(const POINT& pt, const D2D1_RECT_F& paneRect)
12011202
if (w <= 50.0f || h <= 100.0f) return 0;
12021203
if (pt.x < paneRect.left || pt.x > paneRect.right || pt.y < paneRect.top || pt.y > paneRect.bottom) return 0;
12031204

1204-
const float zoneWidth = w * 0.15f;
12051205
const float centerY = paneRect.top + h * 0.5f;
1206-
const float radius = 20.0f * g_uiScale;
1206+
// The hot area is larger than the visual button (16.0f) to make it easier to click.
1207+
const float radius = 24.0f * g_uiScale;
12071208
const float radiusSq = radius * radius;
1209+
const float margin = 32.0f * g_uiScale;
12081210

12091211
auto hitCircle = [&](float cx) -> bool {
12101212
const float dx = (float)pt.x - cx;
12111213
const float dy = (float)pt.y - centerY;
12121214
return (dx * dx + dy * dy) <= radiusSq;
12131215
};
12141216

1215-
const float leftX = paneRect.left + zoneWidth * 0.5f;
1217+
const float leftX = paneRect.left + margin;
12161218
if (hitCircle(leftX)) return -1;
1217-
const float rightX = paneRect.right - zoneWidth * 0.5f;
1219+
const float rightX = paneRect.right - margin;
12181220
if (hitCircle(rightX)) return 1;
12191221
return 0;
12201222
}
@@ -6002,7 +6004,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
60026004

60036005
int oldState = g_viewState.EdgeHoverState; // Record old state
60046006
if (w > 50 && h > 100) {
6005-
bool inHRange = (pt.x < w * 0.15) || (pt.x > w * 0.85);
6007+
float edgeMargin = 64.0f * g_uiScale;
6008+
bool inHRange = (pt.x < edgeMargin) || (pt.x > w - edgeMargin);
60066009
bool inVRange;
60076010

60086011
if (g_config.NavIndicator == 0) {
@@ -6012,7 +6015,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
60126015
}
60136016

60146017
if (inHRange && inVRange) {
6015-
g_viewState.EdgeHoverState = (pt.x < w * 0.15) ? -1 : 1;
6018+
g_viewState.EdgeHoverState = (pt.x < edgeMargin) ? -1 : 1;
60166019
} else {
60176020
g_viewState.EdgeHoverState = 0;
60186021
}
@@ -6814,7 +6817,8 @@ SKIP_EDGE_NAV:;
68146817
D2D1_RECT_F fullRect = D2D1::RectF(0.0f, 0.0f, (float)w, (float)h);
68156818
inEdgeZone = (HitTestNavButtonInPane(pt, fullRect) != 0);
68166819
} else {
6817-
bool inHRange = (pt.x < w * 0.15) || (pt.x > w * 0.85);
6820+
float edgeMargin = 64.0f * g_uiScale;
6821+
bool inHRange = (pt.x < edgeMargin) || (pt.x > w - edgeMargin);
68186822
bool inVRange = (pt.y > h * 0.30) && (pt.y < h * 0.70);
68196823
inEdgeZone = inHRange && inVRange;
68206824
}
@@ -7129,11 +7133,12 @@ SKIP_EDGE_NAV:;
71297133
direction = HitTestNavButtonInPane(pt, fullRect);
71307134
clickValid = (direction != 0);
71317135
} else {
7132-
bool inHRange = (pt.x < width * 0.15) || (pt.x > width * 0.85);
7136+
float edgeMargin = 64.0f * g_uiScale;
7137+
bool inHRange = (pt.x < edgeMargin) || (pt.x > width - edgeMargin);
71337138
bool inVRange = (pt.y > height * 0.30) && (pt.y < height * 0.70);
71347139
if (inHRange && inVRange) {
71357140
clickValid = true;
7136-
direction = (pt.x < width * 0.15) ? -1 : 1;
7141+
direction = (pt.x < edgeMargin) ? -1 : 1;
71377142
}
71387143
}
71397144

0 commit comments

Comments
 (0)