mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
fix: Banners not scaling properly with font size (#2096)
The banner windows did not scale with the fonts resulting in cropped text when font size was made bigger than normal. fixed by ensuring the window is big enough and then making sure text is centered in the y-axis.
This commit is contained in:
@@ -15,7 +15,10 @@ namespace hex::ui {
|
||||
void drawContent() override {
|
||||
const std::string buttonText = Lang(m_buttonText);
|
||||
const auto buttonSize = ImGui::CalcTextSize(buttonText.c_str());
|
||||
|
||||
const auto iconSize = ImGui::CalcTextSize(m_icon);
|
||||
const auto textHeight = std::max(ImGui::CalcTextSize(Lang(m_message)).y, iconSize.y);
|
||||
const auto textOffset = (ImGui::GetWindowHeight() - textHeight) / 2;
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + textOffset);
|
||||
ImGui::TextUnformatted(m_icon);
|
||||
ImGui::SameLine(0, 10_scaled);
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace hex::ui {
|
||||
: Banner(color), m_icon(icon), m_message(std::move(message)) { }
|
||||
|
||||
void drawContent() override {
|
||||
auto textHeight = std::max(ImGui::CalcTextSize(Lang(m_message)).y, ImGui::CalcTextSize(m_icon).y);
|
||||
auto textOffset = (ImGui::GetWindowHeight() - textHeight) / 2;
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + textOffset);
|
||||
ImGui::TextUnformatted(m_icon);
|
||||
ImGui::SameLine(0, 10_scaled);
|
||||
ImGui::TextUnformatted(Lang(m_message));
|
||||
|
||||
Reference in New Issue
Block a user