-
Notifications
You must be signed in to change notification settings - Fork 85
Patch 1 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Patch 1 #74
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,46 @@ class MenuItem : public MenuComponent { | |
virtual Menu* select(); | ||
}; | ||
|
||
class TextMenuItem : public MenuItem { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What benefit does a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not a fan of the name since a |
||
public: | ||
//! \brief Construct a TextMenuItem | ||
//! \param[in] name The name of the menu component that is displayed in | ||
//! clients. | ||
//! \param[in] select_fn The function to call when the MenuItem is | ||
//! selected. | ||
TextMenuItem(const char* name, SelectFnPtr select_fn); | ||
void set_values(char** values, int count){this->_values = values;this->count = count;} | ||
void set_value(String value){this->_value = value;} | ||
char* get_value(){return _values[current_value_id];} | ||
|
||
//! \copydoc MenuComponent::render | ||
virtual void render(MenuComponentRenderer const& renderer) const; | ||
|
||
protected: | ||
//! \copydoc MenuComponent::next | ||
//! | ||
//! This method does nothing in MenyItem. | ||
virtual bool next(bool loop=false); | ||
|
||
//! \copydoc MenuComponent::prev | ||
//! | ||
//! This method does nothing in MenuItem. | ||
virtual bool prev(bool loop=false); | ||
|
||
//! \copydoc MenuComponent::reset | ||
//! | ||
//! This method does nothing in MenuItem. | ||
virtual void reset(); | ||
|
||
//! \copydoc MenuComponent:select | ||
virtual Menu* select(); | ||
private: | ||
String _value; | ||
int current_value_id; | ||
char** _values; | ||
int count; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All private member variable should be prefixed with an underscore. |
||
}; | ||
|
||
|
||
//! \brief A MenuItem that calls MenuSystem::back() when selected. | ||
//! \see MenuItem | ||
|
@@ -292,7 +332,6 @@ class NumericMenuItem : public MenuItem { | |
FormatValueFnPtr _format_value_fn; | ||
}; | ||
|
||
|
||
//! \brief A MenuComponent that can contain other MenuComponents. | ||
//! | ||
//! Menu represents the branch in the composite design pattern (see: | ||
|
@@ -382,6 +421,7 @@ class MenuComponentRenderer { | |
virtual void render(Menu const& menu) const = 0; | ||
|
||
virtual void render_menu_item(MenuItem const& menu_item) const = 0; | ||
virtual void render_text_menu_item(TextMenuItem const& menu_item) const = 0; | ||
virtual void render_back_menu_item(BackMenuItem const& menu_item) const = 0; | ||
virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const = 0; | ||
virtual void render_menu(Menu const& menu) const = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One initialization list item per line. See other classes for example.