summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/imgui-raii.cpp6
-rw-r--r--editor/imgui-raii.hpp1
-rw-r--r--editor/imgui-scenery.cpp4
-rw-r--r--editor/imgui-tiles.cpp2
-rw-r--r--editor/imgui.cpp5
5 files changed, 16 insertions, 2 deletions
diff --git a/editor/imgui-raii.cpp b/editor/imgui-raii.cpp
index 8f784126..05e9edab 100644
--- a/editor/imgui-raii.cpp
+++ b/editor/imgui-raii.cpp
@@ -36,6 +36,12 @@ raii_wrapper push_style_color(ImGuiCol_ var, const Color4& value)
return {[]{ ImGui::PopStyleColor(); }};
}
+raii_wrapper push_id(StringView str)
+{
+ ImGui::PushID(str.data(), str.data() + str.size());
+ return {[]{ ImGui::PopID(); }};
+}
+
raii_wrapper push_style_var(ImGuiStyleVar_ var, float value)
{
ImGui::PushStyleVar(var, value);
diff --git a/editor/imgui-raii.hpp b/editor/imgui-raii.hpp
index 69693e20..ba283195 100644
--- a/editor/imgui-raii.hpp
+++ b/editor/imgui-raii.hpp
@@ -33,6 +33,7 @@ private:
[[nodiscard]] raii_wrapper push_style_var(ImGuiStyleVar_ var, Vector2 value);
[[nodiscard]] raii_wrapper push_style_var(ImGuiStyleVar_ var, float value);
[[nodiscard]] raii_wrapper push_style_color(ImGuiCol_ var, const Color4& value);
+[[nodiscard]] raii_wrapper push_id(StringView str);
void text(StringView str, ImGuiTextFlags flags = ImGuiTextFlags_NoWidthForLargeClippedText);
diff --git a/editor/imgui-scenery.cpp b/editor/imgui-scenery.cpp
index 5c4fd37d..45861fd8 100644
--- a/editor/imgui-scenery.cpp
+++ b/editor/imgui-scenery.cpp
@@ -11,12 +11,14 @@ using namespace floormat::imgui;
void app::draw_editor_scenery_pane(scenery_editor& ed)
{
+ const auto b1 = push_id("scenery-pane");
+
const auto& style = ImGui::GetStyle();
const auto dpi = M->dpi_scale();
constexpr ImGuiTableFlags flags = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_ScrollY;
constexpr int ncolumns = 4;
const auto size = ImGui::GetWindowSize();
- auto b = imgui::begin_table("scenery-table", ncolumns, flags, size);
+ auto b2 = imgui::begin_table("scenery-table", ncolumns, flags, size);
const auto row_height = ImGui::GetCurrentContext()->FontSize + 5*dpi;
constexpr auto thumbnail_width = 50;
const auto colwidth_type = ImGui::CalcTextSize("generic").x;
diff --git a/editor/imgui-tiles.cpp b/editor/imgui-tiles.cpp
index 824ea1e7..79bf2166 100644
--- a/editor/imgui-tiles.cpp
+++ b/editor/imgui-tiles.cpp
@@ -11,6 +11,8 @@ using namespace floormat::imgui;
void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas)
{
+ const auto b = push_id("tile-pane");
+
const auto dpi = M->dpi_scale();
constexpr Color4 color_perm_selected{1, 1, 1, .7f},
color_selected{1, 0.843f, 0, .8f},
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 15f6bc37..e1b39d07 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -154,13 +154,16 @@ void app::draw_editor_pane(float main_menu_height)
if (main_menu_height > 0)
{
+ const auto b = push_id("editor");
+
ImGui::SetNextWindowPos({0, main_menu_height+style.WindowPadding.y});
ImGui::SetNextFrameWantCaptureKeyboard(false);
ImGui::SetNextWindowSize({425 * dpi, window_size[1] - main_menu_height - style.WindowPadding.y});
if (const auto flags = ImGuiWindowFlags_(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
auto b = begin_window({}, flags))
{
- if (auto b = begin_list_box("##atlases", {-FLT_MIN, -1}))
+ const auto b2 = push_id("editor-pane");
+ if (auto b3 = begin_list_box("##atlases", {-FLT_MIN, -1}))
{
if (ed)
for (const auto& [k, v] : *ed)