Raspberry Pi Weighting Control System
This project serves as a simple weighting control system, that was realized as a Bachelor Thesis
gui_selectable.cpp
Go to the documentation of this file.
1 #include "gui_selectable.h"
2 
3 
4 gui_selectable::gui_selectable(const char *label, int index, int *selector, void (*callback)(),
5  int width, int height, ImGuiSelectableFlags flags)
6 {
7  this->label = label;
8  this->index = index;
9  this->selector = selector;
10  this->width = (width <= 0 ? 0 : width);
11  this->height = (height <= 0 ? 0 : height);
12  this->callback = callback;
13  this->flags = flags;
14  // "label##i" - is to ensure unique ImGuiID, but label should already be unique
15  this->inner_label = std::string(this->label) + "##" + std::to_string(this->index);
16 }
17 
20 
21  ImVec2 size((float) width, (float) height);
22  // if (ImGui::Selectable(this->inner_label.c_str(), this->index == *(this->selector), this->flags, size)) {
23  if (ImGui::Selectable(this->inner_label.c_str(), false, this->flags, size)) { // false - not highlighting selected element
24  *(this->selector) = this->index;
25 
26  if (this->callback != nullptr)
27  this->callback();
28  }
29 }
virtual void render_element()
Definition: gui_element.cpp:9
gui_selectable(const char *label, int index, int *selector, void(*callback)(), int width=-1, int height=-1, ImGuiSelectableFlags flags=0)
Construct a new gui selectable object.