mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-04 13:14:31 +00:00
ImGuiManager: Extract out gradient rect function
This commit is contained in:
@@ -1317,6 +1317,16 @@ void FullscreenUI::PopPrimaryColor()
|
||||
ImGui::PopStyleColor(5);
|
||||
}
|
||||
|
||||
void FullscreenUI::DrawRoundedGradientRect(ImDrawList* const dl, const ImVec2& pos_min, const ImVec2& pos_max,
|
||||
ImU32 col_left, ImU32 col_right, float rounding)
|
||||
{
|
||||
dl->AddRectFilled(pos_min, ImVec2(pos_min.x + rounding, pos_max.y), col_left, rounding, ImDrawFlags_RoundCornersLeft);
|
||||
dl->AddRectFilledMultiColor(ImVec2(pos_min.x + rounding, pos_min.y), ImVec2(pos_max.x - rounding, pos_max.y),
|
||||
col_left, col_right, col_right, col_left);
|
||||
dl->AddRectFilled(ImVec2(pos_max.x - rounding, pos_min.y), pos_max, col_right, rounding,
|
||||
ImDrawFlags_RoundCornersRight);
|
||||
}
|
||||
|
||||
bool FullscreenUI::BeginFullscreenColumns(const char* title, float pos_y, bool expand_to_screen_width, bool footer)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(expand_to_screen_width ? 0.0f : UIStyle.LayoutPaddingLeft, pos_y));
|
||||
|
||||
@@ -308,6 +308,9 @@ void CancelPendingMenuClose();
|
||||
void PushPrimaryColor();
|
||||
void PopPrimaryColor();
|
||||
|
||||
void DrawRoundedGradientRect(ImDrawList* const dl, const ImVec2& pos_min, const ImVec2& pos_max, ImU32 col_left,
|
||||
ImU32 col_right, float rounding);
|
||||
|
||||
void DrawWindowTitle(std::string_view title);
|
||||
|
||||
bool BeginFullscreenColumns(const char* title = nullptr, float pos_y = 0.0f, bool expand_to_screen_width = false,
|
||||
|
||||
@@ -958,6 +958,7 @@ void ImGuiManager::AcquirePendingOSDMessages(Timer::Value current_time)
|
||||
void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||
{
|
||||
using FullscreenUI::DarkerColor;
|
||||
using FullscreenUI::DrawRoundedGradientRect;
|
||||
using FullscreenUI::ModAlpha;
|
||||
using FullscreenUI::RenderShadowedTextClipped;
|
||||
using FullscreenUI::UIStyle;
|
||||
@@ -1105,19 +1106,13 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||
ImDrawList* const dl = ImGui::GetForegroundDrawList();
|
||||
|
||||
const float background_opacity = opacity * 0.95f;
|
||||
const u32 left_background_color32 = ImGui::GetColorU32(ModAlpha(left_background_color, background_opacity));
|
||||
const u32 right_background_color32 = ImGui::GetColorU32(
|
||||
ModAlpha(ImLerp(left_background_color, right_background_color,
|
||||
std::min((box_width - min_rounded_width) / (max_width_for_color - min_rounded_width), 1.0f)),
|
||||
background_opacity));
|
||||
|
||||
dl->AddRectFilled(pos, ImVec2(pos.x + rounding, pos_max.y), left_background_color32, rounding,
|
||||
ImDrawFlags_RoundCornersLeft);
|
||||
dl->AddRectFilledMultiColor(ImVec2(pos.x + rounding, pos.y), ImVec2(pos_max.x - rounding, pos_max.y),
|
||||
left_background_color32, right_background_color32, right_background_color32,
|
||||
left_background_color32);
|
||||
dl->AddRectFilled(ImVec2(pos_max.x - rounding, pos.y), pos_max, right_background_color32, rounding,
|
||||
ImDrawFlags_RoundCornersRight);
|
||||
DrawRoundedGradientRect(
|
||||
dl, pos, pos_max, ImGui::GetColorU32(ModAlpha(left_background_color, background_opacity)),
|
||||
ImGui::GetColorU32(
|
||||
ModAlpha(ImLerp(left_background_color, right_background_color,
|
||||
std::min((box_width - min_rounded_width) / (max_width_for_color - min_rounded_width), 1.0f)),
|
||||
background_opacity)),
|
||||
rounding);
|
||||
|
||||
const ImVec2 base_pos = ImVec2(pos.x + padding, pos.y + padding);
|
||||
const ImU32 color = ImGui::GetColorU32(ModAlpha(text_color, opacity));
|
||||
|
||||
Reference in New Issue
Block a user