fw sync: ui-widgets compiles: FaceSpec fields, story binds, registry-visible story modules, text_x, deprecations

This commit is contained in:
Dylan M. Taylor
2026-11-22 23:23:20 -05:00
parent 7f53dfd8b7
commit ccbd4283ba
12 changed files with 17 additions and 17 deletions
@@ -1,7 +1,7 @@
//! `CommandSearch`: the command-search opener, a search field's face that fires its command.
use super::ButtonOutput;
use super::face::{self, FaceLook, FaceSpec};
use super::face::{self, Arrangement, FaceLook, FaceSpec};
use crate::contract::{Common, Component, Cx, MeasureCx, PaintUi, PartsCx, Pointer as _, Props as _, Role};
use crate::display::Kbd;
use crate::primitives::{HAlign, IconSpec};
@@ -63,7 +63,7 @@ impl CommandSearch {
}
fn spec<'s>(&'s self, label: &'s str) -> FaceSpec<'s> {
FaceSpec { label, role: Some(TypeRole::Body), lead: Some(&self.glyph), trail: None, loading: false, mnemonic: None, align: HAlign::Start }
FaceSpec { arrangement: Arrangement::Inline, label, role: Some(TypeRole::Body), lead: Some(&self.glyph), picture: None, trail: None, loading: false, mnemonic: None, align: HAlign::Start }
}
}
@@ -86,7 +86,7 @@ fn swatch_table_empty(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
fn swatch_table_trailing(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let entries = table_entries().into_iter().step_by(21).take(12).collect::<Vec<_>>();
let shown = SwatchTable::new("Colors", &entries)
.selection(Bind::bound(data.value("selected", Selection::single(0usize))))
.selection(data.bind("selected", Selection::single(0usize)))
.wells(true)
.tips(true)
.per_row(6)
@@ -25,7 +25,7 @@ fn slider_field_log(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
/// A whole-step slider whose field keeps finer typed values.
#[story(SliderField<'static>, covers = [], drive = Drive::Never)]
fn slider_field_typed_precision(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
SliderField::new("Size", Bind::bound(data.value("precise_size", 36.1231)), 1.0..=100.0).step(1.0).typed_decimals(4).show(ui).into()
SliderField::new("Size", data.bind("precise_size", 36.1231), 1.0..=100.0).step(1.0).typed_decimals(4).show(ui).into()
}
#[story(SliderField<'static>, covers = [Mixed], drive = Drive::Never)]
+1 -1
View File
@@ -474,7 +474,7 @@ fn list_row_menu(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
#[story(List<'static, usize>, covers = [], drive = Drive::Never)]
fn list_rename_while_filtered(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
const NOTES: usize = 2;
let id = egui::Id::new("list_rename_while_filtered");
let id = egui::Id::unique("list_rename_while_filtered");
let names = data.value("names", vec![String::from("Chapter 1"), String::from("Chapter 2"), String::from("Notes")]).clone();
// The button sits at the start of the list's width, which is the right under right-to-left.
let start = if Env::of(ui).view().direction().is_rtl() { egui::Align::Max } else { egui::Align::Min };
+1 -1
View File
@@ -3,7 +3,7 @@
use super::item::{RowInput, close_on_pick};
use super::level::{MenuLevel, Row};
use crate::contract::{
Access, Common, Component, Cx, Focus as _, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Role, SetPosition,
Access, Common, Component, Cx, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Role, SetPosition,
Styled as _,
};
use crate::primitives::IconSpec;
+1 -1
View File
@@ -2,7 +2,7 @@
pub mod bar;
pub(crate) mod edit;
mod icon_row;
pub(crate) mod icon_row;
pub(crate) mod item;
#[doc(hidden)]
pub mod level;
+1 -1
View File
@@ -7,7 +7,7 @@
pub(crate) mod calendar;
mod codec;
mod popover;
pub(crate) mod popover;
#[cfg(feature = "suite")]
pub(crate) mod stories;
+1 -1
View File
@@ -342,7 +342,7 @@ impl<'a, D: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> Documen
if let Some(area) = trailing.as_mut() {
// The strip fills the row less the room the control took last pass; the control follows the last tab
// when every tab shows, and is the row's last item when they overflow.
let memory = ui.id().with("document-tabs-trailing-width");
let memory = ui.scope_id().with("document-tabs-trailing-width");
let held: f32 = ui.ctx().data(|data| data.get_temp(memory)).unwrap_or(0.0);
let slot = ui.allocate_exact_size(egui::vec2(held, strip.response.response.rect.height()), egui::Sense::hover()).0;
let all_show = strip.tab_rects.len() == tabs.len();
+1 -1
View File
@@ -9,7 +9,7 @@ pub(crate) mod linked;
pub(crate) mod number;
pub(crate) mod selectable_text;
pub(crate) mod text_field;
mod word_run;
pub(crate) mod word_run;
mod words;
pub(crate) mod zoom_field;
+3 -3
View File
@@ -1049,7 +1049,7 @@ impl Component for Tile<'_> {
};
let title_layout = draw.layout(&title, title_area.width());
let title_x =
if centered { title_area.center().x - title_layout.size().x / 2.0 } else { self.text_x(title_area, title_layout.size().x, cx) };
if centered { title_area.center().x - title_layout.size().x / 2.0 } else { Self::text_x(title_area, title_layout.size().x, cx) };
draw.galley(egui::pos2(title_x, title_area.top()), &title_layout);
if !centered {
if let Some(detail) = &self.detail {
@@ -1060,11 +1060,11 @@ impl Component for Tile<'_> {
if layout.galley.rows.len() > 2 {
layout = draw.layout(&run.elide(), picture.width());
}
draw.galley(egui::pos2(self.text_x(picture, layout.size().x, cx), icon.bottom() + style.sizes.tight), &layout);
draw.galley(egui::pos2(Self::text_x(picture, layout.size().x, cx), icon.bottom() + style.sizes.tight), &layout);
}
let run = TextRun::new(action.as_str()).role(style.detail.role).color(style.range).elide();
let layout = draw.layout(&run, picture.width());
draw.galley(egui::pos2(self.text_x(picture, layout.size().x, cx), picture.bottom() - layout.size().y), &layout);
draw.galley(egui::pos2(Self::text_x(picture, layout.size().x, cx), picture.bottom() - layout.size().y), &layout);
}
self.caption_rect = Some(title_area);
return;
+1 -1
View File
@@ -257,7 +257,7 @@ fn a_menu_opener_accepts_accessibility_activation() {
fn a_context_menu_near_the_top_stays_inside_the_window() {
let mut fixture = Fixture::new(|ui| {
let (rect, _) = ui.allocate_exact_size(egui::vec2(400.0, 300.0), egui::Sense::click());
let target = ui.interact(rect, ui.id().with("area"), egui::Sense::click());
let target = ui.interact(rect, ui.scope_id().with("area"), egui::Sense::click());
Menu::context("Page menu", &target).show(ui, |ui, _| {
for name in ["Copy", "Paste", "Select All", "Rotate", "Delete", "Insert", "Extract", "Print", "Properties", "More"] {
MenuItem::new(name).show(ui);
+3 -3
View File
@@ -54,7 +54,7 @@ fn document_tabs_leave_space_between_neighbours() {
use craft_ui::tabs::{DocumentTab, DocumentTabs};
let mut fixture = Fixture::new(|ui| {
let tabs = [DocumentTab::new(1, "One"), DocumentTab::new(2, "Two")];
DocumentTabs::new("Documents", &tabs).selected(1).show(ui);
let _ = DocumentTabs::new("Documents", &tabs).selected(1).show(ui);
});
fixture.settle();
let first = fixture.by_label("One").expect("first tab").rect;
@@ -101,7 +101,7 @@ fn document_tabs_reserve_space_for_the_trailing_control() {
let seen = trailing_rect.clone();
let mut fixture = Fixture::new(move |ui| {
let tabs: Vec<_> = (0..5).map(|i| DocumentTab::new(i, format!("Long document number {i}, scanned.pdf")).closable(true)).collect();
DocumentTabs::new("Documents", &tabs)
let _ = DocumentTabs::new("Documents", &tabs)
.selected(4)
.trailing(|ui| {
seen.set(Button::new("Open").show(ui).rect);
@@ -125,7 +125,7 @@ fn the_trailing_control_follows_the_last_tab_when_they_fit() {
use craft_ui::tabs::{DocumentTab, DocumentTabs};
let mut fixture = Fixture::new(|ui| {
let tabs: Vec<_> = (0..2).map(|i| DocumentTab::new(i, format!("Doc {i}.pdf")).closable(true)).collect();
DocumentTabs::new("Documents", &tabs)
let _ = DocumentTabs::new("Documents", &tabs)
.selected(1)
.trailing(|ui| {
Button::new("Open").show(ui);