summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/rule.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-11-07 15:15:33 +0700
committerLibravatar GitHub <noreply@github.com>2021-11-07 15:15:33 +0700
commiteafad00af2a9bae9f3ed8124e2a6f6e59ee5d253 (patch)
tree76413948c9c9723075189d51d4c2e02c0f8fdd23 /graphics/src/widget/rule.rs
parent61c747b53589d98f477fea95f85d2ea5349666d3 (diff)
parent07b5097bc92ced376d09115d787ff1d2ebe00836 (diff)
downloadiced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.gz
iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.bz2
iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.zip
Merge pull request #1110 from iced-rs/remove-renderer-traits
Reduce the surface of the `Renderer` APIs
Diffstat (limited to 'graphics/src/widget/rule.rs')
-rw-r--r--graphics/src/widget/rule.rs72
1 files changed, 1 insertions, 71 deletions
diff --git a/graphics/src/widget/rule.rs b/graphics/src/widget/rule.rs
index 835ebed8..b96924fa 100644
--- a/graphics/src/widget/rule.rs
+++ b/graphics/src/widget/rule.rs
@@ -1,73 +1,3 @@
//! Display a horizontal or vertical rule for dividing content.
-use crate::{Backend, Primitive, Renderer};
-use iced_native::mouse;
-use iced_native::rule;
-use iced_native::{Background, Color, Rectangle};
-
-pub use iced_style::rule::{FillMode, Style, StyleSheet};
-
-/// Display a horizontal or vertical rule for dividing content.
-///
-/// This is an alias of an `iced_native` rule with an `iced_graphics::Renderer`.
-pub type Rule<Backend> = iced_native::Rule<Renderer<Backend>>;
-
-impl<B> rule::Renderer for Renderer<B>
-where
- B: Backend,
-{
- type Style = Box<dyn StyleSheet>;
-
- fn draw(
- &mut self,
- bounds: Rectangle,
- style_sheet: &Self::Style,
- is_horizontal: bool,
- ) -> Self::Output {
- let style = style_sheet.style();
-
- let line = if is_horizontal {
- let line_y = (bounds.y + (bounds.height / 2.0)
- - (style.width as f32 / 2.0))
- .round();
-
- let (offset, line_width) = style.fill_mode.fill(bounds.width);
- let line_x = bounds.x + offset;
-
- Primitive::Quad {
- bounds: Rectangle {
- x: line_x,
- y: line_y,
- width: line_width,
- height: style.width as f32,
- },
- background: Background::Color(style.color),
- border_radius: style.radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- }
- } else {
- let line_x = (bounds.x + (bounds.width / 2.0)
- - (style.width as f32 / 2.0))
- .round();
-
- let (offset, line_height) = style.fill_mode.fill(bounds.height);
- let line_y = bounds.y + offset;
-
- Primitive::Quad {
- bounds: Rectangle {
- x: line_x,
- y: line_y,
- width: style.width as f32,
- height: line_height,
- },
- background: Background::Color(style.color),
- border_radius: style.radius,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- }
- };
-
- (line, mouse::Interaction::default())
- }
-}
+pub use iced_native::widget::rule::*;