Move more code from .hpp to .cpp.

This commit is contained in:
Jared Boone 2015-12-16 22:35:26 -08:00
parent d34499d920
commit 750506b33e
2 changed files with 63 additions and 52 deletions

View File

@ -249,6 +249,14 @@ Widget* View::initial_focus() {
/* Rectangle *************************************************************/
Rectangle::Rectangle(
Rect parent_rect,
Color c
) : Widget { parent_rect },
color { c }
{
}
void Rectangle::set_color(const Color c) {
color = c;
set_dirty();
@ -263,6 +271,20 @@ void Rectangle::paint(Painter& painter) {
/* 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) {
text = value;
set_dirty();
@ -278,6 +300,15 @@ void Text::paint(Painter& painter) {
/* 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) {
text_ = value;
set_dirty();
@ -378,6 +409,17 @@ bool Button::on_touch(const TouchEvent event) {
/* 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 {
return selected_index_;
}
@ -432,6 +474,21 @@ bool OptionsField::on_touch(const TouchEvent event) {
/* 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 {
return value_;
}

View File

@ -171,13 +171,7 @@ protected:
class Rectangle : public Widget {
public:
constexpr Rectangle(
const Rect parent_rect,
const Color c
) : Widget { parent_rect },
color { c }
{
}
Rectangle(Rect parent_rect, Color c);
void paint(Painter& painter) override;
@ -193,19 +187,8 @@ public:
) : text { "" } {
}
Text(
Rect parent_rect,
std::string text
) : Widget { parent_rect },
text { text }
{
}
Text(
Rect parent_rect
) : Text { parent_rect, { } }
{
}
Text(Rect parent_rect, std::string text);
Text(Rect parent_rect);
void set(const std::string value);
@ -219,14 +202,7 @@ class Button : public Widget {
public:
std::function<void(Button&)> on_select;
Button(
Rect parent_rect,
std::string text
) : Widget { parent_rect },
text_ { text }
{
flags.focusable = true;
}
Button(Rect parent_rect, std::string text);
Button(
) : Button { { }, { } }
@ -254,16 +230,7 @@ public:
std::function<void(size_t, value_t)> on_change;
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;
}
OptionsField(Point parent_pos, size_t length, options_t options);
size_t selected_index() const;
void set_selected_index(const size_t new_index);
@ -287,20 +254,7 @@ public:
using range_t = std::pair<int32_t, int32_t>;
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;
}
NumberField(Point parent_pos, size_t length, range_t range, int32_t step, char fill_char);
NumberField(const NumberField&) = delete;
NumberField(NumberField&&) = delete;