Commit 5a827093 authored by Florian Blasius's avatar Florian Blasius 🤘

[#157] refactor theme code to move it to

own sub crate.
parent 03aef195
Pipeline #3836 passed with stages
in 6 minutes and 31 seconds
......@@ -41,6 +41,11 @@ name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bumpalo"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "1.3.1"
......@@ -312,6 +317,14 @@ name = "linked-hash-map"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lzw"
version = "0.10.0"
......@@ -427,7 +440,7 @@ dependencies = [
"orbclient 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
"orbgl_api 0.1.0 (git+https://gitlab.redox-os.org/redox-os/orbgl.git)",
"rust-cairo 0.1.0 (git+https://gitlab.redox-os.org/redox-os/rust-cairo.git)",
"stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -438,7 +451,7 @@ dependencies = [
"orbclient 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
"orbfont 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"orbimage 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -463,10 +476,19 @@ dependencies = [
"orbgl 0.1.0 (git+https://gitlab.redox-os.org/redox-os/orbgl.git)",
"orbgl_api 0.1.0 (git+https://gitlab.redox-os.org/redox-os/orbgl.git)",
"orbimage 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"orbtk-css-engine 0.1.0",
"orbtk-structs 0.1.0",
"orbtk-web-window 0.1.0",
]
[[package]]
name = "orbtk-css-engine"
version = "0.1.0"
dependencies = [
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"orbtk-structs 0.1.0",
]
[[package]]
name = "orbtk-structs"
version = "0.1.0"
......@@ -479,7 +501,7 @@ name = "orbtk-web-window"
version = "0.1.0"
dependencies = [
"orbtk-structs 0.1.0",
"stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -883,7 +905,7 @@ dependencies = [
[[package]]
name = "stdweb"
version = "0.4.15"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -891,8 +913,9 @@ dependencies = [
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -909,7 +932,7 @@ dependencies = [
[[package]]
name = "stdweb-internal-macros"
version = "0.2.6"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -985,6 +1008,54 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bumpalo 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.2.8"
......@@ -1022,6 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum bumpalo 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a6bc2ba935b1e2f810787ceba8dfe86cbc164cee55925cae715541186673c4"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4390a3b5f4f6bce9c1d0c00128379df433e53777fdd30e92f16a529332baec4e"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
......@@ -1056,6 +1128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
......@@ -1122,9 +1195,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "69b7df505db8e81d54ff8be4693421e5b543e08214bd8d99eb761fcb4d5668ba"
"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb"
"checksum stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c1d5ac2f828b2877a6be60a51b8e3ebb57b56862b10be1a72676ca8900b69d"
"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930"
"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887"
"checksum stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa"
"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
......@@ -1133,6 +1206,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4"
"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1"
"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71"
"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385"
"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
......
......@@ -32,6 +32,7 @@ orbclient = "0.3.21"
[dependencies]
orbtk-structs = { version = "0.1.0", path = "crates/structs" }
orbtk-css-engine = { version = "0.1.0", path = "crates/css-engine" }
cssparser = "0.17.0"
lazy_static = "1.3.0"
# dces = { path = "../dces-rust"}
......
[package]
name = "orbtk-css-engine"
version = "0.1.0"
authors = ["Florian Blasius <flovanpt@posteo.de>"]
description = "CSS engine used to theme OrbTk."
repository = "https://gitlab.redox-os.org/redox-os/orbtk"
license = "MIT"
keywords = ["css", "theme", "styling", "ui"]
edition = "2018"
[dependencies]
orbtk-structs = { version = "0.1.0", path = "../structs" }
cssparser = "0.17.0"
\ No newline at end of file
pub use selector::*;
pub use theme::*;
pub mod prelude;
mod selector;
mod theme;
pub use crate::*;
\ No newline at end of file
use std::{collections::HashSet, ops::Add};
use std::fmt;
#[derive(Clone, Debug)]
pub enum SelectorRelation {
Ancestor(Selector),
Parent(Selector),
}
/// Describes the specificity of a selector.
///
/// The indexes are as follows:
/// 0 - number of IDs (most important)
/// 1 - number of classes and pseudo-classes
/// 2 - number of elements (least important)
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Specificity([u8; 3]);
impl Add<Self> for Specificity {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Specificity([
self.0[0] + rhs.0[0],
self.0[1] + rhs.0[1],
self.0[2] + rhs.0[2],
])
}
}
/// Describes a css selector.
#[derive(Debug, Default)]
pub struct Selector {
pub id: Option<String>,
pub element: Option<String>,
pub classes: HashSet<String>,
pub pseudo_classes: HashSet<String>,
pub relation: Option<Box<SelectorRelation>>,
pub dirty: bool,
}
/// Inner selector value.
impl Selector {
pub fn new() -> Self {
Selector {
id: None,
element: None,
classes: HashSet::new(),
pseudo_classes: HashSet::new(),
relation: None,
dirty: true,
}
}
pub fn is_empty(&self) -> bool {
self.element.is_none()
&& self.id.is_none()
&& self.classes.is_empty()
&& self.pseudo_classes.is_empty()
}
pub fn dirty(&self) -> bool {
self.dirty
}
pub fn set_dirty(&mut self, dirty: bool) {
self.dirty = dirty;
}
pub fn specificity(&self) -> Specificity {
let s = Specificity([
if self.id.is_some() { 1 } else { 0 },
(self.classes.len() + self.pseudo_classes.len()) as u8,
if self.element.is_some() { 1 } else { 0 },
]);
if let Some(ref relation) = self.relation {
match **relation {
SelectorRelation::Ancestor(ref x) | SelectorRelation::Parent(ref x) => {
return x.specificity() + s;
}
}
}
s
}
pub fn matches(&self, other: &Selector) -> bool {
if self.id.is_some() && self.id != other.id {
return false;
}
if self.element.is_some() && self.element != other.element {
return false;
}
if !other.classes.is_superset(&self.classes) {
return false;
}
if !other.pseudo_classes.is_superset(&self.pseudo_classes) {
return false;
}
true
}
pub fn with<S: Into<String>>(mut self, element: S) -> Self {
self.element = Some(element.into());
self
}
pub fn id<S: Into<String>>(mut self, id: S) -> Self {
self.id = Some(id.into());
self
}
pub fn class<S: Into<String>>(mut self, class: S) -> Self {
self.classes.insert(class.into());
self
}
pub fn without_class<S: Into<String>>(mut self, class: S) -> Self {
self.classes.remove(&class.into());
self
}
pub fn pseudo_class<S: Into<String>>(mut self, pseudo_class: S) -> Self {
self.pseudo_classes.insert(pseudo_class.into());
self
}
pub fn without_pseudo_class<S: Into<String>>(mut self, pseudo_class: S) -> Self {
self.pseudo_classes.remove(&pseudo_class.into());
self
}
}
impl PartialEq for Selector {
fn eq(&self, other: &Selector) -> bool {
self.id == other.id
}
}
impl Clone for Selector {
fn clone(&self) -> Self {
Selector {
id: self.id.clone(),
element: self.element.clone(),
classes: self.classes.clone(),
pseudo_classes: self.pseudo_classes.clone(),
relation: self.relation.clone(),
dirty: self.dirty,
}
}
}
impl fmt::Display for Selector {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(element) = &self.element {
return write!(f, ", css: {}", element);
}
write!(f, "")
}
}
\ No newline at end of file
......@@ -9,6 +9,6 @@ keywords = ["windowing", "wasm"]
edition = "2018"
[dependencies]
stdweb = "0.4.15"
stdweb = "0.4.16"
orbtk-structs = { version = "0.1.0", path = "../structs" }
......@@ -11,7 +11,7 @@ use crate::{
backend::{FontMeasure, FONT_MEASURE},
properties::{
Bounds, Constraint, Font, FontIcon, FontSize, HorizontalAlignment, IconFont, IconSize,
Image, Text, VerticalAlignment, Visibility, VisibilityValue, WaterMark, ImageExtension, ConstraintExtension,
Image, Text, VerticalAlignment, Visibility, VisibilityValue, WaterMark, ImageExt, ConstraintExt,
},
enums::Alignment,
structs::{DirtySize, Size},
......
......@@ -9,7 +9,7 @@ use dces::prelude::{Entity, EntityComponentManager};
use crate::{
application::Tree,
properties::{
Bounds, Constraint, HorizontalAlignment, Margin, Padding, VerticalAlignment, Visibility, VisibilityValue, ConstraintExtension,
Bounds, Constraint, HorizontalAlignment, Margin, Padding, VerticalAlignment, Visibility, VisibilityValue, ConstraintExt,
},
enums::Alignment,
structs::{DirtySize, Position, Size, Spacer},
......
......@@ -24,8 +24,10 @@ pub use crate::theme::*;
pub use crate::widgets::*;
pub use dces::prelude::*;
pub use orbtk_css_engine::prelude as css_engine;
pub use orbtk_structs::prelude as structs;
pub mod application;
pub mod backend;
pub mod enums;
......
......@@ -20,5 +20,6 @@ pub use crate::{
theme::*,
widgets::*,
widget,
property
property,
css_engine::Selector as SelectorValue
};
\ No newline at end of file
......@@ -8,7 +8,7 @@ property!(
// --- Trait implementations ---
/// Contains different methods to check the bounds.
pub trait BoundsExtension {
pub trait BoundsExt {
/// Check if this rect contains the given `point`.
fn contains(&self, point: (f64, f64)) -> bool;
......@@ -19,7 +19,7 @@ pub trait BoundsExtension {
fn intersects(&self, rect: &Bounds) -> bool;
}
impl BoundsExtension for Bounds {
impl BoundsExt for Bounds {
fn contains(&self, point: (f64, f64)) -> bool {
point.0 >= self.0.x
&& point.0 < self.0.x + self.0.width
......
......@@ -171,7 +171,7 @@ property!(
// --- Trait implementations ---
/// Provides additional operations on grid columns.
pub trait ColumnExtension {
pub trait ColumnExt {
fn create() -> ColumnsBuilder;
/// Returns the number of elements in the columns list, also referred to as its 'length'.
......@@ -190,7 +190,7 @@ pub trait ColumnExtension {
fn iter_mut(&mut self) -> IterMut<Column>;
}
impl ColumnExtension for Columns {
impl ColumnExt for Columns {
/// Creates a new `ColumnsBuilder` object with default values.
fn create() -> ColumnsBuilder {
ColumnsBuilder::new()
......
......@@ -124,7 +124,7 @@ property!(
// --- Trait implementations ---
/// Provides operations on a box constraint.
pub trait ConstraintExtension {
pub trait ConstraintExt {
/// Returns a constraint builder.
fn create() -> ConstraintBuilder;
......@@ -186,7 +186,7 @@ pub trait ConstraintExtension {
fn perform(&self, size: (f64, f64)) -> (f64, f64);
}
impl ConstraintExtension for BoxConstraint {
impl ConstraintExt for BoxConstraint {
fn create() -> ConstraintBuilder {
ConstraintBuilder::new()
}
......@@ -285,7 +285,7 @@ impl ConstraintExtension for BoxConstraint {
}
}
impl ConstraintExtension for Constraint {
impl ConstraintExt for Constraint {
fn create() -> ConstraintBuilder {
ConstraintBuilder::new()
}
......
......@@ -10,7 +10,7 @@ property!(
// --- Trait implementations ---
/// Used to align the position of a widget vertical.
pub trait HorizontalAlignmentExtension {
pub trait HorizontalAlignmentExt {
/// Calculates the x position of the widget depending on the available width, the goal width
/// margin and Horizontal alignment.
fn align_x(&self, available_height: f64, height: f64, margin: Margin) -> f64;
......@@ -20,7 +20,7 @@ pub trait HorizontalAlignmentExtension {
fn align_width(&self, available_height: f64, height: f64, margin: Margin) -> f64;
}
impl HorizontalAlignmentExtension for HorizontalAlignment {
impl HorizontalAlignmentExt for HorizontalAlignment {
fn align_x(&self, available_height: f64, height: f64, margin: Margin) -> f64 {
self.0
.align_position(available_height, height, margin.left(), margin.right())
......
......@@ -170,7 +170,7 @@ property!(
// --- Trait implementations ---
/// Provides additional operations on grid rows.
pub trait RowExtension {
pub trait RowExt {
/// Returns a new Rows Builder.
fn create() -> RowsBuilder;
......@@ -190,7 +190,7 @@ pub trait RowExtension {
fn iter_mut(&mut self) -> IterMut<Row>;
}
impl RowExtension for Rows {
impl RowExt for Rows {
/// Creates a new `RowsBuilder` object with default values.
fn create() -> RowsBuilder {
RowsBuilder::new()
......
......@@ -8,7 +8,7 @@ property!(
// --- Trait implementations ---
/// Used to align the position of a widget vertical.
pub trait VerticalAlignmentExtension {
pub trait VerticalAlignmentExt {
/// Calculates the y position of the widget depending on the available height, the goal height
/// margin and Vertical alignment.
fn align_y(&self, available_height: f64, height: f64, margin: Margin) -> f64;
......@@ -18,7 +18,7 @@ pub trait VerticalAlignmentExtension {
fn align_height(&self, available_height: f64, height: f64, margin: Margin) -> f64;
}
impl VerticalAlignmentExtension for VerticalAlignment {
impl VerticalAlignmentExt for VerticalAlignment {
fn align_y(&self, available_height: f64, height: f64, margin: Margin) -> f64 {
self.0
.align_position(available_height, height, margin.top(), margin.bottom())
......
......@@ -38,11 +38,19 @@ impl From<Box<[u8]>> for InnerFont {
}
}
property!(/// `Font` describes the text font of a widget.
Font(InnerFont));
property!(
/// `Font` describes the text font of a widget.
Font(InnerFont)
);
// --- Conversions ---
impl From<OrbFont> for Font {
fn from(s: OrbFont) -> Font {
Font::from(InnerFont::from(s))
}
}
impl From<&str> for Font {
fn from(s: &str) -> Font {
Font::from(InnerFont::from(OrbFont::from_path(s).unwrap()))
......
......@@ -9,6 +9,12 @@ property!(
// --- Conversions ---
impl From<OrbFont> for IconFont {
fn from(s: OrbFont) -> IconFont {
IconFont::from(InnerFont::from(s))
}
}
impl From<&str> for IconFont {
fn from(s: &str) -> IconFont {
IconFont::from(InnerFont::from(OrbFont::from_path(s).unwrap()))
......
use std::{collections::HashSet, ops::Add};
use std::fmt;
use crate::prelude::*;
#[derive(Clone, Debug)]
pub enum SelectorRelation {
Ancestor(SelectorValue),
Parent(SelectorValue),
}
/// Describes the specificity of a selector.
///
/// The indexes are as follows:
/// 0 - number of IDs (most important)
/// 1 - number of classes and pseudo-classes
/// 2 - number of elements (least important)
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Specificity([u8; 3]);