vizia_core/views/
divider.rs
1use crate::prelude::*;
2
3pub struct Divider {}
5
6impl Divider {
7 pub fn new(cx: &mut Context) -> Handle<Self> {
9 Self {}.build(cx, |cx| {
10 Element::new(cx).class("divider-line");
11 })
12 }
13
14 pub fn horizontal(cx: &mut Context) -> Handle<Self> {
16 Self::new(cx).class("horizontal")
17 }
18
19 pub fn vertical(cx: &mut Context) -> Handle<Self> {
21 Self::new(cx).class("vertical")
22 }
23}
24
25impl View for Divider {
26 fn element(&self) -> Option<&'static str> {
27 Some("divider")
28 }
29}
30
31impl Handle<'_, Divider> {
32 pub fn orientation(self, orientation: impl Res<Orientation>) -> Self {
34 self.bind(orientation, move |handle, orientation| {
35 let orientation = orientation.get(&handle);
36 if orientation == Orientation::Horizontal {
37 handle.toggle_class("horizontal", true).toggle_class("vertical", false);
38 } else {
39 handle.toggle_class("horizontal", false).toggle_class("vertical", true);
40 }
41 })
42 }
43}