From 46d34027054586b24e4906dbe1dda8d87e3c5626 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 14 Nov 2023 12:15:37 +0100 Subject: [PATCH] impr: Better UI for the command palette --- .../include/content/views/view_command_palette.hpp | 4 ++-- .../source/content/views/view_command_palette.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/builtin/include/content/views/view_command_palette.hpp b/plugins/builtin/include/content/views/view_command_palette.hpp index a66318f99..5e6a3502d 100644 --- a/plugins/builtin/include/content/views/view_command_palette.hpp +++ b/plugins/builtin/include/content/views/view_command_palette.hpp @@ -19,8 +19,8 @@ namespace hex::plugin::builtin { [[nodiscard]] bool shouldProcess() const override { return true; } [[nodiscard]] bool hasViewMenuItemEntry() const override { return false; } - [[nodiscard]] ImVec2 getMinSize() const override { return scaled({ 400, 100 }); } - [[nodiscard]] ImVec2 getMaxSize() const override { return scaled({ 400, 100 }); } + [[nodiscard]] ImVec2 getMinSize() const override { return scaled({ 600, 150 }); } + [[nodiscard]] ImVec2 getMaxSize() const override { return scaled({ 600, 150 }); } private: enum class MatchType diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index c871e5c30..2e651aac8 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -34,11 +34,23 @@ namespace hex::plugin::builtin { ImGui::CloseCurrentPopup(); + const auto buttonColor = [](float alpha) { + return ImU32(ImColor(ImGui::GetStyleColorVec4(ImGuiCol_ModalWindowDimBg) * ImVec4(1, 1, 1, alpha))); + }; + // Draw the main input text box ImGui::PushItemWidth(-1); + ImGui::PushStyleColor(ImGuiCol_FrameBg, buttonColor(0.5F)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, buttonColor(0.7F)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, buttonColor(0.9F)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0_scaled); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4_scaled); + if (ImGui::InputText("##command_input", this->m_commandBuffer)) { this->m_lastResults = this->getCommandResults(this->m_commandBuffer); } + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(3); ImGui::PopItemWidth(); ImGui::SetItemDefaultFocus(); @@ -74,6 +86,8 @@ namespace hex::plugin::builtin { this->m_justOpened = false; } + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetStyle().FramePadding.y); + ImGui::Separator(); // Draw the results