mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
UI: canvas chrome clears the scroll bar and the empty navigator
- The Rotate View compass of a turned view sits left of the vertical scroll bar. It was placed in the canvas's top right corner, where the scroll bar drew over most of it. - With no document open, the status bar's artboard navigator shows a dash instead of an empty box.
This commit is contained in:
1 parent
b24f5af47c
commit
745a0d5b7b
3 files changed
+50
-3
No files matched your search
@@ -395,7 +395,7 @@ fn compass(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option<Can
|
||||
return None;
|
||||
}
|
||||
let mut turn = space.view.rotation;
|
||||
let rect = RotateView::compass_rect(ui, space.view.rect);
|
||||
let rect = RotateView::compass_rect(ui, clear_of_scroll_bars(app, ui, space.view.rect));
|
||||
RotateView::new(tl!("Rotate View"), Bind::bound(&mut turn), false).show_at(ui, rect);
|
||||
(turn != space.view.rotation).then(|| {
|
||||
let mut view = space.view;
|
||||
@@ -404,6 +404,17 @@ fn compass(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option<Can
|
||||
})
|
||||
}
|
||||
|
||||
/// `rect` without the strip the vertical scroll bar takes along its right edge (the bar's thickness and its margin,
|
||||
/// the sizes `CanvasScrollbars` draws with), in the screen modes that show the scroll bars.
|
||||
fn clear_of_scroll_bars(app: &VectorcraftApp, ui: &Ui, rect: egui::Rect) -> egui::Rect {
|
||||
if app.ui.screen_mode >= 2 {
|
||||
return rect;
|
||||
}
|
||||
let env = Env::of(ui);
|
||||
let strip = env.tokens.size.icon.md + env.tokens.space.gap.tight;
|
||||
egui::Rect::from_min_max(rect.min, egui::pos2((rect.right() - strip).max(rect.left()), rect.bottom()))
|
||||
}
|
||||
|
||||
/// The scroll bars along the right and bottom edges (Normal and Full Screen with Menu Bar): the view
|
||||
/// a thumb drag or page press moved.
|
||||
fn scroll_bars(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option<CanvasView> {
|
||||
|
||||
@@ -120,8 +120,15 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
Field::new(tl!("Artboard")).side(SideLabel::new().kind(LabelKind::Hidden)).show(ui, |ui, _| {
|
||||
if let Some(i) =
|
||||
Select::new(tl!("Artboard"), Bind::given(cur), &boards).look(SelectLook::Filled).enabled(nab > 0).show(ui).events.committed().copied()
|
||||
// With no document the navigator shows a dash, as the info readout does.
|
||||
if let Some(i) = Select::new(tl!("Artboard"), Bind::given(cur), &boards)
|
||||
.placeholder("\u{2013}")
|
||||
.look(SelectLook::Filled)
|
||||
.enabled(nab > 0)
|
||||
.show(ui)
|
||||
.events
|
||||
.committed()
|
||||
.copied()
|
||||
{
|
||||
go = Some(json!(i));
|
||||
}
|
||||
@@ -264,6 +271,15 @@ mod tests {
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_no_document_the_artboard_navigator_shows_a_dash() {
|
||||
let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
let mut panel = Panel::new(app, status_bar);
|
||||
panel.room(egui::vec2(1200.0, 300.0));
|
||||
panel.frame();
|
||||
assert_eq!(panel.value_role("Artboard", Role::COMBO_BOX).as_deref(), Some("\u{2013}"), "the empty navigator reads as a dash");
|
||||
}
|
||||
}
|
||||
|
||||
/// What the bar shows as work in progress: the running script, then background jobs, opens and places. The first
|
||||
|
||||
@@ -318,6 +318,26 @@ fn rotate_view_to_selection_squares_the_view_to_the_selected_object() {
|
||||
assert!(square_on_screen(&app));
|
||||
}
|
||||
|
||||
/// The Rotate View compass of a turned view sits clear of the vertical scroll bar, so the bar does not cover it.
|
||||
#[test]
|
||||
fn the_rotate_view_compass_is_clear_of_the_vertical_scroll_bar() {
|
||||
let mut w = Window::new();
|
||||
w.ctx.enable_accesskit();
|
||||
w.after(0.0, vec![]);
|
||||
let out = w.after(0.0, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.as_ref().map_or(&[][..], |u| &u.nodes[..]);
|
||||
let bounds = |label: &str| {
|
||||
nodes
|
||||
.iter()
|
||||
.find(|(_, n)| n.label() == Some(label))
|
||||
.and_then(|(_, n)| n.bounds())
|
||||
.map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32)))
|
||||
.unwrap_or_else(|| panic!("no {label} in the access tree"))
|
||||
};
|
||||
let (compass, bar) = (bounds("Rotation compass"), bounds("Vertical scroll bar"));
|
||||
assert!(compass.right() <= bar.left(), "the compass {compass:?} reaches under the scroll bar {bar:?}");
|
||||
}
|
||||
|
||||
/// The window, with a 400 × 300 document whose view is turned to 30°, and the Selection tool. Each
|
||||
/// frame comes the given number of seconds, zero or more, after the one before it.
|
||||
struct Window {
|
||||
|
||||
Reference in new issue
Block a user