Add BeginWindowWithDisplaySettings with background opacity to start

This commit is contained in:
scawful
2024-01-22 22:08:29 -05:00
parent ff8a6a18f3
commit 2dbbeba44d
3 changed files with 39 additions and 7 deletions

View File

@@ -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_;

View File

@@ -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

View File

@@ -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);