Skip to content

Commit 2d114b9

Browse files
authored
Merge pull request #82 from justnullname/fix-nav-indicator-ui-11110187312669809843
Optimize Edge Navigation Button UI
2 parents 30af299 + 992f45c commit 2d114b9

2 files changed

Lines changed: 26 additions & 23 deletions

File tree

QuickView/UIRenderer.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,9 +2013,10 @@ void UIRenderer::DrawNavIndicators(ID2D1DeviceContext* dc) {
20132013
// Only draw for Arrow mode (0)
20142014
if (g_config.NavIndicator != 0) return;
20152015
const float s = m_uiScale;
2016-
float circleRadius = 20.0f * s;
2017-
float arrowSize = 10.0f * s;
2018-
float strokeWidth = 3.0f * s;
2016+
float circleRadius = 16.0f * s;
2017+
float arrowSize = 8.0f * s;
2018+
float strokeWidth = 2.0f * s;
2019+
float margin = 32.0f * s;
20192020

20202021
ComPtr<ID2D1SolidColorBrush> brushCircle, brushArrow;
20212022
dc->CreateSolidColorBrush(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.5f), &brushCircle);
@@ -2067,18 +2068,16 @@ void UIRenderer::DrawNavIndicators(ID2D1DeviceContext* dc) {
20672068
bool drawn = false;
20682069

20692070
if (g_viewState.EdgeHoverLeft != 0 && leftW > 1.0f) {
2070-
float zoneWidth = leftW * 0.15f;
20712071
float arrowCenterX = (g_viewState.EdgeHoverLeft == -1)
2072-
? (zoneWidth / 2.0f)
2073-
: (splitX - zoneWidth / 2.0f);
2072+
? margin
2073+
: (splitX - margin);
20742074
drawArrow(arrowCenterX, arrowCenterY, g_viewState.EdgeHoverLeft == -1);
20752075
drawn = true;
20762076
}
20772077
if (g_viewState.EdgeHoverRight != 0 && rightW > 1.0f) {
2078-
float zoneWidth = rightW * 0.15f;
20792078
float arrowCenterX = (g_viewState.EdgeHoverRight == -1)
2080-
? (splitX + zoneWidth / 2.0f)
2081-
: (m_width - zoneWidth / 2.0f);
2079+
? (splitX + margin)
2080+
: (m_width - margin);
20822081
drawArrow(arrowCenterX, arrowCenterY, g_viewState.EdgeHoverRight == -1);
20832082
drawn = true;
20842083
}
@@ -2088,9 +2087,8 @@ void UIRenderer::DrawNavIndicators(ID2D1DeviceContext* dc) {
20882087

20892088
if (!g_viewState.EdgeHoverState) return;
20902089

2091-
float zoneWidth = m_width * 0.15f;
20922090
float arrowCenterY = m_height * 0.5f;
2093-
float arrowCenterX = (g_viewState.EdgeHoverState == -1) ? (zoneWidth / 2.0f) : (m_width - zoneWidth / 2.0f);
2091+
float arrowCenterX = (g_viewState.EdgeHoverState == -1) ? margin : (m_width - margin);
20942092
drawArrow(arrowCenterX, arrowCenterY, g_viewState.EdgeHoverState == -1);
20952093
}
20962094

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)