Commit dd85e134 authored by Florian Blasius's avatar Florian Blasius 🤘

[wip] add more styling properties.

parent dcaf03d0
use crate::structs::Brush;
// todo: documentation and methods
pub struct Background {
pub value: Brush,
}
/// Used to draw the background brush of a widget.
pub struct Background(pub Brush);
property!(
Background,
BackgroundProperty,
background,
shared_background
);
impl Default for Background {
fn default() -> Background {
Background {
value: Brush::from("#000000"),
}
"#000000".into()
}
}
impl From<&str> for Background {
fn from(s: &str) -> Background {
Background(s.into())
}
}
\ No newline at end of file
use crate::structs::Brush;
/// Used to draw the border brush of a widget.
pub struct BorderBrush(pub Brush);
property!(
BorderBrush,
BorderBrushProperty,
border_brush,
shared_border_brush
);
impl Default for BorderBrush {
fn default() -> BorderBrush {
"#000000".into()
}
}
impl From<&str> for BorderBrush {
fn from(s: &str) -> BorderBrush {
BorderBrush(s.into())
}
}
\ No newline at end of file
/// Represents the degree to which the corners of a Border are rounded.
pub struct BorderRadius(pub f64);
property!(
BorderRadius,
BorderRadiusProperty,
border_radius,
shared_border_radius
);
impl From<f64> for BorderRadius {
fn from(t: f64) -> Self {
BorderRadius(t)
}
}
use crate::structs::{Spacer, Thickness};
/// Represents relative thickness of a Border.
pub struct BorderThickness(pub Thickness);
property!(
BorderThickness,
BorderThicknessProperty,
border_thickness,
shared_border_thickness
);
impl Spacer for BorderThickness {
fn left(&self) -> f64 {
self.0.left
}
fn set_left(&mut self, left: f64) {
self.0.left = left;
}
fn top(&self) -> f64 {
self.0.top
}
fn set_top(&mut self, top: f64) {
self.0.top = top;
}
fn right(&self) -> f64 {
self.0.right
}
fn set_right(&mut self, right: f64) {
self.0.right = right;
}
fn bottom(&self) -> f64 {
self.0.bottom
}
fn set_bottom(&mut self, bottom: f64) {
self.0.bottom = bottom;
}
fn thickness(&self) -> Thickness {
self.0
}
fn set_thickness(&mut self, thickness: Thickness) {
self.0 = thickness;
}
}
impl From<(f64, f64, f64, f64)> for BorderThickness {
fn from(t: (f64, f64, f64, f64)) -> Self {
BorderThickness(Thickness::new(t.0, t.1, t.2, t.3))
}
}
impl From<(f64, f64)> for BorderThickness {
fn from(t: (f64, f64)) -> Self {
BorderThickness(Thickness::new(t.0, t.1, t.0, t.1))
}
}
impl From<f64> for BorderThickness {
fn from(t: f64) -> Self {
BorderThickness(Thickness::new(t, t, t, t))
}
}
use orbgl_api::Font as OrbGLFont;
pub struct Font(OrbGLFont);
\ No newline at end of file
/// Represents the font size of an text element.
pub struct FontSize(pub f64);
property!(
FontSize,
FontSizeProperty,
font_size,
shared_font_size
);
impl From<f64> for FontSize {
fn from(t: f64) -> Self {
FontSize(t)
}
}
use crate::structs::Brush;
/// Used to draw the foreground brush of a widget.
pub struct Foreground(pub Brush);
property!(
Foreground,
ForegroundProperty,
foreground,
shared_foreground
);
impl Default for Foreground {
fn default() -> Foreground {
"#000000".into()
}
}
impl From<&str> for Foreground {
fn from(s: &str) -> Foreground {
Foreground(s.into())
}
}
\ No newline at end of file
// Styling related properties.
pub use self::background::Background;
pub use self::background::{Background, BackgroundProperty};
mod background;
mod border_brush;
mod border_radius;
mod border_thickness;
mod font_size;
mod foreground;
mod icon_font;
mod icon_size;
#[cfg(test)]
mod tests;
\ No newline at end of file
use super::*;
mod background;
mod border_brush;
mod border_radius;
mod border_thickness;
mod font_size;
mod font;
mod foreground;
mod icon_font;
mod icon_size;
\ No newline at end of file
use crate::{
layout::PaddingLayout,
properties::PaddingProperty,
properties::{BackgroundProperty, PaddingProperty},
shapes::Rectangle,
widget::{Template, Widget},
};
/// The `Container` represents a layout that surrounds its child with a padding. Draws a box arround the child.
/// The `Container` represents a layout that surrounds its child with a padding. Draws a box around the child.
///
/// # Properties
///
/// * `selector` - CSS selector with element name `container`, used to request the theme of the widget.
/// * `background` - background drawing brush.
/// * `padding` - gap to the child.
///
/// # Others
///
......@@ -30,4 +31,4 @@ impl Widget for Container {
}
}
template!(ContainerTemplate, [PaddingProperty]);
template!(ContainerTemplate, [BackgroundProperty, PaddingProperty]);
use crate::{
enums::ParentType,
layout::GridLayout,
properties::{Columns, ColumnsProperty, Rows, RowsProperty},
properties::{Columns, ColumnsProperty, Rows, RowsProperty, BackgroundProperty},
shapes::Rectangle,
widget::{Template, Widget},
};
......@@ -11,9 +11,10 @@ use crate::{
/// # Properties
///
/// * `columns` - used to define the columns of the grid.
/// * `background` - background brush of the grid.
/// * `rows` - used to define the rows of the grid.
/// * `selector` - css selector with element `grid`.
///
///
/// # Others
///
/// * `ParentType`- Multi.
......@@ -35,4 +36,4 @@ impl Widget for Grid {
}
}
template!(GridTemplate, [RowsProperty, ColumnsProperty]);
template!(GridTemplate, [BackgroundProperty, RowsProperty, ColumnsProperty]);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment