From 722f9b68861bb48fb0c1d0d01f8edf6cafae483a Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 5 Sep 2016 15:30:45 -0700 Subject: [PATCH] MenuItem: Misc const and constructor consistency adjustments. Also moved add_items() body to .cpp file. --- firmware/application/ui_menu.cpp | 8 +++++++- firmware/application/ui_menu.hpp | 11 +++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/firmware/application/ui_menu.cpp b/firmware/application/ui_menu.cpp index 4b79cbb1..4a04e817 100644 --- a/firmware/application/ui_menu.cpp +++ b/firmware/application/ui_menu.cpp @@ -69,10 +69,16 @@ MenuView::~MenuView() { } } -void MenuView::add_item(const MenuItem item) { +void MenuView::add_item(MenuItem item) { add_child(new MenuItemView { item }); } +void MenuView::add_items(std::initializer_list items) { + for(auto item : items) { + add_item(item); + } +} + void MenuView::set_parent_rect(const Rect new_parent_rect) { View::set_parent_rect(new_parent_rect); diff --git a/firmware/application/ui_menu.hpp b/firmware/application/ui_menu.hpp index 6873e5da..7d10dbf6 100644 --- a/firmware/application/ui_menu.hpp +++ b/firmware/application/ui_menu.hpp @@ -45,7 +45,7 @@ class MenuItemView : public Widget { public: MenuItemView( MenuItem item - ) : item(item) + ) : item { item } { } @@ -69,13 +69,8 @@ public: ~MenuView(); - void add_item(const MenuItem item); - - void add_items(const std::initializer_list items) { - for(const auto& item : items) { - add_item(item); - } - } + void add_item(MenuItem item); + void add_items(std::initializer_list items); void set_parent_rect(const Rect new_parent_rect) override;