mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-27 08:10:42 -04:00
"At least it builds, now"
This commit is contained in:
parent
8009a9b543
commit
c81ba5be8e
27 changed files with 112 additions and 88 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "ui_widget.hpp"
|
||||
#include "ui_painter.hpp"
|
||||
#include "portapack.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
@ -7,6 +8,8 @@
|
|||
|
||||
#include "string_format.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
static bool ui_dirty = true;
|
||||
|
@ -298,6 +301,16 @@ void Text::paint(Painter& painter) {
|
|||
|
||||
/* Checkbox **************************************************************/
|
||||
|
||||
Checkbox::Checkbox(
|
||||
Point parent_pos,
|
||||
size_t length,
|
||||
std::string text
|
||||
) : Widget { { parent_pos, { static_cast<ui::Dim>((8 * length) + 24), 24 } } },
|
||||
text_ { text }
|
||||
{
|
||||
flags.focusable = true;
|
||||
}
|
||||
|
||||
void Checkbox::set_text(const std::string value) {
|
||||
text_ = value;
|
||||
set_dirty();
|
||||
|
@ -375,7 +388,6 @@ bool Checkbox::on_touch(const TouchEvent event) {
|
|||
set_dirty();
|
||||
return true;
|
||||
|
||||
|
||||
case TouchEvent::Type::End:
|
||||
flags.highlighted = false;
|
||||
value_ = not value_;
|
||||
|
@ -423,7 +435,7 @@ bool Checkbox::on_touch(const TouchEvent event) {
|
|||
|
||||
/* Button ****************************************************************/
|
||||
|
||||
Button::Button(
|
||||
Button::Button(
|
||||
Rect parent_rect,
|
||||
std::string text
|
||||
) : Widget { parent_rect },
|
||||
|
@ -467,6 +479,11 @@ bool Button::on_key(const KeyEvent key) {
|
|||
on_select(*this);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if( on_dir ) {
|
||||
on_dir(*this, key);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -654,6 +671,12 @@ void OptionsField::set_by_value(value_t v) {
|
|||
}
|
||||
}
|
||||
|
||||
void OptionsField::set_options(options_t new_options) {
|
||||
options = new_options;
|
||||
set_by_value(0);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void OptionsField::paint(Painter& painter) {
|
||||
const auto paint_style = has_focus() ? style().invert() : style();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue