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_;
}