tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1077HTML 1008Markdown 12TOML 83209 Definiciones

⎇ 22a79ba0ee895068d1c4b0598cbec5f479561b17 src/style/block.rs Rust · 42 líneas · 1.4 KB Historia Quién tocó qué crudo

Float layout WIP 22a79ba0e · Nico Burns ·

1//! Style types for Block layout
2use crate::{CoreStyle, Style};
3
4/// The set of styles required for a Block layout container
5pub trait BlockContainerStyle: CoreStyle {
6    /// Defines which row in the grid the item should start and end at
7    #[inline(always)]
8    fn text_align(&self) -> TextAlign {
9        Style::<Self::CustomIdent>::DEFAULT.text_align
10    }
11}
12
13/// The set of styles required for a Block layout item (child of a Block container)
14pub trait BlockItemStyle: CoreStyle {
15    /// Whether the item is a table. Table children are handled specially in block layout.
16    #[inline(always)]
17    fn is_table(&self) -> bool {
18        false
19    }
20
21    /// Whether the item is a floated
22    #[cfg(feature = "float_layout")]
23    #[inline(always)]
24    fn float(&self) -> super::Float {
25        super::Float::None
26    }
27}
28
29/// Used by block layout to implement the legacy behaviour of `<center>` and `<div align="left | right | center">`
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32pub enum TextAlign {
33    /// No special legacy text align behaviour.
34    #[default]
35    Auto,
36    /// Corresponds to `-webkit-left` or `-moz-left` in browsers
37    LegacyLeft,
38    /// Corresponds to `-webkit-right` or `-moz-right` in browsers
39    LegacyRight,
40    /// Corresponds to `-webkit-center` or `-moz-center` in browsers
41    LegacyCenter,
42}