1#ifndef YAZE_APP_GUI_WIDGETS_WIDGET_ID_REGISTRY_H_
2#define YAZE_APP_GUI_WIDGETS_WIDGET_ID_REGISTRY_H_
7#include <unordered_map>
10#include "absl/strings/string_view.h"
11#include "absl/time/time.h"
12#include "imgui/imgui.h"
46 const std::string& widget_name)
const;
50 static thread_local std::vector<std::string>
id_stack_;
78 std::optional<std::string>
label;
109 void RegisterWidget(
const std::string& full_path,
const std::string& type,
111 const std::string& description =
"",
115 std::vector<std::string>
FindWidgets(
const std::string& pattern)
const;
116 ImGuiID
GetWidgetId(
const std::string& full_path)
const;
129 std::string
ExportCatalog(
const std::string& format =
"yaml")
const;
131 const std::string& format =
"yaml")
const;
142 std::unordered_map<std::string, WidgetInfo>
widgets_;
149#define YAZE_WIDGET_SCOPE(name) yaze::gui::WidgetIdScope _yaze_scope_##__LINE__(name)
152#define YAZE_REGISTER_WIDGET(widget_type, widget_name) \
154 if (ImGui::GetItemID() != 0) { \
155 yaze::gui::WidgetIdRegistry::Instance().RegisterWidget( \
156 _yaze_scope_##__LINE__.GetWidgetPath(#widget_type, widget_name), \
157 #widget_type, ImGui::GetItemID()); \
163#define YAZE_REGISTER_CURRENT_WIDGET(widget_type) \
165 if (ImGui::GetItemID() != 0) { \
166 yaze::gui::WidgetIdRegistry::Instance().RegisterWidget( \
167 _yaze_scope_##__LINE__.GetWidgetPath(widget_type, \
168 ImGui::GetLastItemLabel()), \
169 widget_type, ImGui::GetItemID()); \
Main namespace for the application.