@@ -1027,30 +1027,29 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
10271027 const ImVec2 text_size = msg.text .empty () ? ImVec2 () :
10281028 font->CalcTextSizeA (font_size, text_font_weight, max_text_width,
10291029 max_text_width, IMSTR_START_END (msg.text ));
1030- float box_width = icon_size_with_margin + std::max (text_size.x , title_size.x ) + padding + padding;
1030+ const float box_width = icon_size_with_margin + std::max (text_size.x , title_size.x ) + padding + padding;
10311031 const float box_height = std::max (icon_size.y , title_size.y + text_size.y ) + padding + padding;
10321032
10331033 float opacity;
1034- bool clip_box = false ;
1034+ float actual_x ;
10351035 if (time_passed < OSD_FADE_IN_TIME)
10361036 {
10371037 const float pct = time_passed / OSD_FADE_IN_TIME;
10381038 const float eased_pct = std::clamp (Easing::OutExpo (pct), 0 .0f , 1 .0f );
1039- box_width = box_width * eased_pct;
1039+ actual_x = ImFloor (position_x - ( box_width * 0 . 2f * ( 1 . 0f - eased_pct))) ;
10401040 opacity = pct;
1041- clip_box = true ;
10421041 }
10431042 else if (time_passed > (msg.duration - OSD_FADE_OUT_TIME))
10441043 {
10451044 const float pct = (msg.duration - time_passed) / OSD_FADE_OUT_TIME;
10461045 const float eased_pct = std::clamp (Easing::InExpo (pct), 0 .0f , 1 .0f );
1047- box_width = box_width * eased_pct;
1046+ actual_x = ImFloor (position_x - ( box_width * 0 . 2f * ( 1 . 0f - eased_pct))) ;
10481047 opacity = eased_pct;
1049- clip_box = true ;
10501048 }
10511049 else
10521050 {
10531051 opacity = 1 .0f ;
1052+ actual_x = position_x;
10541053 }
10551054
10561055 const float expected_y = position_y;
@@ -1093,14 +1092,11 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
10931092 if (actual_y >= ImGui::GetIO ().DisplaySize .y || (msg.type >= OSDMessageType::Info && !show_messages))
10941093 break ;
10951094
1096- const ImVec2 pos = ImVec2 (position_x , actual_y);
1095+ const ImVec2 pos = ImVec2 (actual_x , actual_y);
10971096 const ImVec2 pos_max = ImVec2 (pos.x + box_width, pos.y + box_height);
10981097
10991098 ImDrawList* const dl = ImGui::GetForegroundDrawList ();
11001099
1101- if (clip_box)
1102- dl->PushClipRect (pos, pos_max);
1103-
11041100 dl->AddRectFilled (pos, pos_max, ImGui::GetColorU32 (ModAlpha (UIStyle.ToastBackgroundColor , opacity * 0 .95f )),
11051101 rounding);
11061102
@@ -1135,9 +1131,6 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
11351131 msg.text , &text_size, ImVec2 (0 .0f , 0 .0f ), max_text_width, &text_rect, scale);
11361132 }
11371133
1138- if (clip_box)
1139- dl->PopClipRect ();
1140-
11411134 position_y += box_height + spacing;
11421135 }
11431136
0 commit comments