3#include "absl/strings/str_format.h"
4#include "imgui/imgui.h"
5#include "imgui/imgui_internal.h"
11 const std::string& type) {
21 metrics.
rect_min = ImGui::GetItemRectMin();
22 metrics.
rect_max = ImGui::GetItemRectMax();
62 float end_x = ImGui::GetCursorPosX();
83 float available_width)
const {
85 return toolbar_width > available_width;
89 const std::string& toolbar_id)
const {
90 static const std::vector<WidgetMetrics> empty;
104 std::string json =
"{\n \"toolbars\": {\n";
106 bool first_toolbar =
true;
110 first_toolbar =
false;
112 json += absl::StrFormat(
" \"%s\": {\n", toolbar_id);
113 json += absl::StrFormat(
" \"total_width\": %.1f,\n",
115 json +=
" \"widgets\": [\n";
117 bool first_widget =
true;
118 for (
const auto& metric : metrics) {
121 first_widget =
false;
124 json += absl::StrFormat(
" \"id\": \"%s\",\n", metric.widget_id);
125 json += absl::StrFormat(
" \"type\": \"%s\",\n", metric.type);
126 json += absl::StrFormat(
" \"width\": %.1f,\n", metric.size.x);
127 json += absl::StrFormat(
" \"height\": %.1f,\n", metric.size.y);
128 json += absl::StrFormat(
" \"x\": %.1f,\n", metric.position.x);
129 json += absl::StrFormat(
" \"y\": %.1f\n", metric.position.y);