Skip to content

Commit 27fc7de

Browse files
committed
FullscreenUI: Add translucency/shadow to achievement notifications
1 parent a1e5bb7 commit 27fc7de

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

src/util/imgui_fullscreen.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,7 +3400,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
34003400

34013401
const ImVec2 box_min(position.x, actual_y);
34023402
const ImVec2 box_max(box_min.x + box_width, box_min.y + box_height);
3403-
const u32 background_color = ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, opacity));
3403+
const u32 background_color = ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, opacity * 0.95f));
34043404

34053405
ImDrawList* dl = ImGui::GetForegroundDrawList();
34063406
dl->AddRectFilled(box_min, box_max, background_color, rounding, ImDrawFlags_RoundCornersAll);
@@ -3421,17 +3421,20 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
34213421
}
34223422
}
34233423

3424-
const u32 text_col = ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity));
3424+
const u32 title_col = ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity));
3425+
const u32 text_col = ImGui::GetColorU32(ModAlpha(DarkerColor(UIStyle.ToastTextColor), opacity));
34253426

3426-
const ImVec2 title_min(badge_max.x + horizontal_spacing, box_min.y + vertical_padding);
3427-
const ImVec2 title_max(title_min.x + title_size.x, title_min.y + title_size.y);
3428-
dl->AddText(title_font, title_font->FontSize, title_min, text_col, notif.title.c_str(),
3429-
notif.title.c_str() + notif.title.size(), max_text_width);
3427+
const ImVec2 title_pos = ImVec2(badge_max.x + horizontal_spacing, box_min.y + vertical_padding);
3428+
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
3429+
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, title_col, notif.title.c_str(),
3430+
notif.title.c_str() + notif.title.size(), &title_size, ImVec2(0.0f, 0.0f), max_text_width,
3431+
&title_bb);
34303432

3431-
const ImVec2 text_min(badge_max.x + horizontal_spacing, title_max.y + vertical_spacing);
3432-
const ImVec2 text_max(text_min.x + text_size.x, text_min.y + text_size.y);
3433-
dl->AddText(text_font, text_font->FontSize, text_min, text_col, notif.text.c_str(),
3434-
notif.text.c_str() + notif.text.size(), max_text_width);
3433+
const ImVec2 text_pos = ImVec2(badge_max.x + horizontal_spacing, title_bb.Max.y + vertical_spacing);
3434+
const ImRect text_bb = ImRect(text_pos, text_pos + text_size);
3435+
RenderShadowedTextClipped(dl, text_font, text_bb.Min, text_bb.Max, text_col, notif.text.c_str(),
3436+
notif.text.c_str() + notif.text.size(), &text_size, ImVec2(0.0f, 0.0f), max_text_width,
3437+
&text_bb);
34353438

34363439
if (clip_box)
34373440
dl->PopClipRect();
@@ -3498,24 +3501,28 @@ void ImGuiFullscreen::DrawToast()
34983501
const ImVec2 box_pos((display_size.x - box_size.x) * 0.5f, (display_size.y - margin - box_size.y));
34993502

35003503
ImDrawList* dl = ImGui::GetForegroundDrawList();
3501-
dl->AddRectFilled(box_pos, box_pos + box_size, ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, alpha)),
3502-
padding);
3504+
dl->AddRectFilled(box_pos, box_pos + box_size,
3505+
ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, alpha * 0.95f)), padding);
35033506

35043507
const u32 text_col = ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, alpha));
35053508

35063509
if (!s_state.toast_title.empty())
35073510
{
35083511
const float offset = (comb_size.x - title_size.x) * 0.5f;
3509-
dl->AddText(title_font, title_font->FontSize, box_pos + ImVec2(offset + padding, padding), text_col,
3510-
s_state.toast_title.c_str(), s_state.toast_title.c_str() + s_state.toast_title.length(), max_width);
3512+
const ImVec2 title_pos = box_pos + ImVec2(offset + padding, padding);
3513+
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
3514+
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, text_col, s_state.toast_title.c_str(),
3515+
s_state.toast_title.c_str() + s_state.toast_title.length(), &title_size,
3516+
ImVec2(0.0f, 0.0f), max_width, &title_bb);
35113517
}
35123518
if (!s_state.toast_message.empty())
35133519
{
35143520
const float offset = (comb_size.x - message_size.x) * 0.5f;
3515-
dl->AddText(message_font, message_font->FontSize,
3516-
box_pos + ImVec2(offset + padding, padding + spacing + title_size.y), text_col,
3517-
s_state.toast_message.c_str(), s_state.toast_message.c_str() + s_state.toast_message.length(),
3518-
max_width);
3521+
const ImVec2 message_pos = box_pos + ImVec2(offset + padding, padding + spacing + title_size.y);
3522+
const ImRect message_bb = ImRect(message_pos, message_pos + message_size);
3523+
RenderShadowedTextClipped(dl, message_font, message_bb.Min, message_bb.Max, text_col, s_state.toast_message.c_str(),
3524+
s_state.toast_message.c_str() + s_state.toast_message.length(), &message_size,
3525+
ImVec2(0.0f, 0.0f), max_width, &message_bb);
35193526
}
35203527
}
35213528

0 commit comments

Comments
 (0)