diff options
-rw-r--r-- | main/imgui.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/main/imgui.cpp b/main/imgui.cpp index db4f321b..04dc49ed 100644 --- a/main/imgui.cpp +++ b/main/imgui.cpp @@ -83,6 +83,7 @@ void app::draw_editor_pane(tile_type& type, float main_menu_height) }; const auto& style = ImGui::GetStyle(); + tile_type* const ed = _editor.current(); if (main_menu_height > 0) { @@ -93,9 +94,8 @@ void app::draw_editor_pane(tile_type& type, float main_menu_height) auto b = begin_window({}, flags)) { const float window_width = ImGui::GetWindowWidth() - 32; - const auto* ed = _editor.current(); - char buf[64]; + char buf[128]; //ImGui::SetNextWindowBgAlpha(.2f); if (auto b = begin_list_box("##atlases", {-FLT_MIN, -1})) @@ -105,8 +105,13 @@ void app::draw_editor_pane(tile_type& type, float main_menu_height) ///const auto& k_ = k; const auto& v_ = v; const auto click_event = [&] { - if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) - _editor.floor().select_tile_permutation(v_); + if (ed) + { + if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) + ed->select_tile_permutation(v_); + else if (ImGui::IsItemClicked(ImGuiMouseButton_Middle)) + ed->clear_selection(); + } }; const auto add_tile_count = [&] { snprintf(buf, sizeof(buf), "%zu", (std::size_t)v_->num_tiles()); @@ -114,8 +119,9 @@ void app::draw_editor_pane(tile_type& type, float main_menu_height) ImGui::Text("%s", buf); }; const auto N = v->num_tiles(); + std::snprintf(buf, sizeof(buf), "%s%s", k.data(), ed && ed->is_permutation_selected(v) ? " (selected)" : ""); if (const auto flags = ImGuiTreeNodeFlags_(ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Framed); - auto b = tree_node(k.data(), flags)) + auto b = tree_node(buf, flags)) { click_event(); add_tile_count(); @@ -143,10 +149,13 @@ void app::draw_editor_pane(tile_type& type, float main_menu_height) const auto uv = v->texcoords_for_id(i); ImGui::ImageButton(buf, (void*)&v->texture(), {TILE_SIZE[0]/2, TILE_SIZE[1]/2}, { uv[3][0], uv[3][1] }, { uv[0][0], uv[0][1] }); - if (ImGui::IsItemClicked()) - _editor.floor().select_tile(v, i); - else - click_event(); + if (ed) + { + if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) + ed->select_tile(v, i); + else + click_event(); + } ImGui::SameLine(); } ImGui::NewLine(); |