///|
pub(all) enum MainAxisAlignment {
MainStart
MainCenter
MainEnd
SpaceBetween
SpaceAround
SpaceEvenly
} derive(Eq, Debug, ToJson)
///|
pub extend MainAxisAlignment with Debug::{to_repr}
///|
pub extend MainAxisAlignment with Eq::{not_equal, equal}
///|
pub extend MainAxisAlignment with ToJson::{to_json}
///|
pub(all) enum CrossAxisAlignment {
CrossStart
CrossCenter
CrossEnd
CrossStretch
} derive(Eq, Debug, ToJson)
///|
pub extend CrossAxisAlignment with Debug::{to_repr}
///|
pub extend CrossAxisAlignment with Eq::{not_equal, equal}
///|
pub extend CrossAxisAlignment with ToJson::{to_json}
///|
pub(all) struct Alignment {
x : Double
y : Double
} derive(Eq, Debug, ToJson)
///|
pub extend Alignment with Debug::{to_repr}
///|
pub extend Alignment with Eq::{not_equal, equal}
///|
pub extend Alignment with ToJson::{to_json}
///|
pub(all) struct KeyboardShortcut {
key : String
modifiers : KeyModifiers
} derive(Eq, Debug, ToJson)
///|
pub extend KeyboardShortcut with Debug::{to_repr}
///|
pub extend KeyboardShortcut with Eq::{not_equal, equal}
///|
pub extend KeyboardShortcut with ToJson::{to_json}
///|
pub(all) enum PressableState {
Normal
Hovered
Pressed
} derive(Eq, Debug, ToJson)
///|
pub extend PressableState with Debug::{to_repr}
///|
pub extend PressableState with Eq::{not_equal, equal}
///|
pub extend PressableState with ToJson::{to_json}
///|
pub(all) struct ViewStyle {
font : FontSpec?
foreground : Color?
background : Brush?
corner_radius : Double?
} derive(Eq, Debug, ToJson)
///|
pub extend ViewStyle with Debug::{to_repr}
///|
pub extend ViewStyle with Eq::{not_equal, equal}
///|
pub extend ViewStyle with ToJson::{to_json}
///|
pub(all) enum ImageFit {
Contain
Cover
Stretch
ScaleDown
FitWidth
FitHeight
} derive(Eq, Debug, ToJson)
///|
pub extend ImageFit with Debug::{to_repr}
///|
pub extend ImageFit with Eq::{not_equal, equal}
///|
pub extend ImageFit with ToJson::{to_json}
///|
pub(all) struct ShadowStyle {
color : Color
offset : Point
blur_radius : Double
spread : Double
} derive(Eq, Debug, ToJson)
///|
pub extend ShadowStyle with Debug::{to_repr}
///|
pub extend ShadowStyle with Eq::{not_equal, equal}
///|
pub extend ShadowStyle with ToJson::{to_json}
///|
pub(all) struct BorderStyle {
brush : Brush
width : Double
} derive(Eq, Debug, ToJson)
///|
pub extend BorderStyle with Debug::{to_repr}
///|
pub extend BorderStyle with Eq::{not_equal, equal}
///|
pub extend BorderStyle with ToJson::{to_json}
///|
pub(all) struct VisualStyle {
background : Brush?
foreground : Color?
border : BorderStyle?
shadow : ShadowStyle?
radius : Double?
opacity : Double?
} derive(Eq, Debug, ToJson)
///|
pub extend VisualStyle with Debug::{to_repr}
///|
pub extend VisualStyle with Eq::{not_equal, equal}
///|
pub extend VisualStyle with ToJson::{to_json}
///|
pub fn ViewStyle::empty() -> ViewStyle {
{ font: None, foreground: None, background: None, corner_radius: None, }
}
///|
pub fn ShadowStyle::new(
color~ : Color,
offset? : Point = Point::new(x=0.0, y=2.0),
blur_radius? : Double = 8.0,
spread? : Double = 0.0,
) -> ShadowStyle {
{ color, offset, blur_radius, spread, }
}
///|
pub fn BorderStyle::new(brush~ : Brush, width? : Double = 1.0) -> BorderStyle {
{ brush, width, }
}
///|
pub fn VisualStyle::empty() -> VisualStyle {
{
background: None,
foreground: None,
border: None,
shadow: None,
radius: None,
opacity: None,
}
}
///|
pub fn Alignment::new(x~ : Double, y~ : Double) -> Alignment {
{ x: clamp_double(x, -1.0, 1.0), y: clamp_double(y, -1.0, 1.0), }
}
///|
pub fn Alignment::center() -> Alignment {
Alignment::new(x=0.0, y=0.0)
}
///|
pub fn Alignment::top_leading() -> Alignment {
Alignment::new(x=-1.0, y=-1.0)
}
///|
pub fn Alignment::top_trailing() -> Alignment {
Alignment::new(x=1.0, y=-1.0)
}
///|
pub fn Alignment::bottom_leading() -> Alignment {
Alignment::new(x=-1.0, y=1.0)
}
///|
pub fn Alignment::bottom_trailing() -> Alignment {
Alignment::new(x=1.0, y=1.0)
}
///|
pub fn KeyboardShortcut::new(
key~ : String,
modifiers? : KeyModifiers = KeyModifiers::none(),
) -> KeyboardShortcut {
{ key, modifiers, }
}
///|
pub fn KeyboardShortcut::matches(
self : KeyboardShortcut,
event : KeyboardEvent,
) -> Bool {
event.pressed && event.key == self.key && event.modifiers == self.modifiers
}
///|
pub fn ViewStyle::merge(self : ViewStyle, next : ViewStyle) -> ViewStyle {
{
font: option_prefer(next.font, self.font),
foreground: option_prefer(next.foreground, self.foreground),
background: option_prefer(next.background, self.background),
corner_radius: option_prefer(next.corner_radius, self.corner_radius),
}
}
///|
fn[T] option_prefer(value : T?, fallback : T?) -> T? {
match value {
Some(_) => value
None => fallback
}
}