summaryrefslogtreecommitdiff
path: root/src/menu.h
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2015-05-08 21:42:09 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2015-05-08 21:42:09 +0200
commit4d552bef5814e5f9ba87123716d296a45b5d941e (patch)
treee94d3ed29c13bf5aa299c04ceb6bd53416ea47ca /src/menu.h
parent173d23dde64585cf95d24d2f56015c8d790b75c2 (diff)
menu: reduce indirection
Diffstat (limited to 'src/menu.h')
-rw-r--r--src/menu.h45
1 files changed, 10 insertions, 35 deletions
diff --git a/src/menu.h b/src/menu.h
index 5f02b867..552e7fc7 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -37,8 +37,6 @@ namespace NC {
/// holding any std::vector compatible values.
template <typename ItemT> class Menu : public Window
{
- struct ItemProxy;
-
public:
struct Item
{
@@ -82,16 +80,8 @@ public:
bool m_is_separator;
};
- typedef boost::indirect_iterator<
- typename std::vector<ItemProxy>::iterator,
- Item,
- boost::random_access_traversal_tag
- > Iterator;
- typedef boost::indirect_iterator<
- typename std::vector<ItemProxy>::const_iterator,
- const Item,
- boost::random_access_traversal_tag
- > ConstIterator;
+ typedef typename std::vector<Item>::iterator Iterator;
+ typedef typename std::vector<Item>::const_iterator ConstIterator;
typedef std::reverse_iterator<Iterator> ReverseIterator;
typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
@@ -226,20 +216,20 @@ public:
/// @param pos requested position
/// @return reference to item at given position
/// @throw std::out_of_range if given position is out of range
- Menu<ItemT>::Item &at(size_t pos) { return *m_items.at(pos); }
+ Menu<ItemT>::Item &at(size_t pos) { return m_items.at(pos); }
/// @param pos requested position
/// @return const reference to item at given position
/// @throw std::out_of_range if given position is out of range
- const Menu<ItemT>::Item &at(size_t pos) const { return *m_items.at(pos); }
+ const Menu<ItemT>::Item &at(size_t pos) const { return m_items.at(pos); }
/// @param pos requested position
/// @return const reference to item at given position
- const Menu<ItemT>::Item &operator[](size_t pos) const { return *m_items[pos]; }
+ const Menu<ItemT>::Item &operator[](size_t pos) const { return m_items[pos]; }
/// @param pos requested position
/// @return const reference to item at given position
- Menu<ItemT>::Item &operator[](size_t pos) { return *m_items[pos]; }
+ Menu<ItemT>::Item &operator[](size_t pos) { return m_items[pos]; }
Iterator current() { return Iterator(m_items.begin() + m_highlight); }
ConstIterator current() const { return ConstIterator(m_items.begin() + m_highlight); }
@@ -272,31 +262,16 @@ public:
ConstReverseValueIterator rendV() const { return ConstReverseValueIterator(beginV()); }
private:
- struct ItemProxy
- {
- typedef Item element_type;
-
- ItemProxy() { }
- ItemProxy(Item item) : m_ptr(std::make_shared<Item>(std::move(item))) { }
-
- Item &operator*() const { return *m_ptr; }
- Item *operator->() const { return m_ptr.get(); }
-
- bool operator==(const ItemProxy &rhs) const { return m_ptr == rhs.m_ptr; }
-
- private:
- std::shared_ptr<Item> m_ptr;
- };
-
+
bool isHighlightable(size_t pos)
{
- return !m_items[pos]->isSeparator()
- && !m_items[pos]->isInactive();
+ return !m_items[pos].isSeparator()
+ && !m_items[pos].isInactive();
}
ItemDisplayer m_item_displayer;
- std::vector<ItemProxy> m_items;
+ std::vector<Item> m_items;
size_t m_beginning;
size_t m_highlight;