From 46f0280686969e01fb695987c9aa468cb5686a11 Mon Sep 17 00:00:00 2001 From: Surinder Singh Matoo Date: Fri, 13 Sep 2024 02:13:12 +0530 Subject: [PATCH] selection panel hover/pressed state/style --- core/resources/i18n/i18n.json | 2 ++ core/src/egui/selection_panels.rs | 19 ++++++++++++------- core/src/modules/account_manager/estimator.rs | 5 +---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/resources/i18n/i18n.json b/core/resources/i18n/i18n.json index 2ef7372..d4d9e04 100644 --- a/core/resources/i18n/i18n.json +++ b/core/resources/i18n/i18n.json @@ -3219,6 +3219,7 @@ "Faucet": "Faucet", "Fee Rate Estimates": "Fee Rate Estimates", "File Handles": "File Handles", + "File contents": "File contents", "Filename:": "Filename:", "Final Amount:": "Final Amount:", "For decrypting uploaded file please enter wallet secret.": "For decrypting uploaded file please enter wallet secret.", @@ -3236,6 +3237,7 @@ "Import Existing Private Key": "Import Existing Private Key", "Import existing": "Import existing", "Import existing file": "Import existing file", + "Importing Legacy Wallet": "Importing Legacy Wallet", "Importing Wallet": "Importing Wallet", "Importing Wallet File": "Importing Wallet File", "Inbound": "Inbound", diff --git a/core/src/egui/selection_panels.rs b/core/src/egui/selection_panels.rs index c55e323..16d6e9b 100644 --- a/core/src/egui/selection_panels.rs +++ b/core/src/egui/selection_panels.rs @@ -150,19 +150,24 @@ impl SelectionPanel { let _res = add_contents(&mut prepared.content_ui); *min_height = min_height.max(prepared.content_ui.min_rect().height()); prepared.content_ui.set_min_height(*min_height); - let rect = prepared.content_ui.min_rect() + prepared.frame.inner_margin; - if !selected && ui.allocate_rect(rect, Sense::hover()).hovered() { - //prepared.frame = prepared.frame.stroke(hover_stroke); - prepared.frame = prepared.frame.fill(selected_bg).stroke(hover_stroke); + let mut response = prepared.allocate_space(ui).interact(Sense::click()); + + if !selected && response.hovered() { + prepared.frame = prepared.frame.stroke(hover_stroke); + } + + if response.is_pointer_button_down_on() { + let visuals = ui.style().interact(&response); + prepared.frame = prepared.frame.fill(selected_bg).stroke(visuals.bg_stroke); } - let res = prepared.end(ui); + prepared.paint(ui); - let mut response = res.interact(Sense::click()); if response.clicked() && *current_value != self.value { *current_value = self.value; response.mark_changed(); } + response } } @@ -340,7 +345,7 @@ impl SelectionPanels { }; ui.indent_with_size("selection-panels", indent, Box::new(add_contents)) - .response + .inner // response |= ui // .vertical_centered(|ui| (self.build_footer)(ui, current_value)) // .response; diff --git a/core/src/modules/account_manager/estimator.rs b/core/src/modules/account_manager/estimator.rs index 47e5513..d247e2a 100644 --- a/core/src/modules/account_manager/estimator.rs +++ b/core/src/modules/account_manager/estimator.rs @@ -129,10 +129,7 @@ impl<'context> Estimator<'context> { }); } - // if fee_selection.render(ui, &mut self.context.fee_mode).clicked() { - let mode = self.context.fee_mode; - fee_selection.render(ui, &mut self.context.fee_mode); - if mode != self.context.fee_mode { + if fee_selection.render(ui, &mut self.context.fee_mode).clicked() { let bucket = self.context.fee_mode.bucket(); let priority_feerate = (bucket.feerate - 1.0).max(0.0); let total_fees_sompi = (priority_feerate * actual_estimate.aggregate_mass as f64) as u64;