summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
Diffstat (limited to 'style')
-rw-r--r--style/Cargo.toml7
-rw-r--r--style/src/button.rs2
-rw-r--r--style/src/checkbox.rs2
-rw-r--r--style/src/lib.rs2
-rw-r--r--style/src/pane_grid.rs51
-rw-r--r--style/src/pick_list.rs2
-rw-r--r--style/src/progress_bar.rs2
-rw-r--r--style/src/radio.rs2
-rw-r--r--style/src/rule.rs18
-rw-r--r--style/src/toggler.rs57
10 files changed, 132 insertions, 13 deletions
diff --git a/style/Cargo.toml b/style/Cargo.toml
index ac16f8ee..a3086477 100644
--- a/style/Cargo.toml
+++ b/style/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "iced_style"
-version = "0.2.0"
+version = "0.3.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "The default set of styles of Iced"
@@ -10,5 +10,6 @@ documentation = "https://docs.rs/iced_style"
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]
-[dependencies]
-iced_core = { version = "0.3", path = "../core" }
+[dependencies.iced_core]
+version = "0.4"
+path = "../core"
diff --git a/style/src/button.rs b/style/src/button.rs
index 43d27216..2281e32f 100644
--- a/style/src/button.rs
+++ b/style/src/button.rs
@@ -2,7 +2,7 @@
use iced_core::{Background, Color, Vector};
/// The appearance of a button.
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub struct Style {
pub shadow_offset: Vector,
pub background: Option<Background>,
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index 1c5f2460..566136bb 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -2,7 +2,7 @@
use iced_core::{Background, Color};
/// The appearance of a checkbox.
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub struct Style {
pub background: Background,
pub checkmark_color: Color,
diff --git a/style/src/lib.rs b/style/src/lib.rs
index 7e0a9f49..08d9f044 100644
--- a/style/src/lib.rs
+++ b/style/src/lib.rs
@@ -10,6 +10,7 @@ pub mod button;
pub mod checkbox;
pub mod container;
pub mod menu;
+pub mod pane_grid;
pub mod pick_list;
pub mod progress_bar;
pub mod radio;
@@ -17,3 +18,4 @@ pub mod rule;
pub mod scrollable;
pub mod slider;
pub mod text_input;
+pub mod toggler;
diff --git a/style/src/pane_grid.rs b/style/src/pane_grid.rs
new file mode 100644
index 00000000..e39ee797
--- /dev/null
+++ b/style/src/pane_grid.rs
@@ -0,0 +1,51 @@
+//! Let your users split regions of your application and organize layout
+//! dynamically.
+use iced_core::Color;
+
+/// A set of rules that dictate the style of a container.
+pub trait StyleSheet {
+ /// The [`Line`] to draw when a split is picked.
+ fn picked_split(&self) -> Option<Line>;
+
+ /// The [`Line`] to draw when a split is hovered.
+ fn hovered_split(&self) -> Option<Line>;
+}
+
+/// A line.
+///
+/// It is normally used to define the highlight of something, like a split.
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub struct Line {
+ /// The [`Color`] of the [`Line`].
+ pub color: Color,
+
+ /// The width of the [`Line`].
+ pub width: f32,
+}
+
+struct Default;
+
+impl StyleSheet for Default {
+ fn picked_split(&self) -> Option<Line> {
+ None
+ }
+
+ fn hovered_split(&self) -> Option<Line> {
+ None
+ }
+}
+
+impl std::default::Default for Box<dyn StyleSheet> {
+ fn default() -> Self {
+ Box::new(Default)
+ }
+}
+
+impl<T> From<T> for Box<dyn StyleSheet>
+where
+ T: 'static + StyleSheet,
+{
+ fn from(style: T) -> Self {
+ Box::new(style)
+ }
+}
diff --git a/style/src/pick_list.rs b/style/src/pick_list.rs
index a757ba98..d1801e5f 100644
--- a/style/src/pick_list.rs
+++ b/style/src/pick_list.rs
@@ -5,6 +5,7 @@ use iced_core::{Background, Color};
#[derive(Debug, Clone, Copy)]
pub struct Style {
pub text_color: Color,
+ pub placeholder_color: Color,
pub background: Background,
pub border_radius: f32,
pub border_width: f32,
@@ -16,6 +17,7 @@ impl std::default::Default for Style {
fn default() -> Self {
Self {
text_color: Color::BLACK,
+ placeholder_color: [0.4, 0.4, 0.4].into(),
background: Background::Color([0.87, 0.87, 0.87].into()),
border_radius: 0.0,
border_width: 1.0,
diff --git a/style/src/progress_bar.rs b/style/src/progress_bar.rs
index 36be63f9..d0878c84 100644
--- a/style/src/progress_bar.rs
+++ b/style/src/progress_bar.rs
@@ -2,7 +2,7 @@
use iced_core::{Background, Color};
/// The appearance of a progress bar.
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub struct Style {
pub background: Background,
pub bar: Background,
diff --git a/style/src/radio.rs b/style/src/radio.rs
index 83310e05..c41b70c0 100644
--- a/style/src/radio.rs
+++ b/style/src/radio.rs
@@ -2,7 +2,7 @@
use iced_core::{Background, Color};
/// The appearance of a radio button.
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub struct Style {
pub background: Background,
pub dot_color: Color,
diff --git a/style/src/rule.rs b/style/src/rule.rs
index 5021340b..be4c86d1 100644
--- a/style/src/rule.rs
+++ b/style/src/rule.rs
@@ -79,6 +79,17 @@ pub struct Style {
pub fill_mode: FillMode,
}
+impl std::default::Default for Style {
+ fn default() -> Self {
+ Style {
+ color: [0.6, 0.6, 0.6, 0.51].into(),
+ width: 1,
+ radius: 0.0,
+ fill_mode: FillMode::Percent(90.0),
+ }
+ }
+}
+
/// A set of rules that dictate the style of a rule.
pub trait StyleSheet {
/// Produces the style of a rule.
@@ -89,12 +100,7 @@ struct Default;
impl StyleSheet for Default {
fn style(&self) -> Style {
- Style {
- color: [0.6, 0.6, 0.6, 0.51].into(),
- width: 1,
- radius: 0.0,
- fill_mode: FillMode::Percent(90.0),
- }
+ Style::default()
}
}
diff --git a/style/src/toggler.rs b/style/src/toggler.rs
new file mode 100644
index 00000000..5a155123
--- /dev/null
+++ b/style/src/toggler.rs
@@ -0,0 +1,57 @@
+//! Show toggle controls using togglers.
+use iced_core::Color;
+
+/// The appearance of a toggler.
+#[derive(Debug)]
+pub struct Style {
+ pub background: Color,
+ pub background_border: Option<Color>,
+ pub foreground: Color,
+ pub foreground_border: Option<Color>,
+}
+
+/// A set of rules that dictate the style of a toggler.
+pub trait StyleSheet {
+ fn active(&self, is_active: bool) -> Style;
+
+ fn hovered(&self, is_active: bool) -> Style;
+}
+
+struct Default;
+
+impl StyleSheet for Default {
+ fn active(&self, is_active: bool) -> Style {
+ Style {
+ background: if is_active {
+ Color::from_rgb(0.0, 1.0, 0.0)
+ } else {
+ Color::from_rgb(0.7, 0.7, 0.7)
+ },
+ background_border: None,
+ foreground: Color::WHITE,
+ foreground_border: None,
+ }
+ }
+
+ fn hovered(&self, is_active: bool) -> Style {
+ Style {
+ foreground: Color::from_rgb(0.95, 0.95, 0.95),
+ ..self.active(is_active)
+ }
+ }
+}
+
+impl std::default::Default for Box<dyn StyleSheet> {
+ fn default() -> Self {
+ Box::new(Default)
+ }
+}
+
+impl<T> From<T> for Box<dyn StyleSheet>
+where
+ T: 'static + StyleSheet,
+{
+ fn from(style: T) -> Self {
+ Box::new(style)
+ }
+}