Skip to content

Commit

Permalink
final background fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyler84 committed Sep 15, 2023
1 parent 65c1b71 commit 5731059
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ Display &View::get_default_display(){


gui::Color View::getBackgroundColor() const {
if (!m_backgroundInherited)
DEBUG_PRINTF("getBackgroundColor() -> %d\n", m_backgroundColor);
if (!m_backgroundInherited) {
DEBUG_PRINTF("not inherited\n");
return m_backgroundColor;
if (getParentView())
}
if (getParentView()){
DEBUG_PRINTF("inherited from parent %p\n", getParentView());
return getParentView()->getBackgroundColor();
}
DEBUG_PRINTF("inherited from view controller\n");
return ViewController::get().getBackgroundColor();
}

Expand Down Expand Up @@ -86,17 +92,19 @@ void View::setWidget(gui::Widget *w) {
void View::redraw(gui::Graphics&g, bool){
if(!childWidgets)
return;
gui::Color c = getBackgroundColor();
if(needsRedrawing()){
clear(g);
clear(g, c);
childWidgets->redraw(g);
childWidgets->redrawDone();
return;
}
if(!childWidgets->needsRedrawing() && !childWidgets->childNeedsRedrawing())
return;
clear(g);
clear(g, c);
childWidgets->redraw(g);
childWidgets->redrawDone();
DEBUG_PRINTF("redraw complete\n");
}

bool View::relayout(){
Expand Down
2 changes: 1 addition & 1 deletion src/view_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ViewController::poll_event_loop(){
gui::Color ViewController::getBackgroundColor() const{
gui::Color c;
c = this->current_view?
this->current_view->m_backgroundColor:
this->current_view->getBackgroundColor():
0;
return c;
}
2 changes: 1 addition & 1 deletion src/widgets/text_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void TextWidget::redraw(Graphics& graphics, bool){
clear(graphics, this->m_textColor);
graphics.set_pen(ViewController::get().getBackgroundColor());
}else{
clear(graphics);
clear(graphics, ViewController::get().getBackgroundColor());
graphics.set_pen(this->m_textColor);
}
graphics.set_font(this->m_font);
Expand Down

0 comments on commit 5731059

Please sign in to comment.