Robowflex  v0.1
Making MoveIt Easy
robowflex::darts::WindowWidget Class Reference

IMGUI widget to add interactive GUI elements programmatically. More...

#include <gui.h>

+ Inheritance diagram for robowflex::darts::WindowWidget:

Public Member Functions

 WindowWidget ()
 Constructor. More...
 
void render () override
 Render GUI. More...
 
Element Addition
void addText (const std::string &text)
 Add a new text element to the GUI. More...
 
void addCheckbox (const std::string &text, bool &boolean)
 Add a new checkbox element to the GUI. More...
 
void addButton (const std::string &text, const ButtonCallback &callback)
 Add a new button element to the GUI. More...
 
void addCallback (const RenderCallback &callback)
 Add a generic render callback for the GUI. More...
 
void addElement (const ImGuiElementPtr &element)
 Add a generic element to the GUI. More...
 
- Public Member Functions inherited from robowflex::darts::Widget
virtual void initialize (Window *window)
 Initialization with window context. More...
 
virtual void prerefresh ()
 Called before window refresh. More...
 

Private Attributes

std::vector< ImGuiElementPtrelements_
 GUI elements. More...
 

Detailed Description

IMGUI widget to add interactive GUI elements programmatically.

Definition at line 368 of file gui.h.

Constructor & Destructor Documentation

◆ WindowWidget()

WindowWidget::WindowWidget ( )

Constructor.

Definition at line 362 of file gui.cpp.

363 {
364 }

Member Function Documentation

◆ addButton()

void WindowWidget::addButton ( const std::string text,
const ButtonCallback callback 
)

Add a new button element to the GUI.

Parameters
[in]textText to display on the button.
[in]callbackCallback upon button press.

Definition at line 388 of file gui.cpp.

389 {
390  addElement(std::make_shared<ButtonElement>(text, callback));
391 }
void addElement(const ImGuiElementPtr &element)
Add a generic element to the GUI.
Definition: gui.cpp:403
void callback(movegroup::MoveGroupHelper::Action &action)
Definition: tapedeck.cpp:20

◆ addCallback()

void WindowWidget::addCallback ( const RenderCallback callback)

Add a generic render callback for the GUI.

Parameters
[in]callbackCallback to render.

Definition at line 398 of file gui.cpp.

399 {
400  addElement(std::make_shared<RenderElement>(callback));
401 }

◆ addCheckbox()

void WindowWidget::addCheckbox ( const std::string text,
bool &  boolean 
)

Add a new checkbox element to the GUI.

Parameters
[in]textText to display on checkbox.
[in]booleanBoolean to modify upon checkbox change.

Definition at line 393 of file gui.cpp.

394 {
395  addElement(std::make_shared<CheckboxElement>(text, boolean));
396 }

◆ addElement()

void WindowWidget::addElement ( const ImGuiElementPtr element)

Add a generic element to the GUI.

Parameters
[in]elementElement to render.

Definition at line 403 of file gui.cpp.

404 {
405  elements_.push_back(element);
406 }
std::vector< ImGuiElementPtr > elements_
GUI elements.
Definition: gui.h:412

◆ addText()

void WindowWidget::addText ( const std::string text)

Add a new text element to the GUI.

Parameters
[in]textText to display.

Definition at line 383 of file gui.cpp.

384 {
385  addElement(std::make_shared<TextElement>(text));
386 }

◆ render()

void WindowWidget::render ( )
override

Render GUI.

Definition at line 366 of file gui.cpp.

367 {
368  if (elements_.empty())
369  return;
370 
371  ImGui::SetNextWindowBgAlpha(0.5f);
372  if (!ImGui::Begin("Robowflex DART", nullptr,
373  ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_HorizontalScrollbar))
374  {
375  ImGui::End();
376  return;
377  }
378 
379  for (const auto &element : elements_)
380  element->render();
381 }

Member Data Documentation

◆ elements_

std::vector<ImGuiElementPtr> robowflex::darts::WindowWidget::elements_
private

GUI elements.

Definition at line 412 of file gui.h.


The documentation for this class was generated from the following files: