ferroui_controls/command_bar/
command_bar_separator.rs1use super::ICommandBarElement;
2use crate::primitives::TemplatedControlImpl;
3use crate::{ControlImpl, Separator};
4use ferroui_base::input::InputElementImpl;
5use ferroui_base::interactivity::InteractiveImpl;
6use ferroui_base::layout::LayoutableImpl;
7use ferroui_base::{
8 ferro_class, ferro_class_info, ferro_impl_classes, ferro_properties, instantiate, FerroObject, FerroObjectImpl,
9 FerroProperty, Ref, StyledElementImpl, StyledProperty, VisualImpl,
10};
11use std::rc::Rc;
12
13#[repr(C)]
15pub struct CommandBarSeparator {
16 base: Separator,
17}
18
19ferro_class!(CommandBarSeparator: Separator);
20ferro_class_info!(CommandBarSeparator {
21 new: CommandBarSeparator::new,
22 interfaces: [
23 Rc<dyn ICommandBarElement> => |separator: Ref<CommandBarSeparator>| separator.as_command_bar_element(),
24 ],
25});
26ferro_impl_classes!(
27 CommandBarSeparator: FerroObjectImpl,
28 StyledElementImpl,
29 VisualImpl,
30 LayoutableImpl,
31 InteractiveImpl,
32 InputElementImpl,
33 ControlImpl,
34 TemplatedControlImpl
35);
36
37struct CommandBarSeparatorElement(Ref<CommandBarSeparator>);
40
41impl ICommandBarElement for CommandBarSeparatorElement {
42 fn is_compact(&self) -> bool {
43 self.0.is_compact()
44 }
45
46 fn set_is_compact(&self, value: bool) {
47 self.0.set_is_compact(value)
48 }
49
50 fn is_in_overflow(&self) -> bool {
51 self.0.is_in_overflow()
52 }
53
54 fn set_is_in_overflow(&self, value: bool) {
55 self.0.set_is_in_overflow(value)
56 }
57
58 fn as_object(&self) -> Option<&FerroObject> {
59 let object: &FerroObject = &self.0;
60 Some(object)
61 }
62}
63
64ferro_properties! {
65 impl CommandBarSeparator {
66 pub fn is_compact_property() -> StyledProperty<bool> {
68 FerroProperty::register::<CommandBarSeparator, _>("IsCompact", false)
69 }
70
71 pub fn is_in_overflow_property() -> StyledProperty<bool> {
73 FerroProperty::register::<CommandBarSeparator, _>("IsInOverflow", false)
74 }
75 }
76}
77
78impl CommandBarSeparator {
79 pub fn construct() -> Self {
81 Self { base: Separator::construct() }
82 }
83
84 pub fn new() -> Ref<Self> {
86 instantiate(Self::construct())
87 }
88
89 pub fn as_command_bar_element(&self) -> Rc<dyn ICommandBarElement> {
91 Rc::new(CommandBarSeparatorElement(self.to_ref()))
92 }
93
94 pub fn is_compact(&self) -> bool {
96 self.get_value(Self::is_compact_property())
97 }
98
99 pub fn set_is_compact(&self, value: bool) {
101 self.set_value(Self::is_compact_property(), value)
102 }
103
104 pub fn is_in_overflow(&self) -> bool {
106 self.get_value(Self::is_in_overflow_property())
107 }
108
109 pub fn set_is_in_overflow(&self, value: bool) {
113 self.set_value(Self::is_in_overflow_property(), value)
114 }
115}