summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/styling/src/main.rs1
-rw-r--r--native/src/user_interface.rs2
-rw-r--r--native/src/widget/checkbox.rs24
-rw-r--r--native/src/widget/pane_grid.rs31
-rw-r--r--native/src/widget/slider.rs22
-rw-r--r--src/settings.rs2
-rw-r--r--style/src/checkbox.rs2
-rw-r--r--winit/src/application.rs2
8 files changed, 62 insertions, 24 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index 4e319285..065764b3 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -528,6 +528,7 @@ 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,
diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs
index 39cac559..f44ed1fb 100644
--- a/native/src/user_interface.rs
+++ b/native/src/user_interface.rs
@@ -409,7 +409,7 @@ where
let overlay_bounds = layer.layout.bounds();
- renderer.with_layer(viewport, |renderer| {
+ renderer.with_layer(overlay_bounds, |renderer| {
overlay.draw(
renderer,
&renderer::Style::default(),
diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs
index 0d4a43ec..81611426 100644
--- a/native/src/widget/checkbox.rs
+++ b/native/src/widget/checkbox.rs
@@ -216,24 +216,24 @@ where
let mut children = layout.children();
+ let custom_style = if is_mouse_over {
+ self.style_sheet.hovered(self.is_checked)
+ } else {
+ self.style_sheet.active(self.is_checked)
+ };
+
{
let layout = children.next().unwrap();
let bounds = layout.bounds();
- let style = if is_mouse_over {
- self.style_sheet.hovered(self.is_checked)
- } else {
- self.style_sheet.active(self.is_checked)
- };
-
renderer.fill_quad(
renderer::Quad {
bounds,
- border_radius: style.border_radius,
- border_width: style.border_width,
- border_color: style.border_color,
+ border_radius: custom_style.border_radius,
+ border_width: custom_style.border_width,
+ border_color: custom_style.border_color,
},
- style.background,
+ custom_style.background,
);
if self.is_checked {
@@ -246,7 +246,7 @@ where
y: bounds.center_y(),
..bounds
},
- color: style.checkmark_color,
+ color: custom_style.checkmark_color,
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Center,
});
@@ -263,7 +263,7 @@ where
&self.label,
self.font,
self.text_size,
- self.text_color,
+ self.text_color.or(Some(custom_style.text_color)),
alignment::Horizontal::Left,
alignment::Vertical::Center,
);
diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs
index 20616ed4..3637822b 100644
--- a/native/src/widget/pane_grid.rs
+++ b/native/src/widget/pane_grid.rs
@@ -481,10 +481,33 @@ where
return mouse::Interaction::Grab;
}
- if let Some((_, axis)) = self.state.picked_split() {
- return match axis {
- Axis::Horizontal => mouse::Interaction::ResizingHorizontally,
- Axis::Vertical => mouse::Interaction::ResizingVertically,
+ let resize_axis =
+ self.state.picked_split().map(|(_, axis)| axis).or_else(|| {
+ self.on_resize.as_ref().and_then(|(leeway, _)| {
+ let bounds = layout.bounds();
+
+ let splits = self
+ .state
+ .split_regions(f32::from(self.spacing), bounds.size());
+
+ let relative_cursor = Point::new(
+ cursor_position.x - bounds.x,
+ cursor_position.y - bounds.y,
+ );
+
+ hovered_split(
+ splits.iter(),
+ f32::from(self.spacing + leeway),
+ relative_cursor,
+ )
+ .map(|(_, axis, _)| axis)
+ })
+ });
+
+ if let Some(resize_axis) = resize_axis {
+ return match resize_axis {
+ Axis::Horizontal => mouse::Interaction::ResizingVertically,
+ Axis::Vertical => mouse::Interaction::ResizingHorizontally,
};
}
diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs
index 49bafab4..3ce53f6c 100644
--- a/native/src/widget/slider.rs
+++ b/native/src/widget/slider.rs
@@ -193,12 +193,14 @@ where
_clipboard: &mut dyn Clipboard,
messages: &mut Vec<Message>,
) -> event::Status {
+ let is_dragging = self.state.is_dragging;
+
let mut change = || {
let bounds = layout.bounds();
- if cursor_position.x <= bounds.x {
- messages.push((self.on_change)(*self.range.start()));
+ let new_value = if cursor_position.x <= bounds.x {
+ *self.range.start()
} else if cursor_position.x >= bounds.x + bounds.width {
- messages.push((self.on_change)(*self.range.end()));
+ *self.range.end()
} else {
let step = self.step.into();
let start = (*self.range.start()).into();
@@ -211,8 +213,16 @@ where
let value = steps * step + start;
if let Some(value) = T::from_f64(value) {
- messages.push((self.on_change)(value));
+ value
+ } else {
+ return;
}
+ };
+
+ if (self.value.into() - new_value.into()).abs() > f64::EPSILON {
+ messages.push((self.on_change)(new_value));
+
+ self.value = new_value;
}
};
@@ -229,7 +239,7 @@ where
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. })
| Event::Touch(touch::Event::FingerLost { .. }) => {
- if self.state.is_dragging {
+ if is_dragging {
if let Some(on_release) = self.on_release.clone() {
messages.push(on_release);
}
@@ -240,7 +250,7 @@ where
}
Event::Mouse(mouse::Event::CursorMoved { .. })
| Event::Touch(touch::Event::FingerMoved { .. }) => {
- if self.state.is_dragging {
+ if is_dragging {
change();
return event::Status::Captured;
diff --git a/src/settings.rs b/src/settings.rs
index d726dc4f..f7940a0b 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -52,6 +52,8 @@ pub struct Settings<Flags> {
/// window to close (e.g. the user presses the close button).
///
/// By default, it is enabled.
+ ///
+ /// [`Application`]: crate::Application
pub exit_on_close_request: bool,
}
diff --git a/style/src/checkbox.rs b/style/src/checkbox.rs
index f8bc6241..77aae42b 100644
--- a/style/src/checkbox.rs
+++ b/style/src/checkbox.rs
@@ -6,6 +6,7 @@ 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,
@@ -25,6 +26,7 @@ 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),
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 9d787933..9ae1364d 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -22,7 +22,7 @@ use std::mem::ManuallyDrop;
/// An interactive, native cross-platform application.
///
/// This trait is the main entrypoint of Iced. Once implemented, you can run
-/// your GUI application by simply calling [`run`](#method.run). It will run in
+/// your GUI application by simply calling [`run`]. It will run in
/// its own window.
///
/// An [`Application`] can execute asynchronous actions by returning a