Component sets: the productivity set

This commit is contained in:
aiongg
2026-11-21 01:19:14 +00:00
parent 3f440d3ff1
commit 3eebedfcff
11 changed files with 36 additions and 31 deletions
+2 -2
View File
@@ -69,7 +69,7 @@ fn vertical_edge_face(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
vertical(ui, &ROWS, Some(Rangef::new(TEXT.0, TEXT.1)), Some(RulerFace::Edge))
}
/// The centred face (the office set's): a bar inset in the strip, ticks centred on it, numbers in place of the
/// The centred face (the productivity set's): a bar inset in the strip, ticks centred on it, numbers in place of the
/// whole-unit ticks over the text range only.
#[story(VerticalRuler<'static>, covers = [], drive = Drive::Never)]
fn vertical_centred_face(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
@@ -121,7 +121,7 @@ fn page_edge_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
single_page(ui, data, None, Some(RulerFace::Edge))
}
/// Both rulers in the centred face (the office set's).
/// Both rulers in the centred face (the productivity set's).
#[story(PageRulers<'static>, covers = [], drive = Drive::Never)]
fn page_centred_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
single_page(ui, data, None, Some(RulerFace::Centred))
@@ -2,7 +2,7 @@
//! indentation (before text, and a first-line or hanging indent by an amount), spacing before and after, line
//! spacing, with a live sample of the result and a Tabs… button. OK applies everything as one change.
//!
//! The Paragraph controls ([`ParagraphControls`](super::ParagraphControls)) are Photoshop's panel; this is the office
//! The Paragraph controls ([`ParagraphControls`](super::ParagraphControls)) are Photoshop's panel; this is the productivity
//! apps' dialog over the same paragraph.
//!
//! ```ignore
+1 -1
View File
@@ -115,7 +115,7 @@ fn edge_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
over_a_page(ui, data, Some(RulerFace::Edge))
}
/// The centred face (the office set's): a bar inset in the strip, ticks centred on it, numbers in place of the
/// The centred face (the productivity set's): a bar inset in the strip, ticks centred on it, numbers in place of the
/// whole-unit ticks over the column only.
#[story(TextRuler<'static>, covers = [], drive = Drive::Never)]
fn centred_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
+16 -11
View File
@@ -337,7 +337,7 @@ fn tick_marks(shapes: &[egui::Shape], strip: egui::Rect) -> Vec<egui::Rect> {
}
/// A page-wide ruler in inches, shown with `face` when given, in a fixture whose root takes `set`; `popup` shows it in
/// an open popover inside a scope that sets the office set.
/// an open popover inside a scope that sets the productivity set.
fn page_ruler(set: ComponentSet, face: Option<RulerFace>, popup: bool) -> (Fixture, Rc<RefCell<Option<egui::Rect>>>) {
let values = Rc::new(RefCell::new(RulerValues::default()));
let strip_at: Rc<RefCell<Option<egui::Rect>>> = Rc::new(RefCell::new(None));
@@ -362,7 +362,7 @@ fn page_ruler(set: ComponentSet, face: Option<RulerFace>, popup: bool) -> (Fixtu
with_env(
ui,
|env| {
env.values.set(ComponentSet::Office);
env.values.set(ComponentSet::Productivity);
},
|ui| {
Popover::new("Card", Bind::given(true)).show(ui, |ui, _| ruler(ui));
@@ -400,13 +400,18 @@ fn edge(p: &Painted) -> bool {
!p.ticks.is_empty() && p.ticks.iter().all(|tick| (tick.max.y - p.strip.max.y).abs() < 1.0)
}
/// With no face given, the component set picks it: the office set's ruler centres its marks on a bar and puts numbers
/// With no face given, the component set picks it: the productivity set's ruler centres its marks on a bar and puts numbers
/// in place of the whole-unit ticks, the creative set's hangs them from the strip's bottom edge.
#[trial]
fn the_component_set_picks_the_ruler_face() {
let (mut fixture, strip) = page_ruler(ComponentSet::Office, None, false);
let office = painted(&mut fixture, &strip);
assert!(centred(&office), "the office set paints the centred face: ticks {:?}, numbers {:?}", office.ticks, office.numbers);
let (mut fixture, strip) = page_ruler(ComponentSet::Productivity, None, false);
let productivity = painted(&mut fixture, &strip);
assert!(
centred(&productivity),
"the productivity set paints the centred face: ticks {:?}, numbers {:?}",
productivity.ticks,
productivity.numbers
);
let (mut fixture, strip) = page_ruler(ComponentSet::Creative, None, false);
let creative = painted(&mut fixture, &strip);
assert!(edge(&creative), "the creative set paints the edge face: ticks {:?}", creative.ticks);
@@ -415,9 +420,9 @@ fn the_component_set_picks_the_ruler_face() {
/// A face given on the ruler wins over the component set.
#[trial]
fn a_given_face_wins_over_the_component_set() {
let (mut fixture, strip) = page_ruler(ComponentSet::Office, Some(RulerFace::Edge), false);
let (mut fixture, strip) = page_ruler(ComponentSet::Productivity, Some(RulerFace::Edge), false);
let given_edge = painted(&mut fixture, &strip);
assert!(edge(&given_edge), "the edge face under the office set: ticks {:?}", given_edge.ticks);
assert!(edge(&given_edge), "the edge face under the productivity set: ticks {:?}", given_edge.ticks);
let (mut fixture, strip) = page_ruler(ComponentSet::Creative, Some(RulerFace::Centred), false);
let given_centred = painted(&mut fixture, &strip);
assert!(centred(&given_centred), "the centred face under the creative set: ticks {:?}", given_centred.ticks);
@@ -428,7 +433,7 @@ fn a_given_face_wins_over_the_component_set() {
fn a_scopes_component_set_reaches_a_popup_opened_inside_it() {
let (mut fixture, strip) = page_ruler(ComponentSet::Creative, None, true);
let in_popup = painted(&mut fixture, &strip);
assert!(centred(&in_popup), "the popup's ruler takes the scope's office set: ticks {:?}", in_popup.ticks);
assert!(centred(&in_popup), "the popup's ruler takes the scope's productivity set: ticks {:?}", in_popup.ticks);
}
/// A set change restyles the ruler in the frame it arrives in, in one pass, and the frame after asks for nothing more.
@@ -436,9 +441,9 @@ fn a_scopes_component_set_reaches_a_popup_opened_inside_it() {
fn a_component_set_change_restyles_the_ruler_in_one_pass_and_then_rests() {
let (mut fixture, strip) = page_ruler(ComponentSet::Creative, None, false);
assert!(edge(&painted(&mut fixture, &strip)));
fixture.set(ComponentSet::Office);
fixture.set(ComponentSet::Productivity);
let changed = painted(&mut fixture, &strip);
assert!(centred(&changed), "the frame of the change paints the office face");
assert!(centred(&changed), "the frame of the change paints the productivity face");
assert_eq!(fixture.passes(), 1, "the change takes one pass");
fixture.idle(1);
assert_eq!(fixture.passes(), 1);
+1 -1
View File
@@ -31,7 +31,7 @@
//!
//! let artcraft = ThemeId::parse("craft.artcraft").unwrap();
//! let defaults =
//! AppDefaults { theme: ThemePair::same(artcraft), mode: ModeChoice::Dark, size: Size::Compact, sizes: Default::default(), set: ComponentSet::Office };
//! AppDefaults { theme: ThemePair::same(artcraft), mode: ModeChoice::Dark, size: Size::Compact, sizes: Default::default(), set: ComponentSet::Productivity };
//! let selection = accepted.suite.with_defaults(&defaults);
//! assert_eq!((selection.theme.light, selection.mode), (graphite.id, ModeChoice::Dark));
//! ```
+3 -3
View File
@@ -121,8 +121,8 @@ pub enum ComponentSet {
/// The look the creative apps' users expect.
#[default]
Creative,
/// The look the office apps' users expect.
Office,
/// The look the productivity apps' users expect.
Productivity,
}
/// What the user picked, every field concrete (after defaults are filled in).
@@ -215,7 +215,7 @@ impl From<Selection> for SuiteChoice {
/// What an app shows for every field the suite hasn't chosen.
///
/// Each app states its own, normally [`crate::SUITE_DEFAULT`] in both slots with the mode and
/// size that suit it (the creative apps Dark and Compact; office apps may ship Light).
/// size that suit it (the creative apps Dark and Compact; productivity apps may ship Light).
#[derive(Clone, Debug, PartialEq)]
pub struct AppDefaults {
/// The theme for each mode.
+5 -5
View File
@@ -10,16 +10,16 @@ fn the_component_set_is_the_apps_unless_the_user_chose_one_for_it_and_never_the_
mode: ModeChoice::Light,
size: Size::Comfortable,
sizes: Default::default(),
set: ComponentSet::Office,
set: ComponentSet::Productivity,
};
let suite = SuiteChoice::default().with_defaults(&defaults);
assert_eq!(suite.set, ComponentSet::Office, "a fresh install shows the app's set");
assert_eq!(suite.set, ComponentSet::Productivity, "a fresh install shows the app's set");
let follows = AppChoice::new(None, None, None).apply(&suite);
assert_eq!(follows.set, ComponentSet::Office, "an app choice without a set keeps the app's");
assert_eq!(follows.set, ComponentSet::Productivity, "an app choice without a set keeps the app's");
let own = AppChoice::new(None, None, None).with_set(ComponentSet::Creative).apply(&suite);
assert_eq!(own.set, ComponentSet::Creative, "the user's set for the app wins");
let stored: AppChoice = serde_json::from_str(r#"{"theme":null,"mode":null,"size":null}"#).expect("a stored choice without a set reads");
assert_eq!(stored.apply(&suite).set, ComponentSet::Office);
assert_eq!(stored.apply(&suite).set, ComponentSet::Productivity);
let shared = SuiteChoice::from(own);
assert_eq!(shared.with_defaults(&defaults).set, ComponentSet::Office, "the suite's choice carries no set to other apps");
assert_eq!(shared.with_defaults(&defaults).set, ComponentSet::Productivity, "the suite's choice carries no set to other apps");
}
@@ -140,7 +140,7 @@ fn edge_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
in_face(ui, data, RulerFace::Edge)
}
/// The centred face (the office set's): a bar inset in each strip, ticks centred on it, labels in place of the major
/// The centred face (the productivity set's): a bar inset in each strip, ticks centred on it, labels in place of the major
/// ticks and none over the shaded margins.
#[story(Rulers<'static>, covers = [], drive = Drive::Never)]
fn centred_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
+2 -2
View File
@@ -52,11 +52,11 @@ pub enum RulerFace {
}
impl RulerFace {
/// The face the component set `set` shows: the creative set the edge face, the office set the centred one.
/// The face the component set `set` shows: the creative set the edge face, the productivity set the centred one.
pub const fn of(set: craft_theme::ComponentSet) -> Self {
match set {
craft_theme::ComponentSet::Creative => RulerFace::Edge,
craft_theme::ComponentSet::Office => RulerFace::Centred,
craft_theme::ComponentSet::Productivity => RulerFace::Centred,
}
}
+3 -3
View File
@@ -66,7 +66,7 @@ choices!(TEXT_SIZES: TextSize = [
(TextSize::Large, "large", "Large"),
]);
choices!(DENSITIES: Size = [(Size::Compact, "compact", "Compact"), (Size::Comfortable, "comfortable", "Comfortable")]);
choices!(SETS: ComponentSet = [(ComponentSet::Creative, "creative", "Creative"), (ComponentSet::Office, "office", "Office")]);
choices!(SETS: ComponentSet = [(ComponentSet::Creative, "creative", "Creative"), (ComponentSet::Productivity, "productivity", "Productivity")]);
choices!(MOTIONS: MotionChoice = [
(MotionChoice::Full, "full", "Off"),
(MotionChoice::Reduced, "reduced", "On"),
@@ -92,7 +92,7 @@ pub enum VariantAxis {
Contrast,
/// Compact and comfortable density.
Size,
/// The creative and the office component set.
/// The creative and the productivity component set.
Set,
/// Left to right and right to left.
Direction,
@@ -122,7 +122,7 @@ impl VariantAxis {
VariantAxis::Mode => "Every mode (light, dark)",
VariantAxis::Contrast => "Every contrast (standard, high)",
VariantAxis::Size => "Every size (compact, comfortable)",
VariantAxis::Set => "Every set (creative, office)",
VariantAxis::Set => "Every set (creative, productivity)",
VariantAxis::Direction => "Every direction (LTR, RTL)",
VariantAxis::ControlSize => "Every control size (Sm, Md)",
VariantAxis::DirectionAndControlSize => "Every direction and control size",
+1 -1
View File
@@ -3034,7 +3034,7 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn edge(look: &RuleLook, rect: Rect, side: RectSide, pixels_per_point: f32) -> Vec<Shape>`. The line along the `side` edge of `rect`, on the physical pixels just inside it: a row's bottom rule or a
- `craft_ui::primitives::RuleKind`: `pub enum RuleKind { Divider, Edge, Grid, DropMark }`. Which rule a look is for.
- `craft_ui::primitives::RulerFace`: `pub enum RulerFace { Edge, Centred }`. How a ruler lays out its marks and numbers. A ruler takes a face from its `face` prop, else from the scope's
- `pub const fn of(set: craft_theme::ComponentSet) -> Self`. The face the component set `set` shows: the creative set the edge face, the office set the centred one.
- `pub const fn of(set: craft_theme::ComponentSet) -> Self`. The face the component set `set` shows: the creative set the edge face, the productivity set the centred one.
- `pub fn bar(self, strip: Rect, edge: TickEdge) -> Rect`. Where the marks of a strip along `edge` sit: the whole strip for the edge face, the strip inset across its
- `pub fn beside_numbers(self, edge: TickEdge, origin: f32, marks: Vec<Tick>, numbers: &[Rect], pad: f32) -> Vec<Tick>`. The marks of `marks` this face shows beside the numbers in `numbers` (screen boxes): the edge face shows every
- `pub fn centred_number(bar: Rect, edge: TickEdge, at: f32, size: Vec2) -> Rect`. The box a centred number of `size` takes for the mark at `at` (a screen position along `edge`'s axis): centred