mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
ImGui:: correctly calculate item width
Fixed bug where changing the server browser causes the alignment of the buttons with the right side border to mess up.
This commit is contained in:
parent
26b99359d6
commit
ead3634a01
@ -305,8 +305,15 @@ void CBrowser::BrowserPanel(void)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
const ImVec2 contentRegionMax = ImGui::GetContentRegionAvail();
|
const ImVec2 regionAvail = ImGui::GetContentRegionAvail();
|
||||||
ImGui::PushItemWidth(contentRegionMax.x / 4);
|
const ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
|
||||||
|
// 4 elements means 3 spacings between items, this has to be subtracted
|
||||||
|
// from the remaining available region to get correct results on all
|
||||||
|
// window padding values!!!
|
||||||
|
const float itemWidth = (regionAvail.x - (3 * style.ItemSpacing.x)) / 4;
|
||||||
|
|
||||||
|
ImGui::PushItemWidth(itemWidth);
|
||||||
{
|
{
|
||||||
ImGui::InputTextWithHint("##ServerBrowser_ServerCon", "Server address and port", m_szServerAddressBuffer, IM_ARRAYSIZE(m_szServerAddressBuffer));
|
ImGui::InputTextWithHint("##ServerBrowser_ServerCon", "Server address and port", m_szServerAddressBuffer, IM_ARRAYSIZE(m_szServerAddressBuffer));
|
||||||
|
|
||||||
@ -314,7 +321,7 @@ void CBrowser::BrowserPanel(void)
|
|||||||
ImGui::InputTextWithHint("##ServerBrowser_ServerKey", "Encryption key", m_szServerEncKeyBuffer, IM_ARRAYSIZE(m_szServerEncKeyBuffer));
|
ImGui::InputTextWithHint("##ServerBrowser_ServerKey", "Encryption key", m_szServerEncKeyBuffer, IM_ARRAYSIZE(m_szServerEncKeyBuffer));
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Connect", ImVec2(contentRegionMax.x / 4.3f, ImGui::GetFrameHeight())))
|
if (ImGui::Button("Connect", ImVec2(itemWidth, ImGui::GetFrameHeight())))
|
||||||
{
|
{
|
||||||
if (m_szServerAddressBuffer[0])
|
if (m_szServerAddressBuffer[0])
|
||||||
{
|
{
|
||||||
@ -323,12 +330,14 @@ void CBrowser::BrowserPanel(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Private servers", ImVec2(contentRegionMax.x / 4.3f, ImGui::GetFrameHeight())))
|
if (ImGui::Button("Private servers", ImVec2(itemWidth, ImGui::GetFrameHeight())))
|
||||||
{
|
{
|
||||||
ImGui::OpenPopup("Private Server");
|
ImGui::OpenPopup("Private Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
HiddenServersModal();
|
HiddenServersModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user