DUDS
Distributed Update of Data from Something
MenuOutputAccess.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2019 Jeff Jackowski
9  */
11 
12 namespace duds { namespace ui { namespace menu {
13 
41  MenuVisibleList::const_iterator seliter;
42  friend MenuOutput;
43 public:
51  MenuOutputAccess(MenuOutput *mov, std::size_t newRange = -1);
59  MenuOutputAccess(MenuOutput &mov, std::size_t newRange = -1) :
60  MenuOutputAccess(&mov, newRange) { }
69  const MenuOutputSptr &mov,
70  std::size_t newRange = -1
71  ) : MenuOutputAccess(mov.get(), newRange) { }
76  retire();
77  }
81  void retire() noexcept;
85  const Menu *menu() const {
86  return viewmenu;
87  }
91  const MenuOutput *outputView() const {
92  return outview;
93  }
97  std::size_t maxVisible() const {
98  return outview->range;
99  }
111  void maxVisible(std::size_t newRange) const {
112  outview->maxVisible(newRange);
113  }
117  bool changed() const {
118  return outview->changed();
119  }
126  const std::shared_ptr<MenuItem> &item(std::size_t index) const {
127  return *(viewmenu->iterator(index));
128  }
134  bool haveToggles() const {
135  return viewmenu->haveToggles();
136  }
141  std::size_t size() const {
142  return outview->items.size();
143  }
148  bool empty() const {
149  return outview->items.empty();
150  }
158  MenuVisibleList::const_iterator begin() const {
159  return outview->items.cbegin();
160  }
169  MenuVisibleList::const_iterator end() const {
170  return outview->items.cend();
171  }
181  const MenuVisibleList::const_iterator &selectedIter() const {
182  return outview->seliter;
183  }
187  const MenuItem &selectedItem() const {
188  return **outview->seliter;
189  }
196  std::size_t selectedIndex() const {
197  return outview->selected;
198  }
206  std::size_t selectedVisible() const {
207  return outview->selectedVis;
208  }
212  std::size_t firstIndex() const {
213  return outview->firstIdx;
214  }
218  std::size_t lastIndex() const {
219  return outview->lastIdx;
220  }
225  bool showingFirst() const {
226  return outview->showFirst;
227  }
232  bool showingLast() const {
233  return outview->showLast;
234  }
238  bool showingAll() const {
239  return outview->items.empty() || (outview->showFirst && outview->showLast);
240  }
241 };
242 
243 } } }
bool showingLast() const
True if the menu&#39;s last visible item is one of the currently visible items.
bool showFirst
True if the visible list includes the first visible item on the menu.
Definition: MenuOutput.hpp:104
const MenuItem & selectedItem() const
Returns the selected MenuItem object.
bool haveToggles() const
True if the menu has at least one MenuItem that is a toggle.
Definition: Menu.hpp:180
MenuVisibleList::const_iterator seliter
An iterator to the selected item.
MenuOutputAccess(MenuOutput &mov, std::size_t newRange=-1)
Creates a new MenuOutputAccess object that will provide information on the visible items from the giv...
const std::shared_ptr< MenuItem > & item(std::size_t index) const
Returns the MenuItem object at the given position on the menu, not the position of visible items...
void retire() noexcept
Relinquishes access to the outview&#39;s data.
std::size_t size() const
Returns the number of visible menu items.
bool changed() const
True if the view has changed since the last access.
std::size_t lastIndex() const
Returns the index of the last visible menu item, or -1 for an empty menu.
bool showingAll() const
True if the entire menu is currently visible.
std::size_t selected
Index of the selected item from the container of all menu items.
Definition: MenuOutput.hpp:91
bool empty() const
Returns true if there are no visible menu items.
bool changed() const
True if the view has changed.
Definition: MenuOutput.hpp:170
bool showingFirst() const
True if the menu&#39;s first visible item is one of the currently visible items.
void maxVisible(std::size_t newRange) const
Changes the maximum number of visible menu items and causes the visible list to be regenerated...
const Menu * menu() const
Returns the Menu in use.
Stores the data that defines a menu and provides thread-safe access to that data. ...
Definition: Menu.hpp:45
std::size_t selectedIndex() const
Returns the index of the currently selected MenuItem from Menu&#39;s container.
MenuOutputAccess(const MenuOutputSptr &mov, std::size_t newRange=-1)
Creates a new MenuOutputAccess object that will provide information on the visible items from the giv...
const MenuVisibleList::const_iterator & selectedIter() const
Returns an iterator to the selected menu item.
const MenuOutput * outputView() const
Returns the MenuOutput being accessed.
bool haveToggles() const
True if the menu has at least one MenuItem that is a toggle, even if none of the toggles are visible...
std::size_t maxVisible() const
Returns the currently set maximum number of visible menu items.
ItemVec::const_iterator iterator(std::size_t index) const
Returns an iterator to the MenuItem object at the given position.
Definition: Menu.cpp:53
MenuOutputAccess(MenuOutput *mov, std::size_t newRange=-1)
Creates a new MenuOutputAccess object that will provide information on the visible items from the giv...
MenuVisibleList::const_iterator end() const
Returns an iterator to the end of the visible menu items.
MenuVisibleList::const_iterator seliter
Iterator to the currently selected item.
Definition: MenuOutput.hpp:65
std::size_t lastIdx
Index of the last menu item that is visible.
Definition: MenuOutput.hpp:81
MenuVisibleList items
The currently visible menu items.
Definition: MenuOutput.hpp:58
Menu * viewmenu
The menu used by the view.
Represents an option that a user can chose from a menu of options.
Definition: MenuItem.hpp:58
MenuOutput * outview
The output view being accessed.
std::size_t firstIdx
Index of the first menu item that is visible.
Definition: MenuOutput.hpp:77
void maxVisible(std::size_t newRange)
Changes the maximum number of visible menu items and causes the visible list to be regenerated...
Definition: MenuOutput.cpp:61
std::size_t selectedVisible() const
Returns the index of the currently selected MenuItem within the list of currently visible items...
MenuVisibleList::const_iterator begin() const
Returns an iterator to the start of the visible menu items.
std::size_t selectedVis
Index of the selected item within the list of currently visible menu items.
Definition: MenuOutput.hpp:73
Compiles a list of visible menu items based on the selected item of a MenuView.
Definition: MenuOutput.hpp:45
bool showLast
True if the visible list includes the last visible item on the menu.
Definition: MenuOutput.hpp:108
~MenuOutputAccess()
Relinquishes access to the outview&#39;s data.
std::size_t range
The maximum number of visible items.
Definition: MenuOutput.hpp:85
Provides access to a MenuOutput for rendering.
std::size_t firstIndex() const
Returns the index of the first visible menu item, or -1 for an empty menu.
std::shared_ptr< MenuOutput > MenuOutputSptr
A shared pointer to a MenuOutput.
Definition: MenuOutput.hpp:231