43 OptionView(std::string name, std::map<uint8_t, std::string> options,
44 uint8_t defaultOption = 0, uint8_t numCols = 4)
47 uint8_t numRows = options.size() / numCols;
48 if (options.size() % numCols != 0)
51 gridOptions =
new GridLayout(numRows, numCols);
53 unsigned int gridPos = 0;
55 for (
auto it = options.begin(); it != options.end(); it++)
57 using namespace std::placeholders;
62 std::bind(&OptionView::onOptionClick,
this, _1, _2));
65 mapOptions[tvOpt] = it->first;
67 gridOptions->
setCell(tvOpt, gridPos++);
69 if (i == defaultOption)
80 for (
auto it = mapOptions.begin(); it != mapOptions.end(); it++)
106 optListeners.push_back(listener);
111 std::vector<View*> out;
112 out.push_back(tvTitle);
113 out.push_back(gridOptions);
118 void draw(mxgui::DrawingContext& dc)
override
122 gridOptions->
draw(dc);
128 if (selectedOption !=
nullptr)
131 selectedOption = opt;
140 TextView* textview =
static_cast<TextView*
>(option);
142 selectOption(textview);
144 for (
auto l : optListeners)
146 l(mapOptions[textview]);
151 mxgui::Color colBgNormal = mxgui::black;
152 mxgui::Color colBgHighlight = mxgui::blue;
154 GridLayout* gridOptions;
155 std::map<TextView*, uint8_t> mapOptions;
157 std::vector<OnOptionChosenListener> optListeners;
159 TextView* selectedOption =
nullptr;
if(canDrivers[canDev]) canDrivers[canDev] -> handleRXInterrupt(fifo)
Displays childs in a numRows*numCols grid.
void setCell(View *child, unsigned int position)
void setBounds(Bounds bounds) override
Sets the bounds in which the view will be drawn.
virtual void draw(mxgui::DrawingContext &context) override
Draw the view in its bounds.
View used to display an option list, so the user can select one by clicking on it.
OptionView(std::string name, std::map< uint8_t, std::string > options, uint8_t defaultOption=0, uint8_t numCols=4)
void addOnOptionChosenListener(OnOptionChosenListener listener)
Adds a callback to be called each time an option is selected by the user.
std::function< void(unsigned int id)> OnOptionChosenListener
std::vector< View * > getChilds() override
Returns the list of childs.
void setBounds(Bounds bounds) override
Sets the bounds in which the view will be drawn.
void draw(mxgui::DrawingContext &dc) override
Draw the view in its bounds.
Simple view to display text on screen.
virtual void draw(mxgui::DrawingContext &dc) override
Draw the view in its bounds.
void setAlignment(HorizAlignment horizAlign, VertAlignment vertAlign)
Base class for anything that can be drawn on the screen and interacted with.
virtual void draw(mxgui::DrawingContext &dc)
Draw the view in its bounds.
virtual void setBackgroundColor(mxgui::Color color)
void addOnInteractionListener(OnInteractionListener listener)
void setSelectable(bool selectable)
virtual void setBounds(Bounds bounds)
Sets the bounds in which the view will be drawn.
Driver for the VN100S IMU.