mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge #17444 into the merge queue batch
Honor tooltip preferences in the modern toolbar
This commit is contained in:
commit
693076a375
3 files changed
+34
No files matched your search
@@ -404,6 +404,8 @@ impl Framework {
|
||||
.density(suite_size(session.prefs().interface.density));
|
||||
// Read each frame, so a preference change shows at once.
|
||||
root.canvas_pattern = session.prefs().interface.show_canvas_dots;
|
||||
// Framework tooltips do not consult the egui style delay used by legacy controls.
|
||||
root.tooltips = session.prefs().interface.show_tooltips && session.prefs().tools.show_tooltips;
|
||||
root.values.set(craft::ui::canvas::ShowReadouts(session.prefs().tools.show_transformation_values));
|
||||
// Length fields read the Point/Pica size from the root; each passes its document's pixels
|
||||
// per inch in its own `LengthUnits`.
|
||||
|
||||
@@ -90,3 +90,5 @@ mod shortcut_undo_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod tooltips_off_tests;
|
||||
@@ -0,0 +1,30 @@
|
||||
use egui::accesskit::Role;
|
||||
use egui::{Pos2, vec2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
use crate::app::framework::BuildApp as _;
|
||||
|
||||
#[test]
|
||||
fn either_show_tooltips_preference_controls_the_toolbar() {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 80, "height": 80})).unwrap();
|
||||
let mut h = Harness::builder().with_size(vec2(400.0, 1800.0)).with_step_dt(1.0 / 60.0).build_app(|ui, app| crate::panels::toolbar(app, ui), app);
|
||||
h.run_steps(4);
|
||||
let brush = h.query_all_by_label_contains("Brush Tool").next().expect("the Brush slot is visible").rect().center();
|
||||
|
||||
for (interface_on, tools_on) in [(true, true), (false, true), (true, false), (true, true)] {
|
||||
h.hover_at(Pos2::new(380.0, 1780.0));
|
||||
h.state_mut().session.edit_prefs(|p| {
|
||||
p.interface.show_tooltips = interface_on;
|
||||
p.tools.show_tooltips = tools_on;
|
||||
});
|
||||
h.run_steps(45);
|
||||
h.hover_at(brush);
|
||||
h.run_steps(45);
|
||||
let shown = h.query_all_by_role(Role::Tooltip).any(|node| node.accesskit_node().label().is_some_and(|label| label.contains("Brush Tool")));
|
||||
assert_eq!(shown, interface_on && tools_on, "Interface option {interface_on}, Tools option {tools_on}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user