mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
Merge branch 'red/rr-ribbon-w2' into area/ribbon-fw
This commit is contained in:
@@ -14,7 +14,7 @@ use egui::{Context, Id, Response, Ui, Vec2};
|
||||
/// `changed` is `value_changed` of the pass's events.
|
||||
pub(crate) fn before_finish(core: &mut CxCore<'_>, activated: bool, injected: Option<FireSource>, changed: bool) {
|
||||
let by_key = activated && core.activation.is_some_and(|activation| activation.by_key);
|
||||
response::rewrite_clicks(&mut core.response, by_key || core.part_clicked, core.command.is_some());
|
||||
response::rewrite_clicks(&mut core.response, by_key || core.part_clicked, core.command.is_some() && activated);
|
||||
if changed {
|
||||
response::mark_changed(&mut core.response);
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ pub(crate) fn press_flags(response: &mut Response, view: PressView) {
|
||||
|
||||
/// Rewrites the click flags of the root's `Response` at step 17: egui's fake click on Enter, Space or AccessKit
|
||||
/// `Click` is cleared, and set again only when the pipeline activated the component by key or by an AccessKit click on a part. A command-bound
|
||||
/// component reports no click, because the command fires instead.
|
||||
pub(crate) fn rewrite_clicks(response: &mut Response, activated_by_key: bool, command_bound: bool) {
|
||||
/// component reports no click on a pass where its command fired, because the command fires instead.
|
||||
pub(crate) fn rewrite_clicks(response: &mut Response, activated_by_key: bool, command_fired: bool) {
|
||||
response.flags.remove(Flags::FAKE_PRIMARY_CLICKED);
|
||||
if activated_by_key {
|
||||
response.flags.insert(Flags::FAKE_PRIMARY_CLICKED);
|
||||
}
|
||||
if command_bound {
|
||||
if command_fired {
|
||||
response.flags.remove(Flags::CLICKED | Flags::FAKE_PRIMARY_CLICKED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,8 +233,10 @@ fn click_and_stay(fixture: &mut Fixture) {
|
||||
#[story(ToggleButton<'static>, covers = [], drive = Drive::Custom(click_and_stay), title = "Clicked under the pointer")]
|
||||
fn toggle_button_clicked_under_pointer(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let shown = ToggleButton::new("Snap to grid", Bind::bound(data.value("snap_hover", false))).icon(IconId::new("eye")).show(ui);
|
||||
*data.value("clicked_over", false) = shown.hover.clicked;
|
||||
shown.into()
|
||||
// The hold is the component's own state, which a measuring run does not carry: the story words it in its readout,
|
||||
// not in its data, which the purity probe compares.
|
||||
let clicked = shown.hover.clicked;
|
||||
StoryOutput::from(shown).readout(if clicked { "Clicked, pointer still over" } else { "Not clicked" })
|
||||
}
|
||||
|
||||
#[story(ToggleButton<'static>, covers = [Mixed], drive = Drive::Never)]
|
||||
|
||||
Reference in New Issue
Block a user