1
0
mirror of synced 2025-02-11 08:12:58 +01:00
ImHex/plugins/ui/include/banners/banner_icon.hpp
paxcut 2f981ef91e
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.
2025-01-30 20:18:44 +01:00

27 lines
841 B
C++

#pragma once
#include <hex/ui/banner.hpp>
#include <imgui.h>
namespace hex::ui {
class BannerIcon : public Banner<BannerIcon> {
public:
BannerIcon(const char *icon, UnlocalizedString message, ImColor color)
: 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));
}
private:
const char *m_icon;
UnlocalizedString m_message;
};
}