CogEngine: Selection Window - Fix Pickup button not scaling with DPI

This commit is contained in:
Arnaud Jamin
2025-02-04 15:21:04 -05:00
parent 9bf32b2d86
commit 27c309ad87
3 changed files with 6 additions and 10 deletions
@@ -292,7 +292,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget()
{
ImGui::PushStyleVarX(ImGuiStyleVar_ItemSpacing, 0);
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
if (FCogWindowWidgets::PickButton("##Pick", ImVec2(20, 20)))
if (FCogWindowWidgets::PickButton("##Pick", ImVec2(ImGui::GetFrameHeight(), ImGui::GetFrameHeight())))
{
GetOwner()->SetActivateSelectionMode(true);
HackWaitInputRelease();
@@ -65,7 +65,7 @@ private:
FCogLogOutputDevice OutputDevice;
TWeakObjectPtr<UCogEngineConfig_OutputLog> Config = nullptr;
TWeakObjectPtr<UCogEngineConfig_OutputLog> Config;
};
//--------------------------------------------------------------------------------------------------------------------------
@@ -1361,14 +1361,10 @@ bool FCogWindowWidgets::PickButton(const char* InLabel, const ImVec2& InSize, Im
ImGui::RenderNavCursor(bb, id);
ImGui::RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding);
ImVec2 pos = bb.Min + ImVec2(ImMax(0.0f, (InSize.x - g.FontSize) * 0.5f), ImMax(0.0f, (InSize.y - g.FontSize) * 0.5f));
float scale = 1.0f;
const float h = window->DrawList->_Data->FontSize * 1.00f;
float r = h * 0.40f * scale;
ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
window->DrawList->AddCircle(center, r, text_col, 0, 1);
window->DrawList->AddCircleFilled(center, r * 0.3f, text_col);
const ImVec2 center = bb.GetCenter();
const float radius = window->DrawList->_Data->FontSize;
window->DrawList->AddCircle(center, radius * 0.4f, text_col, 0, 1);
window->DrawList->AddCircleFilled(center, radius * 0.15f, text_col);
return pressed;
}