Skip to content

Commit

Permalink
Issue #30 and #29, and a suggestion for ease of use. (#31)
Browse files Browse the repository at this point in the history
* Segfault fixed when SideBar has no child.

* Button: Make ButtonStyle::PLAIN the default style; Tab Frame: Fix for not switching to a view if the previous view was nullptr.

* Move the comment above the if statement.
  • Loading branch information
jon-dez committed Jun 20, 2020
1 parent 235141a commit a225a1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/include/borealis/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Button : public View
float cornerRadiusOverride = 0;

public:
Button(ButtonStyle style);
Button(ButtonStyle style = ButtonStyle::PLAIN);
~Button();

void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, Style* style, FrameContext* ctx) override;
Expand Down
5 changes: 4 additions & 1 deletion library/lib/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ View* Sidebar::getDefaultFocus()
if (this->lastFocus >= this->children.size())
this->lastFocus = 0;

View* toFocus{ nullptr };
// Try to focus last focused one
View* toFocus = this->children[this->lastFocus]->view->getDefaultFocus();
if(this->children.size() != 0)
toFocus = this->children[this->lastFocus]->view->getDefaultFocus();

if (toFocus)
return toFocus;

Expand Down
8 changes: 3 additions & 5 deletions library/lib/tab_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ void TabFrame::switchToView(View* view)
this->layout->removeView(1, false);
}

if (view != nullptr)
{
this->layout->addView(view, true, true); // addView() calls willAppear()
this->rightPane = view;
}
this->rightPane = view;
if (this->rightPane != nullptr)
this->layout->addView(this->rightPane, true, true); // addView() calls willAppear()
}

void TabFrame::addTab(std::string label, View* view)
Expand Down

0 comments on commit a225a1e

Please sign in to comment.