1#ifndef YAZE_APP_GUI_WIDGETS_WIDGET_AUTO_REGISTER_H_
2#define YAZE_APP_GUI_WIDGETS_WIDGET_AUTO_REGISTER_H_
6#include "imgui/imgui.h"
8#include "absl/strings/str_cat.h"
65 const std::string& explicit_label =
"",
66 const std::string& description =
"");
77inline bool AutoButton(
const char* label,
const ImVec2& size = ImVec2(0, 0)) {
78 bool clicked = ImGui::Button(label, size);
84 bool clicked = ImGui::SmallButton(label);
90 bool changed = ImGui::Checkbox(label, v);
96 bool clicked = ImGui::RadioButton(label, active);
102 bool clicked = ImGui::RadioButton(label, v, v_button);
108 ImGuiInputTextFlags flags = 0,
109 ImGuiInputTextCallback callback =
nullptr,
110 void* user_data =
nullptr) {
111 bool changed = ImGui::InputText(label, buf, buf_size, flags, callback, user_data);
117 const ImVec2& size = ImVec2(0, 0),
118 ImGuiInputTextFlags flags = 0,
119 ImGuiInputTextCallback callback =
nullptr,
120 void* user_data =
nullptr) {
121 bool changed = ImGui::InputTextMultiline(label, buf, buf_size, size, flags, callback, user_data);
126inline bool AutoInputInt(
const char* label,
int* v,
int step = 1,
int step_fast = 100,
127 ImGuiInputTextFlags flags = 0) {
128 bool changed = ImGui::InputInt(label, v, step, step_fast, flags);
134 float step_fast = 0.0f,
const char* format =
"%.3f",
135 ImGuiInputTextFlags flags = 0) {
136 bool changed = ImGui::InputFloat(label, v, step, step_fast, format, flags);
142 const char* format =
"%d", ImGuiSliderFlags flags = 0) {
143 bool changed = ImGui::SliderInt(label, v, v_min, v_max, format, flags);
149 const char* format =
"%.3f", ImGuiSliderFlags flags = 0) {
150 bool changed = ImGui::SliderFloat(label, v, v_min, v_max, format, flags);
155inline bool AutoCombo(
const char* label,
int* current_item,
const char*
const items[],
156 int items_count,
int popup_max_height_in_items = -1) {
157 bool changed = ImGui::Combo(label, current_item, items, items_count, popup_max_height_in_items);
163 ImGuiSelectableFlags flags = 0,
164 const ImVec2& size = ImVec2(0, 0)) {
165 bool clicked = ImGui::Selectable(label, selected, flags, size);
171 ImGuiSelectableFlags flags = 0,
172 const ImVec2& size = ImVec2(0, 0)) {
173 bool clicked = ImGui::Selectable(label, p_selected, flags, size);
178inline bool AutoMenuItem(
const char* label,
const char* shortcut =
nullptr,
179 bool selected =
false,
bool enabled =
true) {
180 bool activated = ImGui::MenuItem(label, shortcut, selected, enabled);
185inline bool AutoMenuItem(
const char* label,
const char* shortcut,
bool* p_selected,
186 bool enabled =
true) {
187 bool activated = ImGui::MenuItem(label, shortcut, p_selected, enabled);
193 bool opened = ImGui::BeginMenu(label, enabled);
201 ImGuiTabItemFlags flags = 0) {
202 bool selected = ImGui::BeginTabItem(label, p_open, flags);
210 bool opened = ImGui::TreeNode(label);
218 bool opened = ImGui::TreeNodeEx(label, flags);
226 bool opened = ImGui::CollapsingHeader(label, flags);
246inline void RegisterCanvas(
const char* canvas_name,
const std::string& description =
"") {
256inline void RegisterTable(
const char* table_name,
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)
Main namespace for the application.