Skip to content

Commit

Permalink
selection panel hover/pressed state/style
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder83singh committed Sep 12, 2024
1 parent a9c1499 commit 46f0280
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions core/resources/i18n/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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",
Expand Down
19 changes: 12 additions & 7 deletions core/src/egui/selection_panels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,24 @@ impl<Value: PartialEq> SelectionPanel<Value> {
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
}
}
Expand Down Expand Up @@ -340,7 +345,7 @@ impl<Value: PartialEq> SelectionPanels<Value> {
};

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;
Expand Down
5 changes: 1 addition & 4 deletions core/src/modules/account_manager/estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 46f0280

Please sign in to comment.