fix: panel interaction hitbox code

This commit is contained in:
Kiana Sheibani 2025-11-11 00:32:48 -05:00
parent f62e017536
commit e82bdbc9a2
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -21,29 +21,32 @@ CustomMouseArea {
property bool dashboardShortcutActive property bool dashboardShortcutActive
anchors.fill: parent anchors.fill: parent
// HACK: Fixes weird pixel alignment issues that drop mouse events
anchors.rightMargin: -1
anchors.bottomMargin: -1
hoverEnabled: true hoverEnabled: true
function withinPanelWidth(panel: Item, x: real): bool { function withinPanelWidth(panel: Item, x: real): bool {
const panelX = panel.x; const panelX = panel.x + Config.border.thickness;
return x >= panelX - Config.border.rounding && x <= panelX + panel.width + Config.border.rounding; return x >= panelX - Config.border.rounding && x <= panelX + panel.width + Config.border.rounding;
} }
function withinPanelHeight(panel: Item, y: real): bool { function withinPanelHeight(panel: Item, y: real): bool {
const panelY = panel.y; const panelY = panel.y + Config.bar.height;
return y >= panelY + Config.bar.height - Config.border.rounding return y >= panelY - Config.border.rounding && y <= panelY + panel.height + Config.border.rounding;
&& y <= panelY + panel.height + Config.bar.height + Config.border.rounding;
} }
function inBottomPanel(panel: Item, x: real, y: real): bool { function inBottomPanel(panel: Item, x: real, y: real): bool {
return y > root.height - Config.border.thickness - panel.height - Config.border.rounding && withinPanelWidth(panel, x); return y > panel.y + Config.bar.height && withinPanelWidth(panel, x);
} }
function inLeftPanel(panel: Item, x: real, y: real): bool { function inLeftPanel(panel: Item, x: real, y: real): bool {
return x < Config.border.thickness + panel.x + panel.width && withinPanelHeight(panel, y); return x < panel.x + panel.width + Config.border.thickness && withinPanelHeight(panel, y);
} }
function inRightPanel(panel: Item, x: real, y: real): bool { function inRightPanel(panel: Item, x: real, y: real): bool {
return x > Config.border.thickness + panel.x && withinPanelHeight(panel, y); return x > panel.x + Config.border.thickness && withinPanelHeight(panel, y);
} }
// Handling Mouse Input // Handling Mouse Input