mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-05-06 22:26:49 +00:00
Move more code from .hpp to .cpp.
This commit is contained in:
parent
d34499d920
commit
750506b33e
@ -249,6 +249,14 @@ Widget* View::initial_focus() {
|
|||||||
|
|
||||||
/* Rectangle *************************************************************/
|
/* Rectangle *************************************************************/
|
||||||
|
|
||||||
|
Rectangle::Rectangle(
|
||||||
|
Rect parent_rect,
|
||||||
|
Color c
|
||||||
|
) : Widget { parent_rect },
|
||||||
|
color { c }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Rectangle::set_color(const Color c) {
|
void Rectangle::set_color(const Color c) {
|
||||||
color = c;
|
color = c;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
@ -263,6 +271,20 @@ void Rectangle::paint(Painter& painter) {
|
|||||||
|
|
||||||
/* Text ******************************************************************/
|
/* Text ******************************************************************/
|
||||||
|
|
||||||
|
Text::Text(
|
||||||
|
Rect parent_rect,
|
||||||
|
std::string text
|
||||||
|
) : Widget { parent_rect },
|
||||||
|
text { text }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Text::Text(
|
||||||
|
Rect parent_rect
|
||||||
|
) : Text { parent_rect, { } }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Text::set(const std::string value) {
|
void Text::set(const std::string value) {
|
||||||
text = value;
|
text = value;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
@ -278,6 +300,15 @@ void Text::paint(Painter& painter) {
|
|||||||
|
|
||||||
/* Button ****************************************************************/
|
/* Button ****************************************************************/
|
||||||
|
|
||||||
|
Button::Button(
|
||||||
|
Rect parent_rect,
|
||||||
|
std::string text
|
||||||
|
) : Widget { parent_rect },
|
||||||
|
text_ { text }
|
||||||
|
{
|
||||||
|
flags.focusable = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::set_text(const std::string value) {
|
void Button::set_text(const std::string value) {
|
||||||
text_ = value;
|
text_ = value;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
@ -378,6 +409,17 @@ bool Button::on_touch(const TouchEvent event) {
|
|||||||
|
|
||||||
/* OptionsField **********************************************************/
|
/* OptionsField **********************************************************/
|
||||||
|
|
||||||
|
OptionsField::OptionsField(
|
||||||
|
Point parent_pos,
|
||||||
|
size_t length,
|
||||||
|
options_t options
|
||||||
|
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
|
||||||
|
length_ { length },
|
||||||
|
options { options }
|
||||||
|
{
|
||||||
|
flags.focusable = true;
|
||||||
|
}
|
||||||
|
|
||||||
size_t OptionsField::selected_index() const {
|
size_t OptionsField::selected_index() const {
|
||||||
return selected_index_;
|
return selected_index_;
|
||||||
}
|
}
|
||||||
@ -432,6 +474,21 @@ bool OptionsField::on_touch(const TouchEvent event) {
|
|||||||
|
|
||||||
/* NumberField ***********************************************************/
|
/* NumberField ***********************************************************/
|
||||||
|
|
||||||
|
NumberField::NumberField(
|
||||||
|
Point parent_pos,
|
||||||
|
size_t length,
|
||||||
|
range_t range,
|
||||||
|
int32_t step,
|
||||||
|
char fill_char
|
||||||
|
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
|
||||||
|
range { range },
|
||||||
|
step { step },
|
||||||
|
length_ { length },
|
||||||
|
fill_char { fill_char }
|
||||||
|
{
|
||||||
|
flags.focusable = true;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t NumberField::value() const {
|
int32_t NumberField::value() const {
|
||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
@ -171,13 +171,7 @@ protected:
|
|||||||
|
|
||||||
class Rectangle : public Widget {
|
class Rectangle : public Widget {
|
||||||
public:
|
public:
|
||||||
constexpr Rectangle(
|
Rectangle(Rect parent_rect, Color c);
|
||||||
const Rect parent_rect,
|
|
||||||
const Color c
|
|
||||||
) : Widget { parent_rect },
|
|
||||||
color { c }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
@ -193,19 +187,8 @@ public:
|
|||||||
) : text { "" } {
|
) : text { "" } {
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Text(Rect parent_rect, std::string text);
|
||||||
Rect parent_rect,
|
Text(Rect parent_rect);
|
||||||
std::string text
|
|
||||||
) : Widget { parent_rect },
|
|
||||||
text { text }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(
|
|
||||||
Rect parent_rect
|
|
||||||
) : Text { parent_rect, { } }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(const std::string value);
|
void set(const std::string value);
|
||||||
|
|
||||||
@ -219,14 +202,7 @@ class Button : public Widget {
|
|||||||
public:
|
public:
|
||||||
std::function<void(Button&)> on_select;
|
std::function<void(Button&)> on_select;
|
||||||
|
|
||||||
Button(
|
Button(Rect parent_rect, std::string text);
|
||||||
Rect parent_rect,
|
|
||||||
std::string text
|
|
||||||
) : Widget { parent_rect },
|
|
||||||
text_ { text }
|
|
||||||
{
|
|
||||||
flags.focusable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
) : Button { { }, { } }
|
) : Button { { }, { } }
|
||||||
@ -254,16 +230,7 @@ public:
|
|||||||
|
|
||||||
std::function<void(size_t, value_t)> on_change;
|
std::function<void(size_t, value_t)> on_change;
|
||||||
|
|
||||||
OptionsField(
|
OptionsField(Point parent_pos, size_t length, options_t options);
|
||||||
Point parent_pos,
|
|
||||||
size_t length,
|
|
||||||
options_t options
|
|
||||||
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
|
|
||||||
length_ { length },
|
|
||||||
options { options }
|
|
||||||
{
|
|
||||||
flags.focusable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t selected_index() const;
|
size_t selected_index() const;
|
||||||
void set_selected_index(const size_t new_index);
|
void set_selected_index(const size_t new_index);
|
||||||
@ -287,20 +254,7 @@ public:
|
|||||||
|
|
||||||
using range_t = std::pair<int32_t, int32_t>;
|
using range_t = std::pair<int32_t, int32_t>;
|
||||||
|
|
||||||
NumberField(
|
NumberField(Point parent_pos, size_t length, range_t range, int32_t step, char fill_char);
|
||||||
Point parent_pos,
|
|
||||||
size_t length,
|
|
||||||
range_t range,
|
|
||||||
int32_t step,
|
|
||||||
char fill_char
|
|
||||||
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
|
|
||||||
range { range },
|
|
||||||
step { step },
|
|
||||||
length_ { length },
|
|
||||||
fill_char { fill_char }
|
|
||||||
{
|
|
||||||
flags.focusable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberField(const NumberField&) = delete;
|
NumberField(const NumberField&) = delete;
|
||||||
NumberField(NumberField&&) = delete;
|
NumberField(NumberField&&) = delete;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user