FastLED 3.9.15
Loading...
Searching...
No Matches
dropdown.cpp.hpp
Go to the documentation of this file.
1#include "fl/ui/dropdown.h"
2#include "fl/stl/noexcept.h"
3
4namespace fl {
5
6UIDropdown::UIDropdown(const char *name, fl::span<fl::string> options) FL_NOEXCEPT
7 : mImpl(fl::string(name), options), mListener(this) {
8 mListener.addToEngineEventsOnce();
9}
10
11UIDropdown::UIDropdown(const char *name, fl::initializer_list<fl::string> options) FL_NOEXCEPT
12 : mImpl(name, options), mListener(this) {
13 mListener.addToEngineEventsOnce();
14}
15
17
19 UIDropdown &owner = *mOwner;
20
21 // Seed baseline before any first-frame advance so a nextOption() triggered
22 // on the very first frame still produces a change callback.
23 if (!owner.mLastFrameValueValid) {
24 owner.mLastFrameValue = owner.as_int();
25 owner.mLastFrameValueValid = true;
26 }
27
28 // Check the next button if one is attached (via IButtonInput interface)
29 if (owner.mNextButton && owner.mNextButton->clicked()) {
30 owner.nextOption();
31 }
32
33 int value = owner.as_int();
34 if (value != owner.mLastFrameValue) {
35 owner.mCallbacks.invoke(owner);
36 owner.mLastFrameValue = value;
37 }
38}
39
40} // namespace fl
UIDropdown(const char *name, fl::initializer_list< fl::string > options) FL_NOEXCEPT
~UIDropdown() FL_NOEXCEPT
Listener mListener
Definition dropdown.h:197
function_list< void(UIDropdown &)> mCallbacks
Definition dropdown.h:193
fl::shared_ptr< IButtonInput > mNextButton
Definition dropdown.h:196
bool mLastFrameValueValid
Definition dropdown.h:195
fl::string value() const FL_NOEXCEPT
Definition dropdown.h:126
UIDropdownImpl mImpl
Definition dropdown.h:169
int mLastFrameValue
Definition dropdown.h:194
int as_int() const FL_NOEXCEPT
Definition dropdown.h:127
fl::span< fl::string > options FL_NOEXCEPT
Definition dropdown.h:122
void nextOption() FL_NOEXCEPT
Definition dropdown.h:150
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
void onBeginFrame() FL_NOEXCEPT override