use iced::widget::{container, mouse_area, vertical_rule};
use iced::{Background, Color, Element, Length};
use crate::message::Message;
use crate::state::{DragTarget, DragTargetH};
use crate::theme::ThemeColors;
const V_HIT_WIDTH: f32 = 8.0;
const H_HIT_HEIGHT: f32 = 8.0;
pub fn vertical_divider<'a>(target: DragTarget, _c: &ThemeColors) -> Element<'a, Message> {
let rule = vertical_rule(1).style(move |theme: &iced::Theme| {
let tc = crate::theme::ThemeColors::from_theme(theme);
iced::widget::rule::Style {
color: tc.border,
width: 1,
radius: 0.0.into(),
fill_mode: iced::widget::rule::FillMode::Full,
}
});
let hit_zone = container(rule)
.width(V_HIT_WIDTH)
.height(Length::Fill)
.center_x(V_HIT_WIDTH)
.center_y(Length::Fill)
.style(move |theme: &iced::Theme| {
let tc = crate::theme::ThemeColors::from_theme(theme);
container::Style {
background: Some(Background::Color(Color {
a: 0.0,
..tc.border
})),
..Default::default()
}
});
mouse_area(hit_zone)
.on_press(Message::PaneDragStart(target, 0.0))
.interaction(iced::mouse::Interaction::ResizingHorizontally)
.into()
}
pub fn horizontal_divider<'a>(target: DragTargetH, _c: &ThemeColors) -> Element<'a, Message> {
let rule = iced::widget::horizontal_rule(1).style(move |theme: &iced::Theme| {
let tc = crate::theme::ThemeColors::from_theme(theme);
iced::widget::rule::Style {
color: tc.border,
width: 1,
radius: 0.0.into(),
fill_mode: iced::widget::rule::FillMode::Full,
}
});
let hit_zone = container(rule)
.width(Length::Fill)
.height(H_HIT_HEIGHT)
.center_x(Length::Fill)
.center_y(H_HIT_HEIGHT)
.style(move |theme: &iced::Theme| {
let tc = crate::theme::ThemeColors::from_theme(theme);
container::Style {
background: Some(Background::Color(Color {
a: 0.0,
..tc.border
})),
..Default::default()
}
});
mouse_area(hit_zone)
.on_press(Message::PaneDragStartH(target, 0.0))
.interaction(iced::mouse::Interaction::ResizingVertically)
.into()
}