mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
dock: beside PanelTabLook::Block tabs a docked column card's bar is a square strip of surface.canvas across the card's top and only the card's foot is rounded, as VectorCraft 0.24's tool card; beside the other looks the bar stays part of the card
This commit is contained in:
@@ -339,14 +339,28 @@ pub(crate) fn card_style(cx: &StyleCx<'_>) -> SurfaceStyle {
|
||||
SurfaceStyle { radius: UiTokens::corner(cx.tokens.shape.radius.surface), edge: SurfaceEdge::None, shadow: None, ..cx.surface(SurfaceKind::Panel) }
|
||||
}
|
||||
|
||||
/// Paints a column in `rect` whose content sits in `card`: the card over the dock's background where the column is
|
||||
/// one, else the column's panel surface.
|
||||
pub(crate) fn paint_card(ui: &mut PaintUi<'_>, rect: Rect, card: Rect, style: &SurfaceStyle) {
|
||||
/// Paints a column in `rect` whose content sits in `card`, with its own `bar` if it has one, beside tabs in `look`: the
|
||||
/// card over the dock's background where the column is one, else the column's panel surface; the bar on the surface
|
||||
/// of the dock's strips. A card's bar is part of the card, unless the strips have a surface of their own
|
||||
/// ([`PanelTabLook::Block`]): then it is a square strip across the card's top, and only the card's foot is rounded.
|
||||
pub(crate) fn paint_card(ui: &mut PaintUi<'_>, rect: Rect, card: Rect, style: &SurfaceStyle, bar: Option<Rect>, look: PanelTabLook) {
|
||||
let strip = strip_surface(look);
|
||||
if card == rect {
|
||||
ui.draw().surface(rect, SurfaceKind::Panel, Corners::All);
|
||||
} else {
|
||||
ui.draw().surface(rect, SurfaceKind::Background, Corners::None);
|
||||
ui.draw().surface_styled(card, style);
|
||||
if let Some(bar) = bar {
|
||||
ui.draw().surface(bar, strip, Corners::None);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ui.draw().surface(rect, SurfaceKind::Background, Corners::None);
|
||||
match bar.filter(|_| look == PanelTabLook::Block) {
|
||||
Some(bar) => {
|
||||
let mut foot = *style;
|
||||
(foot.radius.nw, foot.radius.ne) = (0, 0);
|
||||
ui.draw().surface_styled(card, &foot);
|
||||
ui.draw().surface(bar, strip, Corners::None);
|
||||
}
|
||||
None => ui.draw().surface_styled(card, style),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,15 +536,10 @@ impl<P: Value + Debug + Hash + 'static> Component for DockColumn<'_, P> {
|
||||
let Some(plan) = self.laid.as_ref() else { return };
|
||||
// Painted here, not as the container's surface, which lies over what `paint` draws.
|
||||
let card = self.inner(cx.rect, cx.flow.is_rtl(), &cx.style.sizes);
|
||||
paint_card(ui, cx.rect, card, &cx.style.card);
|
||||
if self.bar == ColumnBar::Own {
|
||||
// A card's bar is part of the card.
|
||||
if card == cx.rect {
|
||||
ui.draw().surface(plan.bar, strip_surface(self.tab_look), Corners::None);
|
||||
}
|
||||
if self.arrow.shown() {
|
||||
paint_chevron(ui, self.edge, self.arrow, true, cx.flow.is_rtl(), &cx.words::<DockWords>());
|
||||
}
|
||||
let bar = (self.bar == ColumnBar::Own).then_some(plan.bar);
|
||||
paint_card(ui, cx.rect, card, &cx.style.card, bar, self.tab_look);
|
||||
if self.bar == ColumnBar::Own && self.arrow.shown() {
|
||||
paint_chevron(ui, self.edge, self.arrow, true, cx.flow.is_rtl(), &cx.words::<DockWords>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::rails::tool::stories::{BRUSH, tools};
|
||||
use crate::rails::{LastUsed, RailDensity, ToolRail, ToolSlot};
|
||||
use crate::runtime::env::Env;
|
||||
use crate::sections::Panel;
|
||||
use crate::tabs::PanelTabLook;
|
||||
use crate::testing::memory::global;
|
||||
use crate::testing::{Drive, StoryData, StoryOutput, story};
|
||||
use craft_behavior::Flow;
|
||||
@@ -49,11 +50,13 @@ fn in_a_floating_window(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
|
||||
/// A docked column of a tool rail at the window edge shown as a card (`DockConfig::column_cards`), at each rail density
|
||||
/// and one or two steps: inset on its outer, top and bottom sides, where the dock's background shows, with its bar and
|
||||
/// its rail on the rounded panel card. The column is wider than its steps by the inset.
|
||||
/// its rail on the rounded panel card. The column is wider than its steps by the inset. Beside block tabs
|
||||
/// (`PanelTabLook::Block`, VectorCraft's) its bar is a square `surface.canvas` strip across the card's top.
|
||||
#[story(DockColumn<'static, u8>, covers = [], drive = Drive::Never)]
|
||||
fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let density = *data.choice("density", RailDensity::Dense, &[("Regular", RailDensity::Regular), ("Dense", RailDensity::Dense)]);
|
||||
let steps = *data.ranged("steps", 1_u16, 1.0..=2.0);
|
||||
let look = *data.choice("tabs", PanelTabLook::Plain, &[("Plain", PanelTabLook::Plain), ("Block", PanelTabLook::Block)]);
|
||||
let slots = Tracked::new((0..4_u8).map(|slot| ToolSlot::new(u32::from(slot), tools(&[slot]))).collect::<Vec<_>>());
|
||||
let last = Tracked::new(LastUsed::default());
|
||||
let cells = slots.len();
|
||||
@@ -64,14 +67,13 @@ fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, width);
|
||||
let rect = room.with_max_y(room.top() + CARD_HEIGHT);
|
||||
// The column takes the cell a dock gives it, as high as the dock, whatever its rail's height.
|
||||
let shown = DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(CardInset::Edge).show_groups_at(
|
||||
ui,
|
||||
rect,
|
||||
|_, rect, ui, _| {
|
||||
let shown = DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec)
|
||||
.card(CardInset::Edge)
|
||||
.tab_look(look)
|
||||
.show_groups_at(ui, rect, |_, rect, ui, _| {
|
||||
let rail = ToolRail::new("Tools", &slots, &BRUSH, &last).density(density);
|
||||
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| rail.show_rail(ui, |_, _| {}));
|
||||
},
|
||||
);
|
||||
});
|
||||
ui.advance_cursor_after_rect(rect);
|
||||
shown.into()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::dock_column::{
|
||||
BarRecord, CHEVRON, ColumnArrow, ColumnBar, bar_band, bar_slots, card_rect, card_style, column_grip, describe_chevron, paint_card, paint_chevron,
|
||||
register_edges, show_bar,
|
||||
};
|
||||
use super::group::{GripMarks, strip_surface};
|
||||
use super::group::GripMarks;
|
||||
use super::{CardInset, DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag};
|
||||
use crate::buttons::{ActiveLook, IconButton};
|
||||
use crate::contract::overlay::Anchor;
|
||||
@@ -701,12 +701,9 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
|
||||
fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) {
|
||||
// Painted here, not as the container's surface, which lies over what `paint` draws.
|
||||
let card = card_rect(cx.rect, self.card, &cx.style.sizes.column, self.edge, cx.flow.is_rtl());
|
||||
paint_card(ui, cx.rect, card, &cx.style.card);
|
||||
let bar = (self.bar == ColumnBar::Own).then_some(self.bar_rect);
|
||||
paint_card(ui, cx.rect, card, &cx.style.card, bar, self.tab_look);
|
||||
if self.bar == ColumnBar::Own {
|
||||
// A card's bar is part of the card.
|
||||
if self.card.is_none() {
|
||||
ui.draw().surface(self.bar_rect, strip_surface(self.tab_look), Corners::None);
|
||||
}
|
||||
paint_chevron(ui, self.edge, ColumnArrow::Collapse, self.expanded(), cx.flow.is_rtl(), &cx.words::<DockWords>());
|
||||
}
|
||||
let flat = self.flat();
|
||||
|
||||
Reference in New Issue
Block a user