mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-23 15:01:14 -04:00
Use std::unique_ptr inside NavigationView.
This commit is contained in:
parent
18c4672ba2
commit
969d9bd070
2 changed files with 9 additions and 9 deletions
|
@ -48,12 +48,15 @@ NavigationView::NavigationView()
|
|||
{
|
||||
}
|
||||
|
||||
void NavigationView::push_view(View* new_view) {
|
||||
View* NavigationView::push_view(std::unique_ptr<View> new_view) {
|
||||
free_view();
|
||||
|
||||
view_stack.push_back(new_view);
|
||||
const auto p = new_view.get();
|
||||
view_stack.emplace_back(std::move(new_view));
|
||||
|
||||
update_view();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void NavigationView::pop() {
|
||||
|
@ -61,7 +64,6 @@ void NavigationView::pop() {
|
|||
if( view_stack.size() > 1 ) {
|
||||
free_view();
|
||||
|
||||
delete view_stack.back();
|
||||
view_stack.pop_back();
|
||||
|
||||
update_view();
|
||||
|
@ -73,7 +75,7 @@ void NavigationView::free_view() {
|
|||
}
|
||||
|
||||
void NavigationView::update_view() {
|
||||
const auto new_view = view_stack.back();
|
||||
const auto new_view = view_stack.back().get();
|
||||
add_child(new_view);
|
||||
new_view->set_parent_rect({ {0, 0}, size() });
|
||||
focus();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue