mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
tests: a bar member's shown part is its interact rect
A member the bar cuts keeps its whole rect as its response rect; the part the bar shows is the rect egui senses it in.
This commit is contained in:
@@ -237,9 +237,9 @@ fn filling_bar(room: f32, column: f32, fields: Sizing, pages: usize) -> Filling
|
||||
Block::new(Vec2::new(column, 20.0)).show(ui);
|
||||
let mut shown = empty;
|
||||
let bar = Bar::new("Filters", BarKind::Tool).show(ui, |ui, _| {
|
||||
shown.fields[0] = TextField::search("Name", Bind::bound(&mut name)).sizing(fields).show(ui).response.rect;
|
||||
shown.fields[1] = TextField::search("Kind", Bind::bound(&mut kind)).sizing(fields).show(ui).response.rect;
|
||||
shown.button = Button::new("Apply").show(ui).rect;
|
||||
shown.fields[0] = TextField::search("Name", Bind::bound(&mut name)).sizing(fields).show(ui).response.interact_rect;
|
||||
shown.fields[1] = TextField::search("Kind", Bind::bound(&mut kind)).sizing(fields).show(ui).response.interact_rect;
|
||||
shown.button = Button::new("Apply").show(ui).interact_rect;
|
||||
});
|
||||
shown.bar = bar.output.response.rect;
|
||||
out.set(shown);
|
||||
@@ -264,7 +264,7 @@ fn filling_bar_members_keep_their_natural_width_and_the_bar_scrolls() {
|
||||
let (lead, trail) = (held.fields[0].min.x - held.bar.min.x, held.bar.max.x - held.button.max.x);
|
||||
assert!((lead - trail).abs() < 1.0, "the button reaches the bar's end, as the first field its start: {dump}");
|
||||
// Narrowed, the members keep their widths and the bar scrolls. A member's shown rect is the part the bar's view
|
||||
// shows, so the bar is paged toward its end: on some page each field shows at least its natural width and the
|
||||
// shows (its interact rect), so the bar is paged toward its end: on some page each field shows at least its natural width and the
|
||||
// button shows whole, and on no page do two members overlap.
|
||||
let button = held.button.width();
|
||||
let (mut widest, mut button_whole) = ([0.0_f32; 2], Vec::new());
|
||||
|
||||
@@ -155,14 +155,15 @@ fn a_member_the_bar_shows_in_part_is_not_shown_until_it_is_whole() {
|
||||
assert!(checked > 0, "no width put a button across the bar's end");
|
||||
}
|
||||
|
||||
/// A bar `width` wide holding an icon button, a rule and a second icon button; `rects` gets the two buttons' rects.
|
||||
/// Icon buttons keep their width, so nothing in the line narrows to make room.
|
||||
/// A bar `width` wide holding an icon button, a rule and a second icon button; `rects` gets the parts of the two
|
||||
/// buttons the bar shows (their interact rects). Icon buttons keep their width, so nothing in the line narrows to
|
||||
/// make room.
|
||||
fn rule_bar(ui: &mut Ui, width: f32, rects: &std::cell::Cell<(Rect, Rect)>) {
|
||||
in_region(ui, Rect::from_min_size(Pos2::ZERO, Vec2::new(width, 80.0)), |ui| {
|
||||
Bar::new("Options", BarKind::Options).show(ui, |ui, _| {
|
||||
let first = IconButton::new(IconId::new("plus")).label("First").show(ui).rect;
|
||||
let first = IconButton::new(IconId::new("plus")).label("First").show(ui).interact_rect;
|
||||
Divider::vertical().show(ui);
|
||||
let second = IconButton::new(IconId::new("minus")).label("Second").show(ui).rect;
|
||||
let second = IconButton::new(IconId::new("minus")).label("Second").show(ui).interact_rect;
|
||||
rects.set((first, second));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user