diff --git a/examples/slider_header.rs b/examples/slider_header.rs index 3db77882..18845257 100644 --- a/examples/slider_header.rs +++ b/examples/slider_header.rs @@ -1,5 +1,7 @@ //! Sliders with a label and a readout above the track, at the default, `sm` -//! and `xs` sizes; each readout is edited as text. +//! and `xs` sizes; each readout is edited as text. Then a slider whose +//! readout types past its track, and a number edited the same way with no +//! track. #[path = "common/mod.rs"] mod common; @@ -12,6 +14,8 @@ pub struct Levels { pub volume: f64, pub brightness: f64, pub bass: f64, + pub gain: f64, + pub trim: f64, } impl Default for Levels { @@ -20,6 +24,8 @@ impl Default for Levels { volume: 40.0, brightness: 75.0, bass: 20.0, + gain: -20.0, + trim: 0.0, } } } @@ -62,6 +68,21 @@ pub fn layout<'f>(b: &mut Builder<'_, 'f, Levels>, levels: &'f Levels) { .editable(|text| text.trim().parse().ok()) .on_change(|app: &mut Levels, v| app.bass = v); }); + s.slider("gain", levels.gain, -60.0..=0.0) + .label("Gain") + .readout(|v| format!("{v:.0} dB")) + .editable(|text| text.trim().trim_end_matches("dB").trim().parse().ok()) + .typed_range(-380.0..=380.0) + .on_change(|app: &mut Levels, v| app.gain = v); + s.div(tw().flex().items_center().justify_between(), |s| { + s.text(tw(), "Trim"); + s.number("trim", levels.trim, -12.0..=12.0) + .format(|v| format!("{v:+.1} dB")) + .editable(|text| text.trim().trim_end_matches("dB").trim().parse().ok()) + .step(Step::new(0.5)) + .named("Trim") + .on_change(|app: &mut Levels, v| app.trim = v); + }); }, ); } diff --git a/src/owned/mod.rs b/src/owned/mod.rs index 11018fa7..a458b6ef 100644 --- a/src/owned/mod.rs +++ b/src/owned/mod.rs @@ -50,6 +50,7 @@ mod number_field; pub(crate) mod options; mod progress; mod radio; +mod readout; mod segmented; mod select; mod slider; @@ -81,6 +82,7 @@ pub(crate) use options::Gate; pub use options::IntoTip; pub use progress::ProgressChain; pub use radio::RadioGroupChain; +pub use readout::NumberChain; pub use segmented::{Cell, SegmentedChain, SegmentedRows}; pub use select::SelectChain; pub use slider::SliderChain; diff --git a/src/owned/readout.rs b/src/owned/readout.rs new file mode 100644 index 00000000..fe85e58f --- /dev/null +++ b/src/owned/readout.rs @@ -0,0 +1,382 @@ +//! A number shown as text that a click edits: the readout of a slider's +//! header and the standalone [`NumberChain`]. One implementation serves both. + +use std::fmt::Debug; +use std::hash::Hash; +use std::rc::Rc; + +use egui::{Role, Ui}; + +use super::number::{Edit, Edits, Step, ValueRange}; +use super::number_field::Session; +use super::{ + Content, Enablement, FieldBoxChain, TipContent, described, painted, tip, tipped_whole, +}; +use crate::builder::Slot; +use crate::contract::{Colors, Size}; +use crate::focus::{Autofocus, Select}; +use crate::input_trace::{self, Shown}; +use crate::prim::text_field::{self, Field, Opening}; +use crate::{Builder, Tw, tw}; + +#[derive(Clone, Copy, Debug, Hash)] +enum Part { + Readout, + Field, +} + +pub(super) type Format = Rc String>; +pub(super) type Parse = Rc Option>; +pub(super) type Set = Rc; + +/// The narrowest the readout's field opens, so a short value can be typed +/// over. +const MIN_FIELD: f32 = 48.0; + +/// A readout as its owner configured it. +pub(super) struct Readout { + pub(super) value: f64, + pub(super) format: Option, + /// Editable when it has one. + pub(super) parse: Option, + pub(super) step: Step, + /// Where the step's lattice starts: a slider's track start. + pub(super) origin: f64, + /// The range a typed value reaches. + pub(super) reach: ValueRange, + pub(super) name: String, + pub(super) enablement: Enablement, + /// Its text classes: size and, for a slider's, colour. + pub(super) text: Tw, + pub(super) paint: Option, + pub(super) size: Size, +} + +impl Readout { + fn shown(&self) -> String { + self.format.as_ref().map_or_else( + || format!("{:.*}", self.step.decimals(), self.value), + |format| format(self.value), + ) + } + + /// Builds the readout under `Part::Readout`: its text, a button that + /// opens it while it is editable, or the field it opens into. + pub(super) fn show(self, b: &mut Builder<'_, '_, A>, set: Set, edits: Edits) { + let shown = self.shown(); + let Self { + value, + parse, + step, + origin, + reach, + name, + enablement, + text, + paint, + size, + .. + } = self; + let style = b.style().clone(); + let classes = match paint { + Some(colors) => painted(text, colors), + None => text, + } + .tabular_nums() + .shrink_0(); + let Some(parse) = parse else { + b.div_id(Part::Readout, classes, |b| b.text(tw(), shown)); + return; + }; + let editing = b.id_of(Part::Readout).with("editing"); + let session = Session::of(editing); + let accept = move |text: &str| { + parse(text).map(|number| step.snap_from(origin, reach.clamp(number), reach)) + }; + if session.typed(b.ctx()).is_none() { + let classes = enablement.apply(classes.sense_click(), &style); + let label = format!("Edit {name}"); + let current = shown.clone(); + b.div_id(Part::Readout, classes, |b| b.text(tw(), shown)) + .announces(Role::Button) + .draw(move |app, ui| { + let response = described(ui, Role::Button, None, label.trim(), &None); + let opened = response.clicked().then(|| { + let width = response.rect.width(); + let opening = opening_of(ui, &response, ¤t); + session.open(app, ui.ctx(), ¤t, &edits); + ui.data_mut(|data| { + data.insert_temp(editing.with("width"), width); + data.insert_temp(editing.with("opening"), opening); + }); + opening + }); + let decision = match opened { + Some(Opening::All) => "open, select all", + Some(Opening::Caret(_) | Opening::Kept) => "open, caret", + None => "none", + }; + input_trace::pointer( + ui, + editing, + label.trim(), + Shown::Text, + &response, + decision, + ); + }); + return; + } + let input = *style.input.sizes.lookup(b.ctx(), size); + let border = style.input.look.border_width; + let field = Field::singleline("").sized(size).inset(); + let measured = field.clone(); + let slot = b.slot(&Part::Readout); + let shown_width = b + .ctx() + .data(|data| data.get_temp::(editing.with("width"))) + .unwrap_or(0.0); + let outset = input.padding.x + border; + let width = shown_width.max(MIN_FIELD) + 2.0 * outset; + // The box grows past the readout's edge so its text stays where the readout drew it. + FieldBoxChain::new(b.reborrow(), slot) + .size(size) + .classes( + tw().w_px(width) + .mr(-outset / 4.0) + .px(0.0) + .shrink_0() + .tabular_nums(), + ) + .children(|s| { + let leaf = tw().w_full().h_full().text_right(); + s.leaf(Part::Field, leaf, move |m| { + text_field::measure(m, &measured) + }) + .draw_widgets(move |app, ui| { + let mut text = session.typed(ui.ctx()).unwrap_or_default(); + let response = text_field::show(ui, &mut text, &field); + Autofocus::OnAppear(Select::None).apply(ui.ctx(), &response); + let opening = response.gained_focus().then(|| { + ui.data(|data| data.get_temp(editing.with("opening"))) + .unwrap_or(Opening::All) + }); + let decision = text_field::select_number(ui, &response, &text, opening); + if input_trace::enabled() { + let label = format!("Edit {name}"); + input_trace::pointer( + ui, + editing, + label.trim(), + Shown::Field, + &response, + decision, + ); + } + if response.changed() { + session.keep(ui.ctx(), &text); + } + if response.lost_focus() { + session.close(app, ui, (&text, value), &accept, (&edits, &*set)); + } + }); + }); + } +} + +/// Where a click on the readout puts the field's caret: where it landed. +/// The keyboard opens it with the whole value selected, as Tab does. +fn opening_of(ui: &Ui, response: &egui::Response, shown: &str) -> Opening { + let at = response + .interact_pointer_pos() + .filter(|_| response.clicked_by(egui::PointerButton::Primary)); + let Some(at) = at else { + return Opening::All; + }; + let style = crate::draw::node_text(ui); + let leaf = crate::measure::TextLeaf::plain(ui.ctx(), shown, &style); + let galley = ui.ctx().fonts_mut(|fonts| leaf.editing_galley(fonts, None)); + Opening::Caret(galley.cursor_from_pos(at - response.rect.min)) +} + +/// TODO(prose): a number shown as text, which a click edits when it is +/// [`editable`](Self::editable): the readout of a slider, without the track. +/// Start one with [`Builder::number`] and finish it with +/// [`on_change`](Self::on_change), or [`add`](Self::add) for one that only +/// shows the value. +/// +/// It takes the colour of the text around it. +/// +/// ``` +/// use eggshell_ui::Builder; +/// +/// struct App { gain: f64 } +/// +/// fn view(b: &mut Builder<'_, '_, App>, app: &App) { +/// b.number("gain", app.gain, -380.0..=380.0) +/// .format(|v| format!("{v:.1} dB")) +/// .editable(|text| text.trim_end_matches("dB").trim().parse().ok()) +/// .named("Gain") +/// .on_change(|app, v| app.gain = v); +/// } +/// ``` +#[must_use = "a number is not added until you call `.on_change(..)` or `.add()`"] +pub struct NumberChain<'a, 'f, A> { + b: Builder<'a, 'f, A>, + slot: Slot, + value: f64, + range: ValueRange, + step: Step, + format: Option, + parse: Option, + name: Option, + tooltip: TipContent, + classes: Tw, + enablement: Enablement, + size: Option, + edits: Edits, +} + +impl<'b, 'f, A: 'static> Builder<'b, 'f, A> { + /// TODO(prose): `value` within `range`, shown as text; see [`NumberChain`]. + pub fn number( + &mut self, + key: K, + value: f64, + range: impl Into, + ) -> NumberChain<'_, 'f, A> { + NumberChain { + slot: self.slot(&key), + b: self.reborrow(), + value, + range: range.into(), + step: Step::ONE, + format: None, + parse: None, + name: None, + tooltip: None, + classes: tw(), + enablement: Enablement::Enabled, + size: None, + edits: Edits::default(), + } + } +} + +impl NumberChain<'_, '_, A> { + /// TODO(prose): the value as `format` writes it; the step's decimals until then. + pub fn format(mut self, format: impl Fn(f64) -> String + 'static) -> Self { + self.format = Some(Rc::new(format)); + self + } + + /// TODO(prose): a click edits the value as text that `parse` reads. Enter + /// or leaving the field commits it, clamped to the range and snapped to + /// the step; Escape reverts it. + pub fn editable(mut self, parse: impl Fn(&str) -> Option + 'static) -> Self { + self.parse = Some(Rc::new(parse)); + self + } + + /// TODO(prose): the distance between the values a typed one snaps to. + pub fn step(mut self, step: Step) -> Self { + self.step = step; + self + } + + /// The accessible name, the equivalent of `aria-label`. + pub fn named(mut self, name: impl Into) -> Self { + self.name = Some(name.into()); + self + } + + /// Classes merged over its own, such as its width or alignment; the + /// later class wins ([`Tw::merge`]). + pub fn classes(mut self, classes: Tw) -> Self { + self.classes = self.classes.merge(classes); + self + } + + /// Shown while the pointer hovers it, also when it is disabled. + pub fn tooltip(mut self, text: impl Into) -> Self { + self.tooltip = Some(Content::Text(text.into())); + self + } + + /// Whether it takes input. + pub fn enablement(mut self, enablement: impl Into) -> Self { + self.enablement = enablement.into(); + self + } + + /// TODO(prose): the size of the field it opens into, over the one the subtree inherits. + pub fn size(mut self, size: Size) -> Self { + self.size = Some(size); + self + } + + /// Runs `then` as each edit begins and ends (see [`Edit`]): Began as it + /// opens, Ended as it closes, the value set between. + pub fn on_edit(mut self, then: impl Fn(&mut A, Edit) + 'static) -> Self { + self.edits.set(then); + self + } + + /// Adds it. `set` runs with the value typed in it. + #[track_caller] + pub fn on_change(self, set: impl Fn(&mut A, f64) + 'static) { + self.finish(Rc::new(set)); + } + + /// Adds it, showing the value only. + #[track_caller] + pub fn add(mut self) { + self.parse = None; + self.finish(Rc::new(|_: &mut A, _| {})); + } + + #[track_caller] + fn finish(self, set: Set) { + let Self { + mut b, + slot, + value, + range, + step, + format, + parse, + name, + tooltip, + classes, + enablement, + size, + edits, + } = self; + let value = range.checked(b.ctx(), slot.id, value); + let tooltip = tip(&mut b, slot.id, tooltip); + let enablement = b.enablement_of(enablement); + let readout = Readout { + value, + format, + parse, + step, + origin: range.start(), + reach: range, + name: name.unwrap_or_default(), + enablement, + text: tw(), + paint: None, + size: b.size_of(size), + }; + let style = b.style().clone(); + let wrapper = enablement + .fade(tw().flex().items_center(), &style) + .merge(classes); + let wrapper = match tooltip { + Some(_) => wrapper.sense_hover(), + None => wrapper, + }; + b.div_id_with(&slot, wrapper, |b| readout.show(b, set, edits)) + .draw(move |_, ui| tipped_whole(ui, &tooltip)); + } +} diff --git a/src/owned/slider.rs b/src/owned/slider.rs index dc95ac22..7b91ace1 100644 --- a/src/owned/slider.rs +++ b/src/owned/slider.rs @@ -5,20 +5,18 @@ use std::fmt::Debug; use std::hash::Hash; use std::rc::Rc; -use egui::{Key, Rect, Role, Ui, WidgetInfo}; +use egui::{Key, Rect, Ui, WidgetInfo}; use super::number::{self, Edit, Edits, Step, ValueRange}; -use super::number_field::Session; +use super::readout::{Format, Parse, Readout, Set}; use super::{ - Enablement, FieldBoxChain, Gate, IntoTip, OnResponse, described, options, painted, text_sized, - tip_describes, tipped_whole, + Enablement, Gate, IntoTip, OnResponse, options, painted, text_sized, tip_describes, + tipped_whole, }; use crate::builder::Slot; use crate::contract::{Colors, Size}; use crate::finite::clamp; use crate::focus::{Autofocus, Select}; -use crate::input_trace::{self, Shown}; -use crate::prim::text_field::{self, Field, Opening}; use crate::{Builder, NodeUi as _, Tw, tw}; #[derive(Clone, Copy, Debug, Hash)] @@ -26,8 +24,6 @@ enum Part { Box, Header, Label, - Readout, - Field, Track, Thumb, } @@ -67,10 +63,6 @@ pub struct SliderChain<'a, 'f, A> { autofocus: Autofocus, } -type Format = Rc String>; -type Parse = Rc Option>; -type Set = Rc; - /// What a slider says above its track. #[derive(Clone, Default)] struct Header { @@ -501,8 +493,6 @@ impl Header { } } -const MIN_READOUT: f32 = 48.0; - /// The row above the track. struct Row { header: Header, @@ -517,21 +507,6 @@ struct Row { size: Size, } -/// Where a click on the readout puts the field's caret: where it landed. -/// The keyboard opens it with the whole value selected, as Tab does. -fn opening_of(ui: &Ui, response: &egui::Response, shown: &str) -> Opening { - let at = response - .interact_pointer_pos() - .filter(|_| response.clicked_by(egui::PointerButton::Primary)); - let Some(at) = at else { - return Opening::All; - }; - let style = crate::draw::node_text(ui); - let leaf = crate::measure::TextLeaf::plain(ui.ctx(), shown, &style); - let galley = ui.ctx().fonts_mut(|fonts| leaf.editing_galley(fonts, None)); - Opening::Caret(galley.cursor_from_pos(at - response.rect.min)) -} - impl Row { fn show(self, b: &mut Builder<'_, '_, A>, set: Set, edits: Edits) { let Self { @@ -539,7 +514,7 @@ impl Row { value, step, range, - typed: reach, + typed, name, enablement, colors: (label, readout), @@ -548,20 +523,12 @@ impl Row { } = self; let style = b.style().clone(); let input = *style.input.sizes.lookup(b.ctx(), size); - let border = style.input.look.border_width; let row = tw().flex().items_center().justify_between().w_full(); let row = if header.parse.is_some() { row.min_h_px(input.height) } else { row }; - let shown = header.readout.as_ref().map_or_else( - || format!("{value:.*}", step.decimals()), - |format| format(value), - ); - let editing = b.id_of(Part::Readout).with("editing"); - let session = Session::of(editing); - let typed = session.typed(b.ctx()); b.div_id(Part::Header, row, |b| { match &header.label { Some(label_text) => { @@ -573,111 +540,20 @@ impl Row { if header.readout.is_none() && header.parse.is_none() { return; } - let classes = painted(text.clone(), readout).tabular_nums().shrink_0(); - let Some(parse) = header.parse else { - b.div_id(Part::Readout, classes, |b| b.text(tw(), shown)); - return; - }; - let accept = move |text: &str| { - parse(text).map(|number| step.snap_from(range.start(), reach.clamp(number), reach)) - }; - match typed { - None => { - let classes = enablement.apply(classes.sense_click(), &style); - let label = format!("Edit {name}"); - let current = shown.clone(); - let open_edits = edits.clone(); - b.div_id(Part::Readout, classes, |b| b.text(tw(), shown)) - .announces(Role::Button) - .draw(move |app, ui| { - let response = described(ui, Role::Button, None, label.trim(), &None); - let opened = response.clicked().then(|| { - let width = response.rect.width(); - let opening = opening_of(ui, &response, ¤t); - session.open(app, ui.ctx(), ¤t, &open_edits); - ui.data_mut(|data| { - data.insert_temp(editing.with("width"), width); - data.insert_temp(editing.with("opening"), opening); - }); - opening - }); - let decision = match opened { - Some(Opening::All) => "open, select all", - Some(Opening::Caret(_) | Opening::Kept) => "open, caret", - None => "none", - }; - input_trace::pointer( - ui, - editing, - label.trim(), - Shown::Text, - &response, - decision, - ); - }); - } - Some(_) => { - let field = Field::singleline("").sized(size).inset(); - let measured = field.clone(); - let slot = b.slot(&Part::Readout); - let shown_width = b - .ctx() - .data(|data| data.get_temp::(editing.with("width"))) - .unwrap_or(0.0); - let outset = input.padding.x + border; - let width = shown_width.max(MIN_READOUT) + 2.0 * outset; - // The box grows past the row's edge so its text stays where the readout drew it. - FieldBoxChain::new(b.reborrow(), slot) - .size(size) - .classes( - tw().w_px(width) - .mr(-outset / 4.0) - .px(0.0) - .shrink_0() - .tabular_nums(), - ) - .children(|s| { - let leaf = tw().w_full().h_full().text_right(); - s.leaf(Part::Field, leaf, move |m| { - text_field::measure(m, &measured) - }) - .draw_widgets(move |app, ui| { - let mut text = session.typed(ui.ctx()).unwrap_or_default(); - let response = text_field::show(ui, &mut text, &field); - Autofocus::OnAppear(Select::None).apply(ui.ctx(), &response); - let opening = response.gained_focus().then(|| { - ui.data(|data| data.get_temp(editing.with("opening"))) - .unwrap_or(Opening::All) - }); - let decision = - text_field::select_number(ui, &response, &text, opening); - if input_trace::enabled() { - let label = format!("Edit {name}"); - input_trace::pointer( - ui, - editing, - label.trim(), - Shown::Field, - &response, - decision, - ); - } - if response.changed() { - session.keep(ui.ctx(), &text); - } - if response.lost_focus() { - session.close( - app, - ui, - (&text, value), - &accept, - (&edits, &*set), - ); - } - }); - }); - } + Readout { + value, + format: header.readout, + parse: header.parse, + step, + origin: range.start(), + reach: typed, + name, + enablement, + text, + paint: Some(readout), + size, } + .show(b, set, edits); }); } } diff --git a/tests/it/main.rs b/tests/it/main.rs index 93a194ab..cba7f089 100644 --- a/tests/it/main.rs +++ b/tests/it/main.rs @@ -92,6 +92,7 @@ mod named_layouts; mod nested_layouts; mod node_controls; mod notify; +mod number_readout; mod numbers; mod overlay; mod overlay_input; diff --git a/tests/it/number_readout.rs b/tests/it/number_readout.rs new file mode 100644 index 00000000..fa6b204f --- /dev/null +++ b/tests/it/number_readout.rs @@ -0,0 +1,123 @@ +//! `b.number` (#328): the slider's editable readout without the track, +//! through the same implementation. + +use eggshell_ui::owned::{Edit, Enablement, Step}; +use eggshell_ui::{Builder, TextStyle, tw}; +use egui::{Color32, Event, Key, Role, vec2}; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable as _; + +use crate::support::{self, Rig, click_node, focused_node, rect_of, text_color}; + +const INK: Color32 = Color32::from_rgb(20, 40, 60); + +#[derive(Default)] +struct App { + gain: f64, + edits: Vec, + disabled: bool, +} + +fn view(b: &mut Builder<'_, '_, App>, app: &App) { + b.div(tw().flex().flex_col().gap(4.0).p(4.0).text(INK), |b| { + b.number("gain", app.gain, -380.0..=380.0) + .format(|value| format!("{value:.1} dB")) + .editable(|text| text.trim_end_matches("dB").trim().parse().ok()) + .step(Step::new(0.5)) + .named("Gain") + .enablement(Enablement::from(!app.disabled)) + .on_edit(|app: &mut App, edit| app.edits.push(edit)) + .on_change(|app: &mut App, value| app.gain = value); + b.number("shown", 7.0, 0.0..=10.0) + .named("Shown") + .editable(|text| text.parse().ok()) + .add(); + }); +} + +const GAIN: &str = r#"/"gain"/Readout"#; +const SHOWN: &str = r#"/"shown"/Readout"#; + +fn harness_with(app: App) -> Harness<'static, Rig> { + let mut harness = support::harness( + vec2(300.0, 200.0), + TextStyle::new( + eggshell_ui::TextSpec { + size: 14.0, + line_height: 20.0, + family: egui::FontFamily::Proportional, + weight: eggshell_ui::Weight::Normal, + }, + Color32::BLACK, + ), + app, + view, + ); + harness.run_steps(4); + harness +} + +fn type_and(harness: &mut Harness<'_, Rig>, text: &str, key: Key) { + click_node(harness, GAIN); + harness.run_steps(4); + harness.key_press_modifiers(egui::Modifiers::COMMAND, Key::A); + harness.event(Event::Text(text.to_owned())); + harness.run_steps(3); + harness.key_press(key); + harness.run_steps(4); +} + +#[test] +fn it_shows_the_value_as_formatted_in_the_text_colour_around_it() { + let harness = harness_with(App::default()); + assert_eq!(text_color(&harness, rect_of(&harness, GAIN), "0.0 dB"), INK); + assert_eq!(text_color(&harness, rect_of(&harness, SHOWN), "7"), INK); +} + +#[test] +fn enter_commits_a_typed_value_clamped_and_snapped_inside_one_edit() { + let mut harness = harness_with(App::default()); + type_and(&mut harness, "12.3", Key::Enter); + assert_eq!(harness.state().app.gain, 12.5, "snapped to 0.5"); + assert_eq!(harness.state().app.edits, [Edit::Began, Edit::Ended]); + type_and(&mut harness, "900", Key::Enter); + assert_eq!(harness.state().app.gain, 380.0, "clamped"); +} + +#[test] +fn escape_reverts() { + let mut harness = harness_with(App::default()); + type_and(&mut harness, "12", Key::Escape); + assert_eq!(harness.state().app.gain, 0.0); + assert!(focused_node(&harness).is_none(), "the field closed"); +} + +#[test] +fn it_is_a_button_that_opens_a_field() { + let mut harness = harness_with(App::default()); + harness.get_by_role_and_label(Role::Button, "Edit Gain"); + click_node(&mut harness, GAIN); + harness.run_steps(4); + assert_eq!(focused_node(&harness), Some(format!("{GAIN}/Field"))); +} + +#[test] +fn one_added_without_a_parse_only_shows_its_value() { + let mut harness = harness_with(App::default()); + assert!(harness.query_by_label("Edit Shown").is_none()); + click_node(&mut harness, SHOWN); + harness.run_steps(4); + assert!(focused_node(&harness).is_none(), "nothing opens"); +} + +#[test] +fn a_disabled_one_does_not_open() { + let mut harness = harness_with(App { + disabled: true, + ..App::default() + }); + click_node(&mut harness, GAIN); + harness.run_steps(4); + assert!(focused_node(&harness).is_none()); + assert!(harness.state().app.edits.is_empty()); +}