mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 07:57:47 +00:00
Merge pull request #3455 from dotCooCoo/fix/save-for-web-panes-fill-height
ui-patterns: Save for Web's preview panes fill the height beside the settings
This commit is contained in:
@@ -763,7 +763,7 @@ impl<'a> SaveForWebDialog<'a> {
|
||||
let mut slice_click = None;
|
||||
let failed = failed_of(&pictures, live.selected);
|
||||
Row::new().show(ui, |ui, _| {
|
||||
Stack::new().id_salt("preview").show(ui, |ui, _| {
|
||||
Stack::new().fill().id_salt("preview").show(ui, |ui, _| {
|
||||
let reads = panes::Panes {
|
||||
words: &words,
|
||||
units: &units,
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::{
|
||||
};
|
||||
use crate::buttons::Button;
|
||||
use crate::choice::Segmented;
|
||||
use crate::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _, TooltipSpec, clicked};
|
||||
use crate::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _, Sizing, TooltipSpec, clicked};
|
||||
use crate::display::{Shade, Text};
|
||||
use crate::layout_components::{Row, Stack};
|
||||
use crate::patterns::form_dialogs::{PreviewPane, PreviewState, PreviewView, PreviewZoom};
|
||||
@@ -149,12 +149,13 @@ fn zoom_row(ui: &mut Ui, panes: &Panes<'_>, live: &mut Live, pressed: &mut bool)
|
||||
}
|
||||
|
||||
/// The panes of the view, two to a row, over the one shared view: the first view any pane reports is applied to all.
|
||||
/// The rows share the height the preview column has below the zoom row, which is the height of the settings beside it.
|
||||
fn pane_grid(ui: &mut Ui, panes: &Panes<'_>, live: &mut Live, slice: &mut Option<SliceClick>) {
|
||||
let list = live.view.panes();
|
||||
let mut reported = Reported::default();
|
||||
Stack::new().id_salt("panes").show(ui, |ui, _| {
|
||||
Stack::new().fill().id_salt("panes").show(ui, |ui, _| {
|
||||
for (line, row) in list.chunks(2).enumerate() {
|
||||
Row::new().id_salt(line).show(ui, |ui, _| {
|
||||
Row::new().fill().id_salt(line).show(ui, |ui, _| {
|
||||
for (at, pane) in row.iter().enumerate() {
|
||||
one_pane(ui, panes, live, *pane, line * 2 + at, &mut reported);
|
||||
}
|
||||
@@ -182,8 +183,8 @@ fn one_pane(ui: &mut Ui, panes: &Panes<'_>, live: &Live, pane: WebPane, at: usiz
|
||||
]));
|
||||
let state = state_of(panes, pane);
|
||||
let shade = if live.selected == pane { Shade::Normal } else { Shade::Muted };
|
||||
Stack::new().id_salt(at).show(ui, |ui, _| {
|
||||
let mut preview = PreviewPane::state(name.clone(), state.clone(), &live.shared).click_centres(false).id_salt("pane");
|
||||
Stack::new().fill().id_salt(at).show(ui, |ui, _| {
|
||||
let mut preview = PreviewPane::state(name.clone(), state.clone(), &live.shared).click_centres(false).sizing(Sizing::Fill).id_salt("pane");
|
||||
if !panes.slices.is_empty() {
|
||||
let (slices, chosen) = (panes.slices, panes.chosen);
|
||||
preview = preview.overlay(move |painter: &ContentPainterCx, view: CanvasTransform, picture: Rect| {
|
||||
|
||||
@@ -439,3 +439,30 @@ fn a_palette_answer_in_a_measured_frame_shifts_the_entry_once() {
|
||||
let shift = (ColorTableEdit::Shift([255, 0, 255]), vec![[0, 255, 0]]);
|
||||
assert_eq!(table_events(&host), vec![shift], "the answer shifts the opened entry's colour once");
|
||||
}
|
||||
|
||||
/// The rects of the preview panes the view shows, found by their accessible names (`{pane}: {first}, {second}`).
|
||||
fn pane_rects(fixture: &Fixture) -> Vec<Rect> {
|
||||
let tree = fixture.tree();
|
||||
let is_pane = |name: &str| (name.starts_with("Original") || name.starts_with("Optimized")) && name.contains(": ");
|
||||
tree.keys().into_iter().filter(|key| tree.name_of(*key).is_some_and(is_pane)).filter_map(|key| fixture.target(key)).map(|t| t.rect).collect()
|
||||
}
|
||||
|
||||
/// The panes take the height of the settings column beside them, so they reach down to its Image Size rows, and 4-Up
|
||||
/// splits that height between its two rows of panes.
|
||||
#[trial]
|
||||
fn the_preview_panes_take_the_height_beside_the_settings() {
|
||||
let (_, mut fixture) = open(HostedSaveForWeb::new("poster.psd", IMAGE, texture()));
|
||||
for (view, count) in [("2-Up", 2), ("4-Up", 4)] {
|
||||
let tab = fixture.by_label(view).expect("the view tab");
|
||||
fixture.click(&tab).idle(4);
|
||||
let percent = fixture.by_label("Percent").expect("the Image Size rows").rect;
|
||||
let panes = pane_rects(&fixture);
|
||||
assert_eq!(panes.len(), count, "{view} shows {count} panes");
|
||||
let bottom = panes.iter().map(|pane| pane.bottom()).fold(f32::MIN, f32::max);
|
||||
assert!(bottom > percent.top(), "{view}: the panes end at {bottom}, above the Percent row at {}", percent.top());
|
||||
let top = panes.iter().map(|pane| pane.top()).fold(f32::MAX, f32::min);
|
||||
let (upper, lower): (Vec<&Rect>, Vec<&Rect>) = panes.iter().partition(|pane| pane.top() <= top + 0.5);
|
||||
assert_eq!(upper.len(), 2, "{view}: two panes to a row");
|
||||
assert!(lower.iter().all(|pane| upper.iter().all(|up| pane.top() >= up.bottom())), "{view}: the second row is below the first");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user