mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 01:22:49 +00:00
Tile placeholders stand apart from a sunken surface
EnvView::surface reads the surface a component sits on, and a collection's rows sit on the surface the collection paints. A tile on a sunken surface fills its empty picture with the raised surface instead of the sunken one.
This commit is contained in:
@@ -433,10 +433,13 @@ impl<C: Collection> ShapeHooks<C> for ItemsHooks<'_, '_, C> {
|
||||
crate::runtime::commands::register_instance(&ctx, scope, id);
|
||||
}
|
||||
let child_size = comp.props(Internal::new()).child_size;
|
||||
// The rows sit on the surface the collection paints, else on the one the collection sits on.
|
||||
let own = surface.or_else(|| cx.style.surface().and_then(|look| look.kind_in(&cx.core.state)));
|
||||
let base_env = env.derive(|scoped| {
|
||||
scoped.extend_values(values);
|
||||
scoped.arena = Some(ArenaId::new(id));
|
||||
scoped.size = child_size.unwrap_or(cx.core.resolved.size);
|
||||
scoped.surface = SurfaceKind::under(own, scoped.surface);
|
||||
});
|
||||
self.header.paint(ui, cx, env, id, rtl);
|
||||
let len = self.source.len();
|
||||
@@ -717,8 +720,7 @@ impl<C: Collection> ShapeHooks<C> for ItemsHooks<'_, '_, C> {
|
||||
}
|
||||
if self.scrolls {
|
||||
let look = scroll_bar_look(&env.tokens, ScrollBarKind::Overlay);
|
||||
// The rows blend into the surface the collection paints, else the one it sits on.
|
||||
let own = surface.or_else(|| cx.style.surface().and_then(|look| look.kind_in(&cx.core.state)));
|
||||
// The rows blend into the surface they sit on.
|
||||
let background = surface_style(&env.tokens, SurfaceKind::under(own, env.surface)).fill;
|
||||
let hidden = HiddenContent::new(self.content, rect.size(), Vec2::new(self.offset_x as f32, self.offset as f32), rtl);
|
||||
ui.painter().extend(ScrollBar::fades(&look, rect, hidden, background));
|
||||
|
||||
+6
@@ -59,6 +59,12 @@ impl<'a> EnvView<'a> {
|
||||
self.scoped.inside_label.as_deref()
|
||||
}
|
||||
|
||||
/// The surface the component sits on: the innermost container or collection surface that paints a fill, else the
|
||||
/// window's background.
|
||||
pub fn surface(&self) -> crate::style::SurfaceKind {
|
||||
self.scoped.surface
|
||||
}
|
||||
|
||||
/// The flow direction: layout order, arrow keys and roving.
|
||||
pub fn direction(&self) -> Direction {
|
||||
self.scoped.direction
|
||||
|
||||
@@ -226,7 +226,9 @@ pub struct TileStyle {
|
||||
/// The glyph of a glyph badge.
|
||||
#[style(icon)]
|
||||
pill_icon: IconLook,
|
||||
/// The fill of a picture that shows nothing yet, and of one on a sunken surface, where the sunken fill would vanish.
|
||||
placeholder: StyleColor,
|
||||
placeholder_on_sunken: StyleColor,
|
||||
dim: StyleColor,
|
||||
/// The ring outside the picture: the accent when selected or current, the muted ink under the pointer.
|
||||
ring: Stateful<StyleColor>,
|
||||
@@ -664,6 +666,7 @@ impl Component for Tile<'_> {
|
||||
face: IconLook::new(sizes.face, fixed(text.muted)).on(fixed(colors.surface.sunken)),
|
||||
pill_icon: IconLook::new(sizes.glyph, pill.text.clone()).on(pill.fill.clone()),
|
||||
placeholder: c(colors.surface.sunken),
|
||||
placeholder_on_sunken: c(colors.surface.raised),
|
||||
dim: c(colors.surface.scrim.faded(DIM_VEIL)),
|
||||
ring,
|
||||
ring_width,
|
||||
@@ -814,7 +817,8 @@ impl Component for Tile<'_> {
|
||||
if style.sizes.card {
|
||||
ui.draw().surface(picture, SurfaceKind::Sunken, Corners::All);
|
||||
} else {
|
||||
ui.draw().fill(&PaintShape::Rect(picture, flat), style.placeholder);
|
||||
let placeholder = if cx.env.surface() == SurfaceKind::Sunken { style.placeholder_on_sunken } else { style.placeholder };
|
||||
ui.draw().fill(&PaintShape::Rect(picture, flat), placeholder);
|
||||
}
|
||||
if let Some(paint) = self.first.take() {
|
||||
let _ = ui.child("picture", picture, RowThumb::new(paint));
|
||||
|
||||
Reference in New Issue
Block a user