1#include "AlertDialog.hpp" 
    2#include "Container.hpp" 
    3#include "Constraint.hpp" 
    7    : title(title), message(message)
 
   19    messageText->setText(message);
 
   23    auto okButton = (
new Button(
"OK", A_BUTTON));
 
   24    okButton->setAction([
this]() {
 
   25        if (onConfirm) onConfirm();
 
   27    okButton->cornerRadius = 10;
 
   28    okButton->updateBounds();
 
   30    auto innerVStack = 
new Container(COL_LAYOUT, 50);
 
   31    innerVStack->add(messageText);
 
   32    innerVStack->add(okButton);
 
   33    innerVStack->width = dialogWidth;
 
   37    messageText->constrain(ALIGN_CENTER_HORIZONTAL, 0);
 
   38    okButton->constrain(ALIGN_CENTER_HORIZONTAL, 0);
 
   41    vStack->backgroundColor = fromRGB(0xdd, 0xdd, 0xdd);
 
   42    vStack->hasBackground = 
true;
 
   43    vStack->cornerRadius = 15;
 
   44    vStack->
width = dialogWidth;
 
   45    vStack->height = dialogHeight;
 
   46    vStack->add(innerVStack);
 
   48    innerVStack->constrain(ALIGN_CENTER_BOTH, 0);
 
   51    overlay->
width = RootDisplay::mainDisplay->
width;
 
   52    overlay->height = RootDisplay::mainDisplay->height;
 
   53    overlay->backgroundColor = fromRGB(0, 0, 0);
 
   54    overlay->backgroundOpacity = 0x00;
 
   55    overlay->cornerRadius = 1; 
 
   56    overlay->hasBackground = 
true;
 
   58    overlay->child(vStack);
 
   60    vStack->constrain(ALIGN_CENTER_BOTH, 0);
 
   65void AlertDialog::setText(
const std::string& newText) {
 
   66    messageText->setText(newText);
 
   70void AlertDialog::show() {
 
   77        animate(250, [
this](
float progress) {
 
   79            this->vStack->
width = (dialogWidth * progress);
 
   80            this->vStack->height = (dialogHeight * progress);
 
   81            this->overlay->backgroundOpacity = (int)(0x80 * progress);
 
   83            this->vStack->
width = dialogWidth;
 
   84            this->vStack->height = dialogHeight;
 
   85            this->overlay->backgroundOpacity = 0x80;
 
   92    this->
width = dialogWidth;
 
   93    this->
width = dialogHeight;
 
virtual bool process(InputEvents *event) override
process any input that is received for this element
 
virtual void render(Element *parent) override
display the current state of the display
 
AlertDialog(const std::string &title, const std::string &message)
 
virtual bool process(InputEvents *event)
process any input that is received for this element
 
bool hidden
whether this element should skip rendering or not
 
virtual void render(Element *parent)
display the current state of the display
 
int width
width and height of this element (must be manually set, isn't usually calculated (but is in some case...
 
void update(bool forceUpdate=false)
update TextElement with changes