Remove trait-specific draw logic in iced_native
This commit is contained in:
parent
3aae45c191
commit
03b3493138
71 changed files with 641 additions and 3126 deletions
|
|
@ -1,9 +1,7 @@
|
|||
//! Display a horizontal or vertical rule for dividing content.
|
||||
|
||||
use crate::{Backend, Primitive, Renderer};
|
||||
use iced_native::mouse;
|
||||
use crate::{Backend, Renderer};
|
||||
use iced_native::rule;
|
||||
use iced_native::{Background, Color, Rectangle};
|
||||
|
||||
pub use iced_style::rule::{FillMode, Style, StyleSheet};
|
||||
|
||||
|
|
@ -17,57 +15,4 @@ 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())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue