Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Moved the Menu-Item constructors onto
ui
.I'm pleased with how this API looks, so I'm going to write this out. If @dbr and @thomcc also agree with this kind of design, I'll add this to our docs and aim to keep this format for most of our overload-style code.
ui.menu_item
creates amenu_item
with just a label, and nothing else. This function returns a bool directly -- this means that users don't have to write.build
at all. This allows for fast code to be written easily.ui.menu_item_x
are made for common overloads of a single value. So formenu_item
, I bound all of them the various parameters, since they're common enough -- so we have aui.menu_item_shortcut
,ui.menu_item_selected
,ui.menu_item_enabled
, etc. These, like the main simple one, return bool, not the Builder struct, so users shouldn't have to type.build
themselves.ui.menu_item_config
takes the same parameters as our basicui.menu_item
, but returns a Builder instead (ie, users need to type.build()
at the end). For less common situations, we can use this builder to generate complex forms.This should be generalizable to the vast majority of our builder structures, and in my code, made this as easy as it could be in a language without optional arguments. Optional arguments would be nice...
What do you think? imo, it would be nice if at least MOST of the library worked in a similar way