| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2022 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2017 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifdef HAVE_CONFIG_H |
| 9 | #include "config.h" |
| 10 | #endif |
| 11 | |
| 12 | #include "app/ui/drop_down_button.h" |
| 13 | |
| 14 | #include "app/modules/gui.h" |
| 15 | #include "app/ui/skin/skin_property.h" |
| 16 | #include "app/ui/skin/skin_theme.h" |
| 17 | #include "ui/button.h" |
| 18 | #include "ui/theme.h" |
| 19 | |
| 20 | namespace app { |
| 21 | |
| 22 | using namespace app::skin; |
| 23 | using namespace ui; |
| 24 | |
| 25 | DropDownButton::DropDownButton(const char* text) |
| 26 | : HBox() |
| 27 | , m_button(new Button(text)) |
| 28 | , m_dropDown(new Button("")) |
| 29 | { |
| 30 | m_button->setExpansive(true); |
| 31 | m_button->Click.connect(&DropDownButton::onButtonClick, this); |
| 32 | m_dropDown->Click.connect(&DropDownButton::onDropDownButtonClick, this); |
| 33 | |
| 34 | addChild(m_button); |
| 35 | addChild(m_dropDown); |
| 36 | |
| 37 | InitTheme.connect( |
| 38 | [this]{ |
| 39 | auto theme = SkinTheme::get(this); |
| 40 | m_button->setStyle(theme->styles.dropDownButton()); |
| 41 | m_dropDown->setStyle(theme->styles.dropDownExpandButton()); |
| 42 | setChildSpacing(0); |
| 43 | }); |
| 44 | initTheme(); |
| 45 | } |
| 46 | |
| 47 | void DropDownButton::onButtonClick(Event& ev) |
| 48 | { |
| 49 | // Fire "Click" signal. |
| 50 | Click(); |
| 51 | } |
| 52 | |
| 53 | void DropDownButton::onDropDownButtonClick(Event& ev) |
| 54 | { |
| 55 | DropDownClick(); |
| 56 | } |
| 57 | |
| 58 | } // namespace app |
| 59 |