Skip to content

Commit

Permalink
More text UI funcionalities.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 2, 2023
1 parent ca6c6aa commit f991371
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/planet096_ui_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ void Planet096Text::hasRendered() {
this->has_rendered = true;
}

void Planet096Text::setHasScrollbar(bool has_scrollbar) {
this->has_scrollbar = true;
this->invalidate();
}

bool Planet096Text::hasScrollbar() {
return this->has_scrollbar;
}

void Planet096Text::setBackgroundColor(Planet096Color bg_color) {
this->bg_color = bg_color;
this->invalidate();
}

void Planet096Text::setForegroundColor(Planet096Color fg_color) {
this->fg_color = fg_color;
this->invalidate();
}

Planet096Color Planet096Text::getBackgroundColor() {
return this->bg_color;
}

Planet096Color Planet096Text::getForegroundColor() {
return this->fg_color;
}

void Planet096Text::invalidate() {
if(this->has_rendered)
this->scene->renderWidget();
Expand Down
16 changes: 15 additions & 1 deletion src/planet096_ui_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PLANET096_UI_TEXT_H

#include <Arduino.h>
#include <planet096_colors.h>
#include <planet096_scene.h>

class Planet096Scene;
Expand All @@ -25,12 +26,25 @@ class Planet096Text {
void setVisible(bool is_visible);
bool isVisible();

void setHasScrollbar(bool has_scrollbar);
bool hasScrollbar();

void setBackgroundColor(Planet096Color bg_color);
void setForegroundColor(Planet096Color fg_color);

Planet096Color getBackgroundColor();
Planet096Color getForegroundColor();

void hasRendered();

private:
char* text;
bool is_visible = true, has_rendered = false;
uint8_t x = 0, y = 0, size = 1;
Planet096Color bg_color = PLANET096_BLACK,
fg_color = PLANET096_WHITE;
bool is_visible = true,
has_rendered = false,
has_scrollbar = false;

Planet096Scene *scene;

Expand Down

0 comments on commit f991371

Please sign in to comment.