Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Menu/HomePageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,18 @@ void HomePageRenderer::RenderWelcomeSection()
}

if (discordIconAvailable) {
ImVec2 iconSize = ImVec2(menu->uiIcons.discord.size.x, menu->uiIcons.discord.size.y);
// Calculate scaled icon size based on window width, with min/max constraints
ImVec2 originalSize = ImVec2(menu->uiIcons.discord.size.x, menu->uiIcons.discord.size.y);

// Compute width based on window size with constraints and padding (handles very small windows)
float ratioWidth = windowSize.x * DISCORD_BANNER_TARGET_WIDTH_RATIO;
float aspectRatio = originalSize.y / originalSize.x;
float maxAllowed = std::max(1.0f, windowSize.x - DISCORD_BANNER_PADDING_MARGIN);
float upperBound = std::min(DISCORD_BANNER_MAX_WIDTH, maxAllowed);
float lowerBound = std::min(DISCORD_BANNER_MIN_WIDTH, upperBound);
float targetWidth = std::clamp(ratioWidth, lowerBound, upperBound);

ImVec2 iconSize = ImVec2(targetWidth, targetWidth * aspectRatio);
ImGui::SetCursorPosX((windowSize.x - iconSize.x) * 0.5f);

// Push style to remove border
Expand Down
6 changes: 6 additions & 0 deletions src/Menu/HomePageRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class HomePageRenderer
static constexpr float QUICK_LINKS_BUTTON_WIDTH = 180.0f;
static constexpr float LOGO_WATERMARK_HEIGHT = 260.0f;

// Discord banner scaling constants
static constexpr float DISCORD_BANNER_TARGET_WIDTH_RATIO = 0.85f; // 25% of window width
static constexpr float DISCORD_BANNER_MIN_WIDTH = 150.0f;
static constexpr float DISCORD_BANNER_MAX_WIDTH = 1200.0f;
static constexpr float DISCORD_BANNER_PADDING_MARGIN = 40.0f;

static void RenderHomePage();

// First-time setup management
Expand Down