summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/scrollable/src/style.rs1
-rw-r--r--examples/styling/src/main.rs3
-rw-r--r--lazy/src/component.rs11
-rw-r--r--lazy/src/responsive.rs10
-rw-r--r--native/src/user_interface.rs6
-rw-r--r--native/src/widget/checkbox.rs14
-rw-r--r--native/src/widget/radio.rs30
-rw-r--r--style/src/checkbox.rs4
-rw-r--r--style/src/radio.rs2
9 files changed, 41 insertions, 40 deletions
diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs
index ec1f13db..0ed38b00 100644
--- a/examples/scrollable/src/style.rs
+++ b/examples/scrollable/src/style.rs
@@ -116,6 +116,7 @@ mod dark {
dot_color: ACTIVE,
border_width: 1.0,
border_color: ACTIVE,
+ text_color: None,
}
}
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index 065764b3..b4ef3e87 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -343,6 +343,7 @@ mod style {
dot_color: ACTIVE,
border_width: 1.0,
border_color: ACTIVE,
+ text_color: None,
}
}
@@ -528,10 +529,10 @@ mod style {
background: if is_checked { ACTIVE } else { SURFACE }
.into(),
checkmark_color: Color::WHITE,
- text_color: Color::BLACK,
border_radius: 2.0,
border_width: 1.0,
border_color: ACTIVE,
+ text_color: None,
}
}
diff --git a/lazy/src/component.rs b/lazy/src/component.rs
index 2b729045..00c27989 100644
--- a/lazy/src/component.rs
+++ b/lazy/src/component.rs
@@ -263,12 +263,17 @@ where
.build(),
);
- cache.as_ref().unwrap().borrow_overlay().is_some()
+ cache
+ .as_ref()
+ .unwrap()
+ .borrow_overlay()
+ .as_ref()
+ .map(|overlay| overlay.position())
});
- has_overlay.then(|| {
+ has_overlay.map(|position| {
overlay::Element::new(
- layout.position(),
+ position,
Box::new(Overlay { instance: self }),
)
})
diff --git a/lazy/src/responsive.rs b/lazy/src/responsive.rs
index da7bb408..35ad6974 100644
--- a/lazy/src/responsive.rs
+++ b/lazy/src/responsive.rs
@@ -6,6 +6,7 @@ use iced_native::layout::{self, Layout};
use iced_native::mouse;
use iced_native::overlay;
use iced_native::renderer;
+use iced_native::window;
use iced_native::{
Clipboard, Element, Hasher, Length, Point, Rectangle, Shell, Size, Widget,
};
@@ -100,7 +101,10 @@ where
) -> event::Status {
let mut internal = self.0.borrow_mut();
- if internal.state.last_size != Some(internal.state.last_layout.size()) {
+ if matches!(event, Event::Window(window::Event::Resized { .. }))
+ || internal.state.last_size
+ != Some(internal.state.last_layout.size())
+ {
shell.invalidate_widgets();
}
@@ -268,7 +272,9 @@ where
hasher.finish()
};
- if new_layout_hash != state.last_layout_hash {
+ if state.last_size != Some(state.last_layout.size())
+ || new_layout_hash != state.last_layout_hash
+ {
state.last_layout = element.layout(
renderer.deref(),
&layout::Limits::new(
diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs
index 4b1194be..f6ec96bb 100644
--- a/native/src/user_interface.rs
+++ b/native/src/user_interface.rs
@@ -391,7 +391,7 @@ where
let viewport = Rectangle::with_size(self.bounds);
- if let Some(mut overlay) =
+ self.overlay = if let Some(mut overlay) =
self.root.overlay(Layout::new(&self.base.layout), renderer)
{
let layer = Self::overlay_layer(
@@ -401,7 +401,9 @@ where
renderer,
);
- self.overlay = Some(layer);
+ Some(layer)
+ } else {
+ None
};
if let Some(layer) = &self.overlay {
diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs
index a314140c..fff65a40 100644
--- a/native/src/widget/checkbox.rs
+++ b/native/src/widget/checkbox.rs
@@ -10,8 +10,8 @@ use crate::text;
use crate::touch;
use crate::widget::{self, Row, Text};
use crate::{
- Alignment, Clipboard, Color, Element, Hasher, Layout, Length, Point,
- Rectangle, Shell, Widget,
+ Alignment, Clipboard, Element, Hasher, Layout, Length, Point, Rectangle,
+ Shell, Widget,
};
pub use iced_style::checkbox::{Style, StyleSheet};
@@ -43,7 +43,6 @@ pub struct Checkbox<'a, Message, Renderer: text::Renderer> {
spacing: u16,
text_size: Option<u16>,
font: Renderer::Font,
- text_color: Option<Color>,
style_sheet: Box<dyn StyleSheet + 'a>,
}
@@ -75,7 +74,6 @@ impl<'a, Message, Renderer: text::Renderer> Checkbox<'a, Message, Renderer> {
spacing: Self::DEFAULT_SPACING,
text_size: None,
font: Renderer::Font::default(),
- text_color: None,
style_sheet: Default::default(),
}
}
@@ -112,12 +110,6 @@ impl<'a, Message, Renderer: text::Renderer> Checkbox<'a, Message, Renderer> {
self
}
- /// Sets the text color of the [`Checkbox`] button.
- pub fn text_color(mut self, color: Color) -> Self {
- self.text_color = Some(color);
- self
- }
-
/// Sets the style of the [`Checkbox`].
pub fn style(
mut self,
@@ -264,7 +256,7 @@ where
&self.label,
self.font.clone(),
self.text_size,
- self.text_color.or(Some(custom_style.text_color)),
+ custom_style.text_color,
alignment::Horizontal::Left,
alignment::Vertical::Center,
);
diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs
index c6cc46ed..c4992764 100644
--- a/native/src/widget/radio.rs
+++ b/native/src/widget/radio.rs
@@ -51,7 +51,6 @@ pub struct Radio<'a, Message, Renderer: text::Renderer> {
size: u16,
spacing: u16,
text_size: Option<u16>,
- text_color: Option<Color>,
font: Renderer::Font,
style_sheet: Box<dyn StyleSheet + 'a>,
}
@@ -92,7 +91,6 @@ where
size: Self::DEFAULT_SIZE,
spacing: Self::DEFAULT_SPACING, //15
text_size: None,
- text_color: None,
font: Default::default(),
style_sheet: Default::default(),
}
@@ -122,12 +120,6 @@ where
self
}
- /// Sets the text color of the [`Radio`] button.
- pub fn text_color(mut self, color: Color) -> Self {
- self.text_color = Some(color);
- self
- }
-
/// Sets the text font of the [`Radio`] button.
pub fn font(mut self, font: Renderer::Font) -> Self {
self.font = font;
@@ -231,6 +223,12 @@ where
let mut children = layout.children();
+ let custom_style = if is_mouse_over {
+ self.style_sheet.hovered()
+ } else {
+ self.style_sheet.active()
+ };
+
{
let layout = children.next().unwrap();
let bounds = layout.bounds();
@@ -238,20 +236,14 @@ where
let size = bounds.width;
let dot_size = size / 2.0;
- let style = if is_mouse_over {
- self.style_sheet.hovered()
- } else {
- self.style_sheet.active()
- };
-
renderer.fill_quad(
renderer::Quad {
bounds,
border_radius: size / 2.0,
- border_width: style.border_width,
- border_color: style.border_color,
+ border_width: custom_style.border_width,
+ border_color: custom_style.border_color,
},
- style.background,
+ custom_style.background,
);
if self.is_selected {
@@ -267,7 +259,7 @@ where
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
- style.dot_color,
+ custom_style.dot_color,
);
}
}
@@ -282,7 +274,7 @@ where
&self.label,
self.font.clone(),
self.text_size,
- self.text_color,
+ custom_style.text_color,
alignment::Horizontal::Left,
alignment::Vertical::Center,
);
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index 77aae42b..de52e548 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -6,10 +6,10 @@ use iced_core::{Background, Color};
pub struct Style {
pub background: Background,
pub checkmark_color: Color,
- pub text_color: Color,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
+ pub text_color: Option<Color>,
}
/// A set of rules that dictate the style of a checkbox.
@@ -26,10 +26,10 @@ impl StyleSheet for Default {
Style {
background: Background::Color(Color::from_rgb(0.95, 0.95, 0.95)),
checkmark_color: Color::from_rgb(0.3, 0.3, 0.3),
- text_color: Color::BLACK,
border_radius: 5.0,
border_width: 1.0,
border_color: Color::from_rgb(0.6, 0.6, 0.6),
+ text_color: None,
}
}
diff --git a/style/src/radio.rs b/style/src/radio.rs
index 6fb1cb6c..dab76ad8 100644
--- a/style/src/radio.rs
+++ b/style/src/radio.rs
@@ -8,6 +8,7 @@ pub struct Style {
pub dot_color: Color,
pub border_width: f32,
pub border_color: Color,
+ pub text_color: Option<Color>,
}
/// A set of rules that dictate the style of a radio button.
@@ -26,6 +27,7 @@ impl StyleSheet for Default {
dot_color: Color::from_rgb(0.3, 0.3, 0.3),
border_width: 1.0,
border_color: Color::from_rgb(0.6, 0.6, 0.6),
+ text_color: None,
}
}