diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index a69fe3b358..bee00fb389 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -5,27 +5,18 @@ use super::hide::{self, PruneKey}; use crate::contract::Revision; use crate::contract::overlay::{PlacementChange, PlacementKind}; use crate::contract::{ -<<<<<<< HEAD - Bind, BindMut, BodyCx, Cx, Entry, Gap, Lazy, NoValue, Outcome, Pad, Pointer as _, Props as _, ShowContainer as _, Sizing, WordSetCx as _, -======= - Bind, BindMut, BodyCx, Cx, Entry, MemoKey, MemoProps, MemoView, NoValue, Outbox, Outcome, Pad, Pointer as _, Props as _, Show as _, + Bind, BindMut, BodyCx, Cx, Entry, Gap, MemoKey, MemoProps, MemoView, NoValue, Outbox, Outcome, Pad, Pointer as _, Props as _, Show as _, ShowContainer as _, Sizing, Tracked, WordSetCx as _, ->>>>>>> origin/next }; use crate::docking::SplitFramesCx as _; use crate::docking::stack::{StackSection, StackSections, section_heights}; +use crate::docking::tree::FrameRules; use crate::docking::{Arrangement, close_requests, cross_window, end_replaced_drags, float_drop, native, open_requests}; use crate::docking::{ ColumnArrow, ColumnBar, DockColumn, DockCommands, DockConfig, DockDropTarget, DockDropped, DockEvent, DockGroup, DockPanels, DockRoot, DockScene, -<<<<<<< HEAD - DockSizes, DockSpot, DockTargets, DockTo, DockWords, DragUnit, FloatSpace, FloatingGroup, FlyoutResize, GroupAt, GroupDrag, HidePanels, - IconicColumn, IconicMode, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelTitle, SplitArea, WindowColumn, actions, dock_states, fit_widths, - frame, move_actions, stepped, -======= DockSizes, DockSpot, DockTargets, DockTo, DockWords, DragUnit, FloatSpace, FloatingGroup, FlyoutResize, GroupAt, GroupDrag, GroupGrip, - HidePanels, IconicColumn, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelSpecs, PanelTitle, Placing, SpecSource, SplitArea, Titles, - WindowColumn, actions, column_cells, dock_states, frame, move_actions, with_area_rules, ->>>>>>> origin/next + HidePanels, IconicColumn, IconicMode, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelSpecs, PanelTitle, Placing, SpecSource, SplitArea, + Titles, WindowColumn, actions, dock_states, fit_widths, frame, move_actions, }; use crate::layout_components::Stack; use crate::menu::{GroupItem, MenuWords, PanelMenu, PanelRow}; @@ -42,13 +33,8 @@ use craft_behavior::dock::{ use craft_behavior::overlay::Side; use craft_behavior::{CancelReason, DockSide, EditEvent, EditEvents, Flow, GestureId, GesturePhase, Mixed, Proposal}; use craft_host::target::WindowKind; -<<<<<<< HEAD -use egui::{Context, Id, Pos2, Rect, Response, Ui, Vec2, ViewportId}; -use std::cell::{Cell, RefCell}; -======= use egui::{Context, Id, Pos2, Rect, Response, Ui, UiBuilder, Vec2, ViewportId}; use std::cell::{Cell, OnceCell, RefCell}; ->>>>>>> origin/next use std::collections::HashMap; use std::fmt::Debug; use std::hash::Hash; @@ -265,17 +251,12 @@ impl Drops<'_, P> { fn take(&self, cx: &mut Cx<'_, DockRoot<'_, DockDropped

>>) -> Option> { let ctx = cx.core.ctx.clone(); let sizes = *cx.style.sizes(); -<<<<<<< HEAD - let bounds = inset_top(cx.env.get::().0.as_ref().map_or(cx.rect, ShellCx::float_bounds), self.top_inset); - let space = float_space(bounds, &sizes, self.config, self.specs); -======= let shell = cx.env.get::().0; - let bounds = shell.as_ref().map_or(cx.rect, ShellCx::float_bounds); + let bounds = inset_top(shell.as_ref().map_or(cx.rect, ShellCx::float_bounds), self.top_inset); let space = float_space(&ctx, bounds, &sizes, self.config, self.specs); let spec = |panel: &P| spec_in(self.specs, panel); let protected = |panel: &P| (self.permissions)(panel).is_protected(); let (hide, _) = hide::resolved(self.hide, shell.as_ref()); ->>>>>>> origin/next let mut target = DockDropTarget::new(&ctx, self.dock, self.layout, self.permissions); target.rtl = self.rtl; target.space = Some(&space); @@ -381,7 +362,9 @@ impl Scene<'_, P> { fn rail_beside(&self, column: &Column

) -> bool { let spec = |panel: &P| self.spec(panel); let collapses = column.panels().all(|panel| self.permissions(panel).collapses); - self.config.iconic_mode == IconicMode::Rail && !column.iconic && ColumnArrow::of(column, &spec, collapses) == ColumnArrow::Collapse + self.config.iconic_mode == IconicMode::Rail + && !column.iconic + && ColumnArrow::of(column, &self.sizes, &spec, collapses) == ColumnArrow::Collapse } /// The `(width, floor)` of each docked column of a dock, for [`fit_widths`]: a rail beside an expanded column adds @@ -481,11 +464,8 @@ struct Pass<'s, P> { impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { /// Shows the area across the room offered. pub fn show(self, ui: &mut Ui) -> DockAreaOutput

{ -<<<<<<< HEAD - let DockArea { label, mut workspace, panels, config, hide, maximized, auto_collapse, locked, mut flyout, rail_footer, top_inset } = self; -======= - let DockArea { label, mut workspace, specs, panels, config, hide, maximized, auto_collapse, locked, mut flyout } = self; ->>>>>>> origin/next + let DockArea { label, mut workspace, specs, panels, config, hide, maximized, auto_collapse, locked, mut flyout, rail_footer, top_inset } = + self; let ctx = ui.ctx().clone(); let (rtl, window) = { let env = Env::of(ui); @@ -502,11 +482,6 @@ impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { let current = if error.is_none() { held } else { Arc::default() }; let rights = &model.rights; let policy = |panel: &P| rights.get(panel).copied().unwrap_or(Permissions::ALL); -<<<<<<< HEAD - let specs: HashMap = current.layout.panels().into_iter().map(|panel| (panel.clone(), panels.spec(panel))).collect(); - let drops = Drops { dock: id, layout: ¤t.layout, permissions: &policy, config: &config, specs: &specs, rtl, top_inset }; - let shows = Arrangement { dock: id, revision: current.revision() }; -======= let drops = Drops { dock: id, layout: current.layout(), @@ -516,9 +491,9 @@ impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { hide, maximized: maximized.as_ref(), rtl, + top_inset, }; let shows = Arrangement { dock: id, generation: current.generation() }; ->>>>>>> origin/next end_replaced_drags::

(&ctx, shows); let dropped: RefCell>> = RefCell::new(None); let root = DockRoot::new(|cx| { @@ -684,11 +659,7 @@ fn show_area( panels: &mut dyn DockPanels

, mut flyout: Option<&mut Bind<'_, Option

>>, ) -> Passed

{ -<<<<<<< HEAD - let Input { id, ctx, current, config, specs, hide, maximized, auto_collapse, sizes, rtl, rail_footer, top_inset } = *input; -======= - let Input { id, ctx, current, config, specs, keys, hide, model, maximized, auto_collapse, sizes, rtl } = *input; ->>>>>>> origin/next + let Input { id, ctx, current, config, specs, keys, hide, model, maximized, auto_collapse, sizes, rtl, rail_footer, top_inset } = *input; let shell = body.shell(); let mut memory = body.memory::>().clone(); let protected = |panel: &P| rights.get(panel).is_some_and(|rights| rights.is_protected()); @@ -696,13 +667,8 @@ fn show_area( let prune = PruneKey { model, hide, floating, maximized: maximized.map(PanelKey::of) }; let view = derived(ctx, id.with("pruned"), &prune, || frame::maximize(current.layout(), maximized, hide, &protected).into_owned()); let layout: &Layout

= &view.layout; -<<<<<<< HEAD let bounds = inset_top(shell.as_ref().map_or(body.rect, ShellCx::float_bounds), top_inset); - let space = float_space(bounds, &sizes, config, specs); -======= - let bounds = shell.as_ref().map_or(body.rect, ShellCx::float_bounds); let space = float_space(ctx, bounds, &sizes, config, specs); ->>>>>>> origin/next let scene = Scene { dock: id, view: MemoKey::of(&prune), @@ -716,12 +682,8 @@ fn show_area( bounds, auto_collapse, rtl, -<<<<<<< HEAD - floated: ¤t.floated, - rail_footer, -======= floated: current.floated(), ->>>>>>> origin/next + rail_footer, }; let open = open_of(&mut flyout, body, &memory); let mut pass = Pass { @@ -740,38 +702,32 @@ fn show_area( dock: id, }; -<<<<<<< HEAD let limits = |panel: &P| scene.spec(panel).limits; let dock_width = |columns: &[Column

]| scene.natural(columns).iter().map(|(width, _)| *width).sum::(); let stripless = |panel: &P| scene.spec(panel).canvas; let rules = FrameRules::new(&limits).dock_width(&dock_width).stripless(&stripless); -======= - let spec_of = |panel: &P| scene.spec(panel); ->>>>>>> origin/next let label = Label::from(body.words::().panels.as_str().to_owned()); let mut leaves: Vec<(Vec, Rect)> = Vec::new(); - let area = with_area_rules(&scene.sizes, &spec_of, |rules| { - SplitArea::new(label, Bind::given(layout.clone()), rules).show(ui, |ui, split| { - DockTargets::

::register_room(ctx, id, split.rect); - for (anchor, rect) in split.group_frames::

() { - let Some(place) = scene.layout.place(&anchor) else { continue }; - let Some(node) = scene.layout.node_of(&place) else { continue }; - if let PanelPlace::Node(path) = &place { - leaves.push((path.clone(), rect)); - } - pass.leaf(ui, split, node, rect); - } - let flow = Flow::new(split.rect, rtl); - for (edge, rect) in split.dock_frames() { - let Some(path) = scene.layout.dock_path(edge) else { continue }; - let Some(Node::Dock { columns, .. }) = scene.layout.root.as_ref().and_then(|root| node_at(root, &path)) else { continue }; + let area = SplitArea::new(label, Bind::given(layout.clone()), rules).show(ui, |ui, split| { + DockTargets::

::register_room(ctx, id, split.rect); + for (anchor, rect) in split.group_frames::

() { + let Some(place) = scene.layout.place(&anchor) else { continue }; + let Some(node) = scene.layout.node_of(&place) else { continue }; + if let PanelPlace::Node(path) = &place { leaves.push((path.clone(), rect)); - if let Some(shell) = shell.as_ref().filter(|shell| shell.revealed()) { - shell.reveal_rect(ctx, if edge == DockEdge::Start { RevealEdge::Start } else { RevealEdge::End }, rect); - } - pass.dock(ui, split, DockPlan { edge, columns, rect, flow, open: open.clone() }); } - }) + pass.leaf(ui, split, node, rect); + } + let flow = Flow::new(split.rect, rtl); + for (edge, rect) in split.dock_frames() { + let Some(path) = scene.layout.dock_path(edge) else { continue }; + let Some(Node::Dock { columns, .. }) = scene.layout.root.as_ref().and_then(|root| node_at(root, &path)) else { continue }; + leaves.push((path.clone(), rect)); + if let Some(shell) = shell.as_ref().filter(|shell| shell.revealed()) { + shell.reveal_rect(ctx, if edge == DockEdge::Start { RevealEdge::Start } else { RevealEdge::End }, rect); + } + pass.dock(ui, split, DockPlan { edge, columns, rect, flow, open: open.clone() }); + } }); let mut edit = area.output.edit.events.map(|edited| { let mut layout = current.layout().clone(); @@ -1063,28 +1019,6 @@ impl Pass<'_, P> { let scene = self.scene; let anchor = members.first()?; let active = active.min(members.len() - 1); -<<<<<<< HEAD - let viewed = match at { - // The view draws in the group's rect as a layout room of its own: it lays out in the group's room, never in - // the room the area has left, and a view that fills takes the whole group. - GroupAt::Show(rect) => in_room(ui, rect, |ui| self.panels.group_view(members, active, ui, at, body)), - GroupAt::Measure(_) => self.panels.group_view(members, active, ui, at, body), - }; - if let Some(height) = viewed { - return matches!(at, GroupAt::Measure(_)).then_some(height); - } - let titles: Vec = members - .iter() - .map(|panel| { - let spec = scene.spec(panel); - PanelTitle::new(PanelKey::of(panel), spec.label) - .closable(scene.permissions(panel).closable) - .command(spec.command) - .count(spec.count) - .caption(spec.caption) - }) - .collect(); -======= // A tool rail (a panel with a grid) that the host shows itself gets the dock's grip strip on top, under its // column bar, as the references' toolbar: the host's view takes the room under it. let grip = if members.get(active).is_some_and(|panel| scene.spec(panel).grid.is_some()) { scene.sizes.grip } else { 0.0 }; @@ -1093,7 +1027,6 @@ impl Pass<'_, P> { { return Some(height + grip); } ->>>>>>> origin/next let shown = &members[active]; let words = body.words::(); let ctx = ui.ctx().clone(); @@ -1110,7 +1043,14 @@ impl Pass<'_, P> { Titles::from_content( members .iter() - .map(|panel| PanelTitle::new(PanelKey::of(panel), scene.spec(panel).label).closable(scene.permissions(panel).closable)) + .map(|panel| { + let spec = scene.spec(panel); + PanelTitle::new(PanelKey::of(panel), spec.label) + .closable(scene.permissions(panel).closable) + .command(spec.command) + .count(spec.count) + .caption(spec.caption) + }) .collect(), ) }); @@ -1172,12 +1112,8 @@ impl Pass<'_, P> { let (strip, view) = if grip > 0.0 { rect.split_top_bottom_at_y(rect.top() + grip.min(rect.height())) } else { (Rect::NOTHING, rect) }; let output = ui .scope_builder(UiBuilder::new().max_rect(rect), |ui| { - let taken = ui - .scope_builder(UiBuilder::new().max_rect(view), |ui| { - ui.shrink_clip_rect(view); - panels.borrow_mut().group_view(members, active, ui, GroupAt::Show(view), body) - }) - .inner; + // The view is a layout room of its own: a view that fills takes the whole group. + let taken = in_room(ui, view, |ui| panels.borrow_mut().group_view(members, active, ui, GroupAt::Show(view), body)); match taken { Some(_) => None, None => Some(make(active, look.minimized).show_at(ui, rect, |ui, body| panel_body(&panels, shown, ui, body)).output), @@ -1255,7 +1191,6 @@ impl Pass<'_, P> { /// The columns of a dock, from the window edge inwards. fn dock(&mut self, ui: &mut Ui, body: &mut BodyCx<'_>, plan: DockPlan<'_, P>) { let scene = self.scene; -<<<<<<< HEAD let widths = fit_widths(&scene.natural(plan.columns), plan.rect.width()); let reading = plan.flow.to_physical(plan.rect); let start = plan.edge == DockEdge::Start; @@ -1263,12 +1198,7 @@ impl Pass<'_, P> { for (column, width) in plan.columns.iter().zip(widths) { let span = if start { (cursor, cursor + width) } else { (cursor - width, cursor) }; cursor = if start { span.1 } else { span.0 }; - let mut cell = plan.flow.to_physical(Rect::from_x_y_ranges(span.0..=span.1, reading.y_range())); -======= - let spec = |panel: &P| scene.spec(panel); - let cells = column_cells(plan.columns, plan.rect, plan.edge, plan.flow, &scene.sizes, &spec); - for (column, cell) in plan.columns.iter().zip(cells) { ->>>>>>> origin/next + let cell = plan.flow.to_physical(Rect::from_x_y_ranges(span.0..=span.1, reading.y_range())); let Some(first) = column.groups.first().and_then(|group| group.panels.first()) else { continue }; // A docked column takes the dock's height, a stepped one (a tool rail) too: the references' docked // toolbar keeps its column's surface down to the dock's foot, with the tools at the top @@ -1408,22 +1338,11 @@ impl Pass<'_, P> { } }; let work = if column.iconic { -<<<<<<< HEAD let Some(output) = icons(cell, open) else { return }; -======= - let shown = IconicColumn::new(name, dock, column, Bind::given(open), &spec) - .edge(edge) - .opens(opens) - .bar(bar) - .within(within) - .auto_collapse(scene.auto_collapse); - let output = shown.show_flyouts_at(ui, cell, |group, at, ui, body| self.group_of(ui, body, group, at, in_window)); ->>>>>>> origin/next self.report.flyout.extend(output.edit.events); self.rail_work(output.front); ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width: output.width, flyout: output.flyout } } else { -<<<<<<< HEAD if !in_window && scene.rail_beside(column) { // The rail keeps to the dock's window edge and the expanded column shows inward of it. let rail = scene.sizes.iconic_width(column, &spec).min(cell.width()); @@ -1442,10 +1361,7 @@ impl Pass<'_, P> { self.report.actions.push(Action::resize_iconic(first.clone(), Some(width))); } } - let output = DockColumn::new(name, dock, column, &spec) -======= let shown = DockColumn::new(name, dock, column, &spec) ->>>>>>> origin/next .edge(edge) .bar(bar) .arrow(self.arrow_of(column)) diff --git a/crates/ui-patterns/src/patterns/dock/area/stories.rs b/crates/ui-patterns/src/patterns/dock/area/stories.rs index 337d64f037..2dd2b3a58c 100644 --- a/crates/ui-patterns/src/patterns/dock/area/stories.rs +++ b/crates/ui-patterns/src/patterns/dock/area/stories.rs @@ -3,15 +3,9 @@ use super::DockArea; use crate::buttons::IconButton; use crate::contract::SizeLimits; -<<<<<<< HEAD -use crate::contract::{Bind, BodyCx, Props as _, Show as _}; +use crate::contract::{BodyCx, Props as _, Show as _, Tracked}; use crate::display::Text; -use crate::docking::{DockConfig, DockGrid, DockPanels, GroupAt, IconicMode, PanelSpec}; -======= -use crate::contract::{BodyCx, Show as _, Tracked}; -use crate::display::Text; -use crate::docking::{DockConfig, DockGrid, DockPanels, GroupAt, PanelSpec, PanelSpecs}; ->>>>>>> origin/next +use crate::docking::{DockConfig, DockGrid, DockPanels, GroupAt, IconicMode, PanelSpec, PanelSpecs}; use crate::menu::PanelRow; use crate::patterns::presets::{PresetPanelMenu, PresetView}; use crate::testing::{Drive, StoryData, StoryOutput, story}; @@ -123,9 +117,10 @@ fn workspace(minimized: bool) -> Arc> { Arc::new(Workspace::new(Layout::new(Some(root), vec![window, collapsed]))) } +/// One spec model for every story, so its revision stays put across frames. +static SPECS: LazyLock> = LazyLock::new(|| Tracked::new(DemoSpecs)); + fn dock(ui: &mut Ui, data: &mut StoryData, demo: &mut Demo, minimized: bool) -> StoryOutput { - /// One spec model for every story, so its revision stays put across frames. - static SPECS: LazyLock> = LazyLock::new(|| Tracked::new(DemoSpecs)); let (workspace, workspace_at) = data.value_at("workspace", workspace(minimized)); DockArea::new("Dock", workspace_at.bind(&mut *workspace), &*SPECS, demo, DockConfig::default()).show(ui).into() } @@ -153,14 +148,12 @@ fn a_minimized_floating_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput #[story(DockArea<'static, usize>, covers = [Default], drive = Drive::Never, title = "Rail with fixed controls")] fn rail_with_fixed_controls(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let workspace = data.value("rail workspace", { + let (workspace, workspace_at) = data.value_at("rail workspace", { let side = Column::new(vec![Group::new(vec![LAYERS, CHANNELS, PROPERTIES, HISTORY, SWATCHES, NAVIGATOR], 0)]).with_iconic(true); let root = Node::split(Axis::X, SplitSize::Ratio(0.8), Node::tabs(vec![CANVAS], 0), Node::dock(DockEdge::End, vec![side])); - Workspace::new(Layout::new(Some(root), Vec::new())) + Arc::new(Workspace::new(Layout::new(Some(root), Vec::new()))) }); let mut demo = Demo { canvas_view: false, host_rows: false }; - DockArea::new("Rail dock", Bind::bound(&mut *workspace), &mut demo, DockConfig::default().iconic_mode(IconicMode::Rail)) - .rail_footer(LAYERS) - .show(ui) - .into() + let config = DockConfig::default().iconic_mode(IconicMode::Rail); + DockArea::new("Rail dock", workspace_at.bind(&mut *workspace), &*SPECS, &mut demo, config).rail_footer(LAYERS).show(ui).into() } diff --git a/crates/ui-patterns/src/patterns/form_dialogs/about.rs b/crates/ui-patterns/src/patterns/form_dialogs/about.rs index 8e5f76c255..51fd7be895 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/about.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/about.rs @@ -229,13 +229,9 @@ impl Outcome for AboutOutput { /// Help > About: tabs About, Contributors and Models over the app's [`AboutInfo`] and [`Credits`], with an OK button. /// -<<<<<<< HEAD /// - **About.** The app's mark when it has one, the blurb, the version, the community button and the link row -/// centred, then "Part of" with the suite's logo when it has one, the built-with line faint. -======= -/// - **About.** The blurb, the version, the community button and the link row centred, the built-with line faint; or, -/// with [`AboutLayout::Listed`], the name, version, blurb and links one to a line, and Close for OK. ->>>>>>> origin/next +/// centred, then "Part of" with the suite's logo when it has one, the built-with line faint; or, with +/// [`AboutLayout::Listed`], the name, version, blurb and links one to a line, and Close for OK. /// - **Contributors.** Show (Username, Display name, Real name), Sort (the list, with a button to reverse) and View /// (Grab bag or Table). The grab bag flows the names as links: a click reports the contributor's profile URL as the /// link (nothing for one without a profile), and the link's tooltip is the summary. The table has every figure; a @@ -385,43 +381,6 @@ impl Shown<'_> { /// The About tab, laid out as [`AboutLayout`] says. fn about(&self, ui: &mut Ui, link: &RefCell>) { let (words, info) = (self.words, self.info); -<<<<<<< HEAD - let dark = Env::of(ui).view().mode() == Mode::Dark; - Stack::new().show(ui, |ui, _| { - if let Some(mark) = &info.mark { - Row::new().align(RowAlign::Center).show(ui, |ui, _| { - Picture::svg(mark.label.clone(), mark.source(dark)).extent(PictureSize::Thumb(ThumbSize::Small)).show(ui); - }); - } - Text::new(info.blurb.clone()).show(ui); - Text::new(words.version.fill(&[("version", info.version.as_str())])).show(ui); - Row::new().align(RowAlign::Center).show(ui, |ui, _| { - if let Some(community) = &info.community - && clicked(&Button::new(community.label.clone()).variant(Variant::PRIMARY).id_salt("community").show(ui)) - { - *link.borrow_mut() = Some(community.url.clone()); - } - }); - Row::new().align(RowAlign::Center).show(ui, |ui, _| { - for (at, item) in info.links.iter().enumerate() { - if at > 0 && item.icon.is_none() && info.links.get(at - 1).is_some_and(|previous| previous.icon.is_none()) { - Text::new("·").shade(Shade::Faint).show(ui); - } - let activated = if let Some(icon) = &item.icon { - clicked(&Button::new(item.label.clone()).icon(icon.clone()).variant(Variant::GHOST).id_salt(("link", at)).show(ui)) - } else { - clicked(&Link::new(item.label.clone()).id_salt(("link", at)).show(ui)) - }; - if activated { - *link.borrow_mut() = Some(item.url.clone()); - } - } - }); - if let Some(logo) = &info.part_of { - Row::new().align(RowAlign::Center).show(ui, |ui, _| { - Text::new(words.part_of.clone()).shade(Shade::Muted).show(ui); - Picture::svg(logo.label.clone(), logo.source(dark)).show(ui); -======= if self.layout == AboutLayout::Listed { // Three blocks set apart by the item gap, as WordCraft's About spaced them: the name, version and blurb; the // links; the built-with line. @@ -442,9 +401,16 @@ impl Shown<'_> { }); return; } + let dark = Env::of(ui).view().mode() == Mode::Dark; // Four blocks set apart by the section gap: the blurb and version at the start edge, the community button and - // the link row each centred across the body, the built-with line at the start edge. + // the link row each centred across the body, the built-with line at the start edge. The app's mark, when it has + // one, is centred above them, and "Part of" with the suite's logo, when it has one, follows the link row. Stack::new().gap(Gap::Section).fill_width().show(ui, |ui, _| { + if let Some(mark) = &info.mark { + Row::new().fill_width().align(RowAlign::Center).show(ui, |ui, _| { + Picture::svg(mark.label.clone(), mark.source(dark)).extent(PictureSize::Thumb(ThumbSize::Small)).show(ui); + }); + } Stack::new().show(ui, |ui, _| { Text::new(info.blurb.clone()).show(ui); Text::new(words.version.fill(&[("version", info.version.as_str())])).show(ui); @@ -459,14 +425,25 @@ impl Shown<'_> { if !info.links.is_empty() { Row::new().fill_width().align(RowAlign::Center).show(ui, |ui, _| { for (at, item) in info.links.iter().enumerate() { - if at > 0 { + // A dot sets apart two text links; a link with an icon is a button of its own. + if at > 0 && item.icon.is_none() && info.links.get(at - 1).is_some_and(|previous| previous.icon.is_none()) { Text::new("·").shade(Shade::Faint).show(ui); } - if clicked(&Link::new(item.label.clone()).id_salt(("link", at)).show(ui)) { + let activated = if let Some(icon) = &item.icon { + clicked(&Button::new(item.label.clone()).icon(icon.clone()).variant(Variant::GHOST).id_salt(("link", at)).show(ui)) + } else { + clicked(&Link::new(item.label.clone()).id_salt(("link", at)).show(ui)) + }; + if activated { *link.borrow_mut() = Some(item.url.clone()); } } ->>>>>>> origin/next + }); + } + if let Some(logo) = &info.part_of { + Row::new().fill_width().align(RowAlign::Center).show(ui, |ui, _| { + Text::new(words.part_of.clone()).shade(Shade::Muted).show(ui); + Picture::svg(logo.label.clone(), logo.source(dark)).show(ui); }); } Text::new(info.built_with.clone()).shade(Shade::Faint).show(ui); diff --git a/crates/ui-patterns/src/patterns/form_dialogs/about/stories.rs b/crates/ui-patterns/src/patterns/form_dialogs/about/stories.rs index 422a523d6b..8e3300e1e8 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/about/stories.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/about/stories.rs @@ -1,11 +1,7 @@ //! Stories of `AboutDialog`: the About tab (centred and listed), the Contributors tab with a PR-only contributor, and an app tab. -<<<<<<< HEAD -use super::{AboutDialog, AboutImage, AboutInfo, AboutLink, AboutTab, Contributor, Credits, HostedAbout, ModelCredit}; -======= -use super::{AboutAppTab, AboutDialog, AboutInfo, AboutLayout, AboutLink, AboutTab, Contributor, Credits, HostedAbout, ModelCredit}; +use super::{AboutAppTab, AboutDialog, AboutImage, AboutInfo, AboutLayout, AboutLink, AboutTab, Contributor, Credits, HostedAbout, ModelCredit}; use crate::contract::Show as _; ->>>>>>> origin/next use crate::dialog::stories::hosted; use crate::display::Text; use crate::testing::{Drive, StoryData, StoryOutput, story}; @@ -45,7 +41,27 @@ fn about_dialog(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { hosted(ui, data, (tab, community), || HostedAbout::new(info(community), CREDITS.clone()).tab(tab)) } -<<<<<<< HEAD +/// The About tab in the listed layout: name, version, blurb and links one to a line, and Close. +#[story(AboutDialog<'static>, covers = [], drive = Drive::Never)] +fn about_dialog_listed(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let community = *data.value("community_link", true); + hosted(ui, data, community, || HostedAbout::new(info(community), CREDITS.clone()).layout(AboutLayout::Listed)) +} + +/// The dialog with one app tab after Models, open on it. +#[story(AboutDialog<'static>, covers = [], drive = Drive::Never)] +fn about_dialog_app_tab(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let community = *data.value("community_button", true); + hosted(ui, data, community, || { + let languages = AboutAppTab::new("languageData", "Languages", |ui: &mut Ui| { + Text::new("English (built in)").show(ui); + Text::new("Français 1.2 · 98% translated").show(ui); + Text::new("Deutsch 1.1 · 91% translated").show(ui); + }); + HostedAbout::new(info(community), CREDITS.clone()).app_tab(languages).tab(AboutTab::App(0)) + }) +} + /// The story's app mark: a rounded square with a page corner folded down. const MARK: &[u8] = br##""##; @@ -71,26 +87,6 @@ fn about_dialog_icon_links(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { AboutLink::new("Source", "https://example.org/source").icon(craft_behavior::IconId::new("file")), ]; HostedAbout::new(info(false).links(links), CREDITS.clone()) -======= -/// The About tab in the listed layout: name, version, blurb and links one to a line, and Close. -#[story(AboutDialog<'static>, covers = [], drive = Drive::Never)] -fn about_dialog_listed(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let community = *data.value("community_link", true); - hosted(ui, data, community, || HostedAbout::new(info(community), CREDITS.clone()).layout(AboutLayout::Listed)) -} - -/// The dialog with one app tab after Models, open on it. -#[story(AboutDialog<'static>, covers = [], drive = Drive::Never)] -fn about_dialog_app_tab(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let community = *data.value("community_button", true); - hosted(ui, data, community, || { - let languages = AboutAppTab::new("languageData", "Languages", |ui: &mut Ui| { - Text::new("English (built in)").show(ui); - Text::new("Français 1.2 · 98% translated").show(ui); - Text::new("Deutsch 1.1 · 91% translated").show(ui); - }); - HostedAbout::new(info(community), CREDITS.clone()).app_tab(languages).tab(AboutTab::App(0)) ->>>>>>> origin/next }) } diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index 7032e0c5c4..932c7ea7c0 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -25,12 +25,9 @@ use crate::display::{Shade, Text}; use crate::form::SliderFieldLayout; use crate::layout::RowAlign; use crate::layout_components::{Row, Stack}; -<<<<<<< HEAD use crate::notices::{Notice, NoticeLayout}; use crate::style::DataColor; use crate::tabs::{Tab, TabKind, TabStrip}; -======= ->>>>>>> origin/next use crate::primitives::ContentPainterCx; use crate::runtime::env::{Env, Label}; @@ -45,13 +42,8 @@ use crate::sections::{DialogRole, FooterButton}; use crate::contract::LabelScheme; use craft_theme::Srgba; -<<<<<<< HEAD use craft_theme::variant::Tone; use egui::{Context, Pos2, Rect, Response, Ui}; -======= -use egui::load::SizedTexture; -use egui::{Context, Pos2, Response, Ui}; ->>>>>>> origin/next use serde_json::Value; use std::borrow::Cow; @@ -89,15 +81,9 @@ pub enum ParamLayout { } impl ParamLayout { -<<<<<<< HEAD - /// Whether a dialog that previews stands its buttons in a column beside the body. - fn side_buttons(self) -> bool { - !matches!(self, ParamLayout::Stacked | ParamLayout::Document) -======= /// Where a dialog that previews stands its buttons: in a column beside the body, or across the foot. fn button_place(self) -> ButtonPlace { - if matches!(self, ParamLayout::Stacked) { ButtonPlace::Foot } else { ButtonPlace::Side } ->>>>>>> origin/next + if matches!(self, ParamLayout::Stacked | ParamLayout::Document) { ButtonPlace::Foot } else { ButtonPlace::Side } } /// How the range rows arrange their slider and number field. @@ -260,18 +246,11 @@ pub struct ParamDialogOutput { /// The point of the preview picture a click landed on this pass (`PreviewOutput::clicked`): an eyedropper on the /// preview samples there. pub preview_click: Option, -<<<<<<< HEAD /// The id of the extra footer button or the custom row's button pressed this pass (`ParamDialog::extra_buttons`, /// `CustomContext::request_action`). pub action: Option, /// The step the preview pager took this pass (`ParamDialog::preview_pager`). pub preview_step: Option, - /// The answer OK would have given, the pass OK was pressed on a dialog that holds its OK for the host. - pub(crate) held: Option, -======= - /// The id of the extra footer button pressed this pass (`ParamDialog::extra_buttons`). - pub footer_action: Option, ->>>>>>> origin/next /// The picture point at the centre of the view the preview pane drew this pass; `None` without a preview. pub(crate) preview_centre: Option, } @@ -436,15 +415,12 @@ pub struct ParamDialog<'a> { /// The colours the colour rows show in place of their values in this pass, by row key. #[prop(vis = "pub(crate)")] preview_colors: Vec<(String, Srgba)>, -<<<<<<< HEAD - /// The lines the host shows under the rows, after `below` ([`HostedParamDialog::set_notes`]). - #[prop(vis = "pub(crate)")] - host_notes: Vec