stylang 0.1.0

A group of graphical interface description languages that separates style/class from behavior and layout
Documentation
use std::borrow::Cow;

use super::Value;

/// The widget display/search name.
#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Id<'a> {
    /// points to the offset num in the id table.
    Offset(usize),
    /// points to the real display string.
    Display(Cow<'a, str>),
}

/// The event type raised by stylang ui.
#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Event<'a> {
    Click,
    Hover,
    Custom(Cow<'a, str>),
}

/// Event handle type.
#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Handle<'a> {
    /// In-app navigation action.
    Navigation(Cow<'a, str>),
    /// A html href jumping action.
    Hyperlink(Cow<'a, str>),
    /// (Solidity) A smart contract calling.
    Solidity(Cow<'a, str>),
    /// Generic callback string,
    Callback(Cow<'a, str>),
}

///An attribute that append an event handler to an element.
#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OnEvent<'a> {
    /// event type.
    pub event: Event<'a>,
    /// event handle.
    pub handle: Handle<'a>,
}

/// Class attribute that applies to drawing element.
#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Class<'a> {
    /// Class from theme scope.
    Theme(Value<'a, Cow<'a, str>>),
    /// Class from application scope.
    App(Value<'a, Cow<'a, str>>),
}

/// A direction along either the horizontal or vertical Axis in which the origin, or zero position, is determined.
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum AxisDirection {
    Up,
    Right,
    Down,
    Left,
}