1#ifndef YAZE_APP_GUI_AUTOMATION_WIDGET_AUTO_REGISTER_H_
2#define YAZE_APP_GUI_AUTOMATION_WIDGET_AUTO_REGISTER_H_
6#include "absl/strings/str_cat.h"
8#include "imgui/imgui.h"
67 const std::string& explicit_label =
"",
68 const std::string& description =
"");
79inline bool AutoButton(
const char* label,
const ImVec2& size = ImVec2(0, 0)) {
80 bool clicked = ImGui::Button(label, size);
86 bool clicked = ImGui::SmallButton(label);
92 bool changed = ImGui::Checkbox(label, v);
98 bool clicked = ImGui::RadioButton(label, active);
104 bool clicked = ImGui::RadioButton(label, v, v_button);
110 ImGuiInputTextFlags flags = 0,
111 ImGuiInputTextCallback callback =
nullptr,
112 void* user_data =
nullptr) {
114 ImGui::InputText(label, buf, buf_size, flags, callback, user_data);
121 const ImVec2& size = ImVec2(0, 0),
122 ImGuiInputTextFlags flags = 0,
123 ImGuiInputTextCallback callback =
nullptr,
124 void* user_data =
nullptr) {
125 bool changed = ImGui::InputTextMultiline(label, buf, buf_size, size, flags,
126 callback, user_data);
132 int step_fast = 100, ImGuiInputTextFlags flags = 0) {
133 bool changed = ImGui::InputInt(label, v, step, step_fast, flags);
139 float step_fast = 0.0f,
const char* format =
"%.3f",
140 ImGuiInputTextFlags flags = 0) {
141 bool changed = ImGui::InputFloat(label, v, step, step_fast, format, flags);
147 const char* format =
"%d",
148 ImGuiSliderFlags flags = 0) {
149 bool changed = ImGui::SliderInt(label, v, v_min, v_max, format, flags);
155 float v_max,
const char* format =
"%.3f",
156 ImGuiSliderFlags flags = 0) {
157 bool changed = ImGui::SliderFloat(label, v, v_min, v_max, format, flags);
162inline bool AutoCombo(
const char* label,
int* current_item,
163 const char*
const items[],
int items_count,
164 int popup_max_height_in_items = -1) {
165 bool changed = ImGui::Combo(label, current_item, items, items_count,
166 popup_max_height_in_items);
172 ImGuiSelectableFlags flags = 0,
173 const ImVec2& size = ImVec2(0, 0)) {
174 bool clicked = ImGui::Selectable(label, selected, flags, size);
180 ImGuiSelectableFlags flags = 0,
181 const ImVec2& size = ImVec2(0, 0)) {
182 bool clicked = ImGui::Selectable(label, p_selected, flags, size);
187inline bool AutoMenuItem(
const char* label,
const char* shortcut =
nullptr,
188 bool selected =
false,
bool enabled =
true) {
189 bool activated = ImGui::MenuItem(label, shortcut, selected, enabled);
195 bool* p_selected,
bool enabled =
true) {
196 bool activated = ImGui::MenuItem(label, shortcut, p_selected, enabled);
202 bool opened = ImGui::BeginMenu(label, enabled);
210 ImGuiTabItemFlags flags = 0) {
211 bool selected = ImGui::BeginTabItem(label, p_open, flags);
219 bool opened = ImGui::TreeNode(label);
227 bool opened = ImGui::TreeNodeEx(label, flags);
235 ImGuiTreeNodeFlags flags = 0) {
236 bool opened = ImGui::CollapsingHeader(label, flags);
257 const std::string& description =
"") {
268 const std::string& description =
"") {
void RegisterTable(const char *table_name, const std::string &description="")
Register a table after BeginTable.
bool AutoBeginTabItem(const char *label, bool *p_open=nullptr, ImGuiTabItemFlags flags=0)
void AutoRegisterLastItem(const std::string &widget_type, const std::string &explicit_label, const std::string &description)
Automatically register the last ImGui item.
bool AutoInputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
bool AutoInputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
bool AutoInputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
bool AutoTreeNode(const char *label)
bool AutoSelectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
bool AutoSliderFloat(const char *label, float *v, float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
bool AutoCheckbox(const char *label, bool *v)
bool AutoRadioButton(const char *label, bool active)
bool AutoTreeNodeEx(const char *label, ImGuiTreeNodeFlags flags=0)
bool AutoButton(const char *label, const ImVec2 &size=ImVec2(0, 0))
bool AutoSmallButton(const char *label)
void RegisterCanvas(const char *canvas_name, const std::string &description="")
Register a canvas widget after BeginChild or similar.
bool AutoCombo(const char *label, int *current_item, const char *const items[], int items_count, int popup_max_height_in_items=-1)
bool AutoMenuItem(const char *label, const char *shortcut=nullptr, bool selected=false, bool enabled=true)
bool AutoCollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
bool AutoInputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
bool AutoSliderInt(const char *label, int *v, int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
bool AutoBeginMenu(const char *label, bool enabled=true)