Skip to content

Commit

Permalink
fix circular referencing of headers (move code to source)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyler84 committed Sep 15, 2023
1 parent 70bab81 commit 65c1b71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 1 addition & 7 deletions include/gui/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ namespace gui
m_backgroundColor = c;
m_backgroundInherited = false;
}
gui::Color getBackgroundColor() const {
if (!m_backgroundInherited)
return m_backgroundColor;
if (getParentView())
return getParentView()->getBackgroundColor();
return ViewController::get().getBackgroundColor();
}
gui::Color getBackgroundColor() const;
bool isBackgroundInherited() const { return m_backgroundInherited; }
void inheritBackgroundColor() { m_backgroundInherited = true; }
protected:
Expand Down
16 changes: 13 additions & 3 deletions src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ using namespace gui;
Queue<View::TimerEvent> View::timer_events{32};

View::View(View *parent) :
Widget(parent, {0,0,get_default_display().width, get_default_display().height}), childView(nullptr){
Widget(parent, {0,0,get_default_display().width, get_default_display().height}),
childView(nullptr),
m_backgroundInherited(true)
{
requiresRedraw();
if(parent)
setBackgroundColor(parent->getBackgroundColor());
}

View::~View(){
Expand All @@ -32,6 +33,15 @@ Display &View::get_default_display(){
return ViewController::get().get_default_display();
}


gui::Color View::getBackgroundColor() const {
if (!m_backgroundInherited)
return m_backgroundColor;
if (getParentView())
return getParentView()->getBackgroundColor();
return ViewController::get().getBackgroundColor();
}

int View::start_timer(long timeout_us){
//TODO: keep track of timers
alarm_id_t id = add_alarm_at(make_timeout_time_us(timeout_us), timer_handler, this, true);
Expand Down

0 comments on commit 65c1b71

Please sign in to comment.