1#ifndef YAZE_APP_GUI_AUTOMATION_WIDGET_ID_REGISTRY_H_
2#define YAZE_APP_GUI_AUTOMATION_WIDGET_ID_REGISTRY_H_
7#include <unordered_map>
10#include "absl/strings/string_view.h"
11#include "absl/synchronization/mutex.h"
12#include "absl/time/time.h"
13#include "imgui/imgui.h"
47 const std::string& widget_name)
const;
51 static thread_local std::vector<std::string>
id_stack_;
79 std::optional<std::string>
label;
110 void RegisterWidget(
const std::string& full_path,
const std::string& type,
111 ImGuiID imgui_id,
const std::string& description =
"",
115 std::vector<std::string>
FindWidgets(
const std::string& pattern)
const;
116 ImGuiID
GetWidgetId(
const std::string& full_path)
const;
117 std::optional<WidgetInfo>
GetWidgetInfo(
const std::string& full_path)
const;
120 std::unordered_map<std::string, WidgetInfo>
GetAllWidgets()
const;
127 std::string
ExportCatalog(
const std::string& format =
"yaml")
const;
129 const std::string& format =
"yaml")
const;
148#define YAZE_WIDGET_SCOPE(name) \
149 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()); \