summaryrefslogtreecommitdiffstats
path: root/src/canvas/widgets/basic_table_arrows.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2021-04-23 23:13:42 -0400
committerGitHub <noreply@github.com>2021-04-23 23:13:42 -0400
commitd4a18aea759818989acd18295618063155e6a2b9 (patch)
tree0d785a3774c813d0fb2086dc8ed5c0d3aa16fd9e /src/canvas/widgets/basic_table_arrows.rs
parentfcc478a1eb978c826ac416399813df7cdc6b94b2 (diff)
bug: Fix mouse hitboxes (#459)
Fixes the mouse hitbox checks overextending by 1. Also reverts the bandaid fix done for #458.
Diffstat (limited to 'src/canvas/widgets/basic_table_arrows.rs')
-rw-r--r--src/canvas/widgets/basic_table_arrows.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/canvas/widgets/basic_table_arrows.rs b/src/canvas/widgets/basic_table_arrows.rs
index e7f769a8..6ab51124 100644
--- a/src/canvas/widgets/basic_table_arrows.rs
+++ b/src/canvas/widgets/basic_table_arrows.rs
@@ -136,18 +136,28 @@ impl BasicTableArrows for Painter {
);
if app_state.should_get_widget_bounds() {
+ // Some explanations for future readers:
+ // - The "height" as of writing of this entire widget is 2. If it's 1, it occasionally doesn't draw.
+ // - As such, the buttons are only on the lower part of this 2-high widget.
+ // - So, we want to only check at one location, the `draw_loc.y + 1`, and that's it.
+ // - But why is it "+2" then? Well, it's because I have a REALLY ugly hack
+ // for mouse button checking, since most button checks are of the form `(draw_loc.y + draw_loc.height)`,
+ // and the same for the x and width. Unfortunately, if you check using >= and <=, the outer bound is
+ // actually too large - so, we assume all of them are one too big and check via < (see
+ // https://github.com/ClementTsang/bottom/pull/459 for details).
+ // - So in other words, to make it simple, we keep this to a standard and overshoot by one here.
if let Some(basic_table) = &mut app_state.basic_table_widget_state {
basic_table.left_tlc =
- Some((margined_draw_loc[0].x - 1, margined_draw_loc[0].y + 1));
+ Some((margined_draw_loc[0].x, margined_draw_loc[0].y + 1));
basic_table.left_brc = Some((
- margined_draw_loc[0].x + margined_draw_loc[0].width - 1,
- margined_draw_loc[0].y + 1,
+ margined_draw_loc[0].x + margined_draw_loc[0].width,
+ margined_draw_loc[0].y + 2,
));
basic_table.right_tlc =
- Some((margined_draw_loc[2].x - 1, margined_draw_loc[2].y + 1));
+ Some((margined_draw_loc[2].x, margined_draw_loc[2].y + 1));
basic_table.right_brc = Some((
- margined_draw_loc[2].x + margined_draw_loc[2].width - 1,
- margined_draw_loc[2].y + 1,
+ margined_draw_loc[2].x + margined_draw_loc[2].width,
+ margined_draw_loc[2].y + 2,
));
}
}