cloud storage client
git clone https://git.lucas.co/cce-cloud.git
refactor: JsonControl grows an inherent take_click (6bd value shrink)
take_click left WidgetHost; the two button-gated drain sites match the
Button variant directly instead of going through as_dyn_mut.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N4ajhvVZtyEEEus9bodsj3
src/json_layout.rs | 12 +++++++++++-
src/main.rs | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/json_layout.rs b/src/json_layout.rs
index cdbf4cf..62adf9a 100644
--- a/src/json_layout.rs
+++ b/src/json_layout.rs
@@ -79,6 +79,16 @@ impl JsonControl {
JsonControl::Slider(w) => w,
}
}
+
+ /// Drain the one-shot click flag (6bd value shrink — `take_click` left `WidgetHost`,
+ /// the drains are concrete `Adapted` methods). Only buttons carry one, and both call
+ /// sites already gate on the button widget type.
+ pub fn take_click(&mut self) -> bool {
+ match self {
+ JsonControl::Button(w) => w.take_click(),
+ _ => false,
+ }
+ }
}
pub struct JsonWidget {
@@ -484,7 +494,7 @@ impl JsonLayoutWidget {
if w.widget_type == "button" {
// take_click is an WidgetHost method; the Phase 5 Button is Adapted, so call it
// on the box directly rather than through a concrete downcast.
- if w.target_page.is_some() && w.widget.as_dyn_mut().take_click() {
+ if w.target_page.is_some() && w.widget.take_click() {
page_switch = Some(w.target_page.unwrap());
}
}
diff --git a/src/main.rs b/src/main.rs
index c83e37c..130b158 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1823,7 +1823,7 @@ impl PointerHandler for AppState {
for w in &mut jl.widgets {
// take_click is an WidgetHost method; Phase 5 Buttons are
// Adapted, so ask the box directly.
- if w.widget_type == "button" && w.widget.as_dyn_mut().take_click() {
+ if w.widget_type == "button" && w.widget.take_click() {
clicked_btn_id = Some(w.id.clone());
break;
}