mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 23:50:13 +00:00
Keep sampler lifecycle conditions in focused helpers
This commit is contained in:
@@ -264,13 +264,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
app.ui.home = None;
|
||||
}
|
||||
let home_showing = crate::menus::home_showing(app);
|
||||
if home_showing || app.session.active().is_none() {
|
||||
// Home and the empty window still advance egui's click history. Observe the same
|
||||
// correction there so it retires after the two ordinary clicks that replace a pick.
|
||||
let id = egui::Id::unique("canvas");
|
||||
begin_ignore_sampler_pointer(ui, id, false);
|
||||
end_ignore_sampler_pointer(ui, id);
|
||||
}
|
||||
observe_hidden_ignore_sampler_pointer(app, ui, home_showing);
|
||||
if home_showing {
|
||||
// No IME owner this pass (`ime_caret_rect` stays None): the end-of-pass observation marks
|
||||
// the context absent and keeps any marked text as typed.
|
||||
@@ -577,6 +571,16 @@ fn end_ignore_sampler_pointer(ui: &Ui, id: egui::Id) {
|
||||
}
|
||||
}
|
||||
|
||||
fn observe_hidden_ignore_sampler_pointer(app: &VectorcraftApp, ui: &Ui, home_showing: bool) {
|
||||
if home_showing || app.session.active().is_none() {
|
||||
// Home and the empty window still advance egui's click history. Observe the same
|
||||
// correction there so it retires after the two ordinary clicks that replace a pick.
|
||||
let id = egui::Id::unique("canvas");
|
||||
begin_ignore_sampler_pointer(ui, id, false);
|
||||
end_ignore_sampler_pointer(ui, id);
|
||||
}
|
||||
}
|
||||
|
||||
/// A sampler press keeps its release, even if its Down completes or its binding expires held.
|
||||
fn input_after_sampler_refresh(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Response, rect: egui::Rect, cancelled: bool) {
|
||||
let consumed = begin_ignore_sampler_pointer(ui, resp.id, cancelled);
|
||||
|
||||
@@ -316,6 +316,13 @@ pub(crate) fn cancel_ignore_sampler(app: &mut VectorcraftApp, restore: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Presets and restored panel settings can turn Ignore Color off without its checkbox.
|
||||
fn cancel_disabled_ignore_sampler(app: &mut VectorcraftApp, params: &Value) {
|
||||
if params["ignoreWhite"] != true {
|
||||
cancel_ignore_sampler(app, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Also runs when the panel is closed: document changes and tool changes end the pick.
|
||||
pub(crate) fn refresh_ignore_sampler(app: &mut VectorcraftApp) -> bool {
|
||||
let Some(s) = app.ui.trace_ignore_sampler.as_ref() else { return false };
|
||||
@@ -1070,10 +1077,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if is_trace || !preview {
|
||||
st.preview_off = !preview;
|
||||
}
|
||||
// Presets and restored panel settings can turn Ignore Color off without its checkbox.
|
||||
if st.params["ignoreWhite"] != true {
|
||||
cancel_ignore_sampler(app, true);
|
||||
}
|
||||
cancel_disabled_ignore_sampler(app, &st.params);
|
||||
if retrace && is_trace && preview {
|
||||
trace(app, ui.ctx(), &mut st);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user