Select and field arrows are the small filled down triangle, as production

This commit is contained in:
Dylan M. Taylor committed 2026-11-22 05:57:39 -05:00
1 parent 446d51c8b6
commit b2df7dff37
3 files changed
+28 -2

No files matched your search

+2 -2
View File
@@ -52,8 +52,8 @@ pub struct DisclosureGlyph {
pub stroke: StrokeWidth,
}
/// The arrow of a field or picker.
static DROPDOWN: DisclosureGlyph = DisclosureGlyph::dropdown_form();
/// The arrow of a field or picker: the small filled triangle pointing down.
static DROPDOWN: DisclosureGlyph = DisclosureGlyph::new(1.0);
/// The arrow of a button that opens a menu.
static MENU_BUTTON: DisclosureGlyph = DisclosureGlyph { open: 1.0, form: ArrowForm::Dropdown, stroke: StrokeWidth::Medium };
/// The submenu arrow.
@@ -2,6 +2,7 @@
mod combo_list;
mod date;
mod select_arrow;
mod select_list;
mod select_steps;
mod select_width;
@@ -0,0 +1,25 @@
//! The arrow of a select.
use craft_ui::contract::{Bind, Entry, Show as _};
use craft_ui::pickers::Select;
use craft_ui::testing::{Fixture, trial};
use egui::Shape;
/// A select's arrow is a small filled triangle pointing down, as in a document app's choice boxes, not a stroked chevron.
#[trial]
fn a_select_ends_in_a_filled_down_triangle() {
let rect = std::rc::Rc::new(std::cell::Cell::new(egui::Rect::NOTHING));
let seen = rect.clone();
let mut fixture = Fixture::new(move |ui| {
let entries = [Entry::new(0u8, "One"), Entry::new(1u8, "Two")];
seen.set(Select::new("Pick", Bind::given(1u8), &entries).show(ui).response.rect);
});
fixture.settle();
let select = rect.get();
let shapes = fixture.frame_shapes();
let triangle = shapes.iter().any(|shape| match shape {
Shape::Path(path) => path.points.len() == 3 && path.fill != egui::Color32::TRANSPARENT && select.contains_rect(path.visual_bounding_rect()),
_ => false,
});
assert!(triangle, "the select paints a filled triangle for its arrow");
}