From 2dbbeba44d2e98e04e8260a3d814598e89be64e9 Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 22 Jan 2024 22:08:29 -0500 Subject: [PATCH] Add BeginWindowWithDisplaySettings with background opacity to start --- src/app/editor/overworld_editor.cc | 14 ++++++++------ src/app/gui/style.cc | 26 +++++++++++++++++++++++++- src/app/gui/style.h | 6 ++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index ac8e8548..0d02bf46 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -296,9 +296,9 @@ absl::Status OverworldEditor::DrawToolset() { } if (show_gfx_group) { - ImGui::Begin("Gfx Group Editor", &show_gfx_group); + gui::BeginWindowWithDisplaySettings("Gfx Group Editor", &show_gfx_group); RETURN_IF_ERROR(gfx_group_editor_.Update()) - ImGui::End(); + gui::EndWindowWithDisplaySettings(); } if (show_properties) { @@ -721,13 +721,15 @@ void OverworldEditor::CheckForCurrentMap() { parent_map_x * small_map_size, large_map_size, large_map_size); // ow_map_canvas_.mutable_points()->push_back( - // ImVec2(parent_map_x * small_map_size, parent_map_y * small_map_size)); + // ImVec2(parent_map_x * small_map_size, parent_map_y * + // small_map_size)); } else { ow_map_canvas_.DrawOutline(current_map_x * small_map_size, - current_map_y * small_map_size, - small_map_size, small_map_size); + current_map_y * small_map_size, small_map_size, + small_map_size); // ow_map_canvas_.mutable_points()->push_back( - // ImVec2(current_map_x * small_map_size, current_map_y * small_map_size)); + // ImVec2(current_map_x * small_map_size, current_map_y * + // small_map_size)); } static int prev_map_; diff --git a/src/app/gui/style.cc b/src/app/gui/style.cc index c8d2819c..f0d5fdc6 100644 --- a/src/app/gui/style.cc +++ b/src/app/gui/style.cc @@ -5,9 +5,32 @@ namespace yaze { namespace app { - namespace gui { +void BeginWindowWithDisplaySettings(const char* id, bool* active, const ImVec2& size, + ImGuiWindowFlags flags) { + ImGuiStyle* ref = &ImGui::GetStyle(); + static float childBgOpacity = 0.75f; + auto color = ImVec4(0.f, 0.f, 0.f, childBgOpacity); + + ImGui::PushStyleColor(ImGuiCol_WindowBg, color); + ImGui::PushStyleColor(ImGuiCol_ChildBg, color); + ImGui::PushStyleColor(ImGuiCol_Border, color); + + ImGui::Begin(id, active, flags | ImGuiWindowFlags_MenuBar); + ImGui::BeginMenuBar(); + if (ImGui::BeginMenu("Display Settings")) { + ImGui::SliderFloat("Child Background Opacity", &childBgOpacity, 0.0f, 1.0f); + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); +} + +void EndWindowWithDisplaySettings() { + ImGui::End(); + ImGui::PopStyleColor(3); +} + void DrawDisplaySettings(ImGuiStyle* ref) { // You can pass in a reference ImGuiStyle structure to compare to, revert to // and save to (without a reference style pointer, we will use one compared @@ -473,6 +496,7 @@ void ColorsYaze() { colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); } + } // namespace gui } // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/gui/style.h b/src/app/gui/style.h index 6599a0a1..2c656dfb 100644 --- a/src/app/gui/style.h +++ b/src/app/gui/style.h @@ -9,6 +9,12 @@ namespace yaze { namespace app { namespace gui { +void BeginWindowWithDisplaySettings(const char* id, bool* active, + const ImVec2& size = ImVec2(0, 0), + ImGuiWindowFlags flags = 0); + +void EndWindowWithDisplaySettings(); + void DrawDisplaySettings(ImGuiStyle* ref = nullptr); void TextWithSeparators(const absl::string_view& text);