Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
dialog.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019-2021 natinusala
3 Copyright 2021 XITRIX
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16*/
17
18#pragma once
19
21
22#include <aurore/core/bind.hpp>
23#include <aurore/core/box.hpp>
27
28namespace aurore
29{
30
31// TODO: Add the blurred dialog type once the blur is finished
32
34{
35 public:
36 std::string label;
38};
39
40// A modal dialog with zero to three buttons
41// and anything as content
42// Create the dialog then use open() and close()
43class Dialog : public Box
44{
45 private:
46 AURORE_BIND(Box, container, "aurore/dialog/container");
47 AURORE_BIND(AppletFrame, appletFrame, "aurore/dialog/applet");
48
49 unsigned frameX, frameY, frameWidth, frameHeight;
50
51 std::vector<DialogButton*> buttons;
52 std::function<void(void)> closeCallback = [] {};
53
54 void rebuildButtons();
55 void buttonClick(DialogButton* button);
56
57 bool cancelable = true;
58 bool dismissOnButtonClick = true;
59 Label* textLabel = nullptr; // the text of Dialog(text)
60
61 protected:
62 AURORE_BIND(Button, button1, "aurore/dialog/button1");
63 AURORE_BIND(Button, button2, "aurore/dialog/button2");
64 AURORE_BIND(Button, button3, "aurore/dialog/button3");
65
66 AURORE_BIND(Rectangle, button2separator, "aurore/dialog/button2/separator");
67 AURORE_BIND(Rectangle, button3separator, "aurore/dialog/button3/separator");
68
69 // A dialog, said with its text when the focus enters it.
71 std::string getDefaultAccessibilityLabel() override { return this->container->getAccessibilityText(); }
72
73 public:
74 Dialog(std::string text);
75 Dialog(Box* contentView);
77
79
87 void addButton(std::string label, VoidEvent::Callback cb);
88
96 void setCancelable(bool cancelable);
97 void setCloseCallback(std::function<void(void)> cb);
98
103 void setText(const std::string& text);
104 std::string getText();
105
109 void setButtonText(size_t index, const std::string& label);
110
117
118 bool isCancelable() const
119 {
120 return cancelable;
121 }
122
123 virtual void open();
124 void close(std::function<void(void)> cb = [] {});
125
126 bool isTranslucent() override
127 {
128 return true;
129 }
130};
131
132} // namespace aurore
#define AURORE_BIND(type, name, id)
Definition bind.hpp:39
Definition applet_frame.hpp:39
Generic FlexBox layout.
Definition box.hpp:74
Definition button.hpp:146
Definition dialog.hpp:34
std::string label
Definition dialog.hpp:36
VoidEvent::Callback cb
Definition dialog.hpp:37
Definition dialog.hpp:44
AURORE_BIND(Button, button3, "aurore/dialog/button3")
std::string getDefaultAccessibilityLabel() override
A focusable box says the texts shown in it (getAccessibilityText).
Definition dialog.hpp:71
bool isTranslucent() override
Definition dialog.hpp:126
void setCancelable(bool cancelable)
AURORE_BIND(Button, button2, "aurore/dialog/button2")
void close(std::function< void(void)> cb=[] {})
void setButtonText(size_t index, const std::string &label)
Dialog(std::string text)
AppletFrame * getAppletFrame() override
The AppletFrame the view is in, or nullptr.
AURORE_BIND(Button, button1, "aurore/dialog/button1")
std::string getText()
virtual void open()
void setCloseCallback(std::function< void(void)> cb)
void addButton(std::string label, VoidEvent::Callback cb)
AURORE_BIND(Rectangle, button2separator, "aurore/dialog/button2/separator")
bool isCancelable() const
Definition dialog.hpp:118
Dialog(Box *contentView)
AccessibilityRole getDefaultAccessibilityRole() override
Definition dialog.hpp:70
AURORE_BIND(Rectangle, button3separator, "aurore/dialog/button3/separator")
void setText(const std::string &text)
void setDismissOnButtonClick(bool dismiss)
std::function< void(Ts...)> Callback
Definition event.hpp:43
Definition label.hpp:65
Definition rectangle.hpp:28
virtual void dismiss(std::function< void(void)> cb=[] {})
Pops the AppletFrame's content back to the one before, then runs cb.
Definition actions.hpp:25
AccessibilityRole
Definition view_style.hpp:78
Definition text.hpp:13