2021-09-11 14:48:13 +01:00
|
|
|
#include "choice_page.hpp"
|
|
|
|
|
2020-10-05 23:53:12 +01:00
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2021-09-11 14:48:13 +01:00
|
|
|
ChoicePage::ChoicePage(brls::StagedAppletFrame* frame, const std::string text)
|
|
|
|
{
|
2020-09-20 21:58:40 +01:00
|
|
|
this->yes = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("yes");
|
|
|
|
this->yes->setParent(this);
|
2021-09-11 14:48:13 +01:00
|
|
|
this->no = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("no");
|
2020-09-20 21:58:40 +01:00
|
|
|
this->no->setParent(this);
|
|
|
|
|
|
|
|
this->label = new brls::Label(brls::LabelStyle::DIALOG, text, true);
|
|
|
|
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->label->setParent(this);
|
2021-09-11 14:48:13 +01:00
|
|
|
}
|
2020-09-20 21:58:40 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
void ChoicePage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
2020-09-20 21:58:40 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
brls::View* ChoicePage::getDefaultFocus()
|
|
|
|
{
|
|
|
|
return this->no;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChoicePage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
|
|
|
|
{
|
|
|
|
this->label->setWidth(this->width);
|
|
|
|
this->label->invalidate(true);
|
|
|
|
|
|
|
|
this->label->setBoundaries(
|
|
|
|
this->x + this->width / 2 - this->label->getWidth() / 2,
|
2021-09-11 14:48:13 +01:00
|
|
|
this->y + (this->height - this->label->getHeight() - this->y - style->CrashFrame.buttonHeight) / 2,
|
2020-09-20 21:58:40 +01:00
|
|
|
this->label->getWidth(),
|
|
|
|
this->label->getHeight());
|
|
|
|
|
|
|
|
this->yes->setBoundaries(
|
|
|
|
this->x + this->width / 2 - style->CrashFrame.buttonWidth / 2,
|
2021-09-11 14:48:13 +01:00
|
|
|
this->y + (this->height - style->CrashFrame.buttonHeight * 3),
|
2020-09-20 21:58:40 +01:00
|
|
|
style->CrashFrame.buttonWidth,
|
|
|
|
style->CrashFrame.buttonHeight);
|
|
|
|
this->yes->invalidate();
|
|
|
|
|
|
|
|
this->no->setBoundaries(
|
|
|
|
this->x + this->width / 2 - style->CrashFrame.buttonWidth / 2,
|
2021-09-11 14:48:13 +01:00
|
|
|
this->y + (this->height - style->CrashFrame.buttonHeight * 3),
|
2020-09-20 21:58:40 +01:00
|
|
|
style->CrashFrame.buttonWidth,
|
|
|
|
style->CrashFrame.buttonHeight);
|
|
|
|
this->no->invalidate();
|
|
|
|
}
|