libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UIAlert.hpp
Go to the documentation of this file.
1 #ifndef UIALERT_HPP
2 #define UIALERT_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "UIWidget.hpp"
22 #include "UIBox.hpp"
23 #include "UIMarginBox.hpp"
24 #include "Theme.hpp"
25 #include "Alertable.hpp"
26 
27 namespace AlgAudio{
28 
29 class UIHBox;
30 class UIVBox;
31 class UILabel;
32 class UIButton;
33 class Window;
34 
35 class UIAlert : public UIMarginBox{
36 public:
37  static std::shared_ptr<UIAlert> Create(std::weak_ptr<Window> parent_window, std::string text);
38  void SetText(std::string);
39  void SetType(AlertType);
40  // Arg: pressed button id
42  struct ButtonData{
43  std::string name;
46  ButtonData(std::string t, ButtonID id_, Color c = Theme::Get("bg-button-neutral"))
47  : name(t), id(id_), color(c)
48  {}
49  };
50  void SetButtons(std::initializer_list<ButtonData>);
51 private:
52  UIAlert(std::weak_ptr<Window> parent_window);
53  void Init(std::string);
54  std::shared_ptr<UIVBox> main_box;
55  std::shared_ptr<UIHBox> child_buttons_box;
56  std::shared_ptr<UILabel> child_label;
57  std::vector<std::shared_ptr<UIButton>> buttons;
58 };
59 
60 } // namespace AlgAudio
61 
62 #endif // UIALERT_HPP
Signal< ButtonID > on_button_pressed
Definition: UIAlert.hpp:41
Definition: Color.hpp:28
std::string name
Definition: UIAlert.hpp:43
void SetType(AlertType)
Color color
Definition: UIAlert.hpp:45
ButtonID id
Definition: UIAlert.hpp:44
void SetButtons(std::initializer_list< ButtonData >)
ButtonData(std::string t, ButtonID id_, Color c=Theme::Get("bg-button-neutral"))
Definition: UIAlert.hpp:46
Definition: UIAlert.hpp:42
static std::shared_ptr< UIAlert > Create(std::weak_ptr< Window > parent_window, std::string text)
Definition: Alertable.hpp:26
void SetText(std::string)
Definition: UIAlert.hpp:35
Definition: UIMarginBox.hpp:25
ButtonID
Definition: Alertable.hpp:30
AlertType
Definition: Alertable.hpp:42
static const Color & Get(const std::string &)