"At least it builds, now"

This commit is contained in:
furrtek
2016-02-05 17:40:14 +01:00
parent 8009a9b543
commit c81ba5be8e
27 changed files with 112 additions and 88 deletions

View File

@@ -1,2 +1,2 @@
const char md5_baseband[16] = {0xf8,0xf3,0x7b,0x36,0x68,0xd3,0xa1,0x85,0x26,0xb1,0x76,0x99,0x46,0x95,0xfd,0xec,};
const char md5_baseband_tx[16] = {0xfc,0xe9,0x57,0x6b,0xfb,0xac,0x72,0x61,0x65,0x4e,0x3d,0x7f,0xb4,0x78,0xbd,0xd2,};
const char md5_baseband[16] = {0xd1,0x3a,0x3a,0xf4,0xd4,0xdd,0x9f,0xa6,0x3d,0xdb,0xf0,0x1b,0x6a,0x11,0xa1,0xa9,};
const char md5_baseband_tx[16] = {0x30,0x80,0xd0,0x42,0x4a,0x09,0x78,0x77,0xff,0x59,0x00,0x70,0x48,0x77,0xd5,0xc6,};

View File

@@ -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();

View File

@@ -195,9 +195,33 @@ private:
std::string text;
};
class Checkbox : public Widget {
public:
std::function<void(Checkbox&)> on_select;
Checkbox(Point parent_pos, size_t length, std::string text);
void set_text(const std::string value);
void set_style(const Style* new_style);
std::string text() const;
void set_value(const bool value);
bool value() const;
void paint(Painter& painter) override;
bool on_key(const KeyEvent key) override;
bool on_touch(const TouchEvent event) override;
private:
std::string text_;
bool value_ = false;
const Style* style_ { nullptr };
};
class Button : public Widget {
public:
std::function<void(Button&)> on_select;
std::function<void(Button&,KeyEvent)> on_dir;
Button(Rect parent_rect, std::string text);
@@ -266,6 +290,8 @@ public:
std::function<void(void)> on_show_options;
OptionsField(Point parent_pos, size_t length, options_t options);
void set_options(options_t new_options);
size_t selected_index() const;
void set_selected_index(const size_t new_index);