mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 02:32:33 +00:00
Compare: the rule between the two panes
ComparePair::divider gives the segment in the middle of the gap between the panes, as LightCraft's Compare view draws a line there; the pair story shows a vertical Divider on it.
This commit is contained in:
@@ -47,6 +47,13 @@ impl ComparePair {
|
||||
let right = Rect::from_min_size(pos2(inner.max.x - side, inner.min.y), vec2(side, inner.height()));
|
||||
if self.rtl { [right, left] } else { [left, right] }
|
||||
}
|
||||
|
||||
/// The rule between the panes: a segment in the middle of the gap, as tall as the panes. The caller shows a
|
||||
/// vertical divider there.
|
||||
pub fn divider(&self, area: Rect) -> Rect {
|
||||
let inner = area.shrink(self.space.margin);
|
||||
Rect::from_center_size(inner.center(), vec2(self.space.gap, inner.height()))
|
||||
}
|
||||
}
|
||||
|
||||
/// How many columns show `n` survey tiles largest in `area`, for pictures `aspect` (width over height) wide: the
|
||||
|
||||
@@ -4,7 +4,8 @@ use std::collections::HashMap;
|
||||
use std::sync::{Mutex, PoisonError};
|
||||
|
||||
use craft_theme::Srgba;
|
||||
use craft_ui::contract::{Bind, ShowContainer as _};
|
||||
use craft_ui::contract::{Bind, Show as _, ShowContainer as _};
|
||||
use craft_ui::display::Divider;
|
||||
use craft_ui::layout_components::Row;
|
||||
use craft_ui::patterns::form_dialogs::PreviewView;
|
||||
use craft_ui::primitives::textures::Revision;
|
||||
@@ -71,7 +72,9 @@ fn compare_pair(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let output = filling(ui, |ui, area| {
|
||||
let mut active = *data.value("active", 0usize);
|
||||
let view = data.value("view", PreviewView::fitting());
|
||||
let [left, right] = ComparePair::new(space).rtl(rtl).rects(area);
|
||||
let pair = ComparePair::new(space).rtl(rtl);
|
||||
let [left, right] = pair.rects(area);
|
||||
Divider::vertical().show_at(ui, pair.divider(area));
|
||||
let select =
|
||||
CompareTile::new(labels[0], Bind::bound(view), image(1)).caption(caption(labels[0], "IMG_0001.jpg")).active(active == 0).place(ui, left);
|
||||
if select.clicked {
|
||||
|
||||
Reference in New Issue
Block a user