Skip to main content

ferroui_controls/
drop_down_button.rs

1use crate::primitives::TemplatedControlImpl;
2use crate::{Button, ButtonImpl, ContentControlImpl, ControlImpl};
3use ferroui_base::input::InputElementImpl;
4use ferroui_base::interactivity::InteractiveImpl;
5use ferroui_base::layout::LayoutableImpl;
6use ferroui_base::{
7    ferro_class, ferro_impl_classes, instantiate, FerroObjectImpl, Ref, StyledElementImpl, VisualImpl,
8};
9
10/// A button with an added drop-down chevron to visually indicate it has a
11/// flyout with additional actions.
12#[repr(C)]
13pub struct DropDownButton {
14    base: Button,
15}
16
17ferro_class!(DropDownButton: Button);
18ferroui_base::ferro_class_info!(DropDownButton { new: DropDownButton::new });
19ferro_impl_classes!(
20    DropDownButton: FerroObjectImpl,
21    StyledElementImpl,
22    VisualImpl,
23    LayoutableImpl,
24    InteractiveImpl,
25    InputElementImpl,
26    ControlImpl,
27    TemplatedControlImpl,
28    ContentControlImpl,
29    ButtonImpl
30);
31
32impl DropDownButton {
33    /// Creates the class data; see [`ferroui_base::FerroObject::construct`].
34    pub fn construct() -> Self {
35        Self { base: Button::construct() }
36    }
37
38    /// Creates a drop-down button.
39    pub fn new() -> Ref<Self> {
40        instantiate(Self::construct())
41    }
42}