mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 12:27:37 +00:00
Part of #5941: Save for Web's Preview in Browser no longer covers the lists
With the preview panes at their narrowest (a 640 by 400 window), Preview in Browser was drawn over the Download list. It now goes on a row of its own below the Zoom and Download lists when the panes are too narrow for it beside them. The Save for Web test checks that it clears the list.
This commit is contained in:
@@ -619,6 +619,17 @@ fn preview_area(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, set
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
let mut browser = false;
|
||||
// Preview in Browser goes on a row of its own when the panes are too narrow for it beside the
|
||||
// two lists (its width as `widgets::secondary_button` draws it).
|
||||
let label = tl!("Preview in Browser");
|
||||
let button_w = (ui.painter().layout_no_wrap(label.to_string(), crate::theme::semibold(12.5), t.text).size().x + 32.0).max(72.0);
|
||||
let mut beside = false;
|
||||
let mut button = |ui: &mut egui::Ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let b = ui.add_enabled(!io::is_web(app), |ui: &mut egui::Ui| widgets::secondary_button(ui, label));
|
||||
browser = b.on_disabled_hover_text(tl!("Needs the desktop app")).clicked();
|
||||
});
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
let z = ZOOMS.iter().position(|z| *z == d.str("__zoom")).unwrap_or(2);
|
||||
let zoom = ui.name_inputs(tl!("Zoom"), |ui| widgets::dropdown(ui, "sfw-zoom", ZOOM_LABELS[z], &ZOOM_LABELS, 110.0));
|
||||
@@ -635,11 +646,15 @@ fn preview_area(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, set
|
||||
{
|
||||
d.fields.insert("__kbps".into(), json!(s));
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let b = ui.add_enabled(!io::is_web(app), |ui: &mut egui::Ui| widgets::secondary_button(ui, tl!("Preview in Browser")));
|
||||
browser = b.on_disabled_hover_text(tl!("Needs the desktop app")).clicked();
|
||||
});
|
||||
beside = ui.available_width() >= button_w;
|
||||
if beside {
|
||||
button(ui);
|
||||
}
|
||||
});
|
||||
if !beside {
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal(button);
|
||||
}
|
||||
browser
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,12 @@ fn save_for_web_in_the_smallest_window_keeps_its_settings_and_buttons_in_view()
|
||||
if !matches!((controls, settings), (Some(c), Some(s)) if c < s) {
|
||||
wrong.push(format!("{size:?}: Preview in Browser ({controls:?}) is left of the settings ({settings:?})"));
|
||||
}
|
||||
// Preview in Browser is right of the download speed list or on a row below it, not over it.
|
||||
let button = text_rects(&shown, "Preview in Browser").first().copied();
|
||||
let speed = text_rects(&shown, "56.6 Kbps").first().copied();
|
||||
if !matches!((button, speed), (Some(b), Some(s)) if b.left() > s.right() + 16.0 || b.top() > s.bottom() + 8.0) {
|
||||
wrong.push(format!("{size:?}: Preview in Browser ({button:?}) clears the download speed list ({speed:?})"));
|
||||
}
|
||||
}
|
||||
assert!(wrong.is_empty(), "{wrong:#?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user