@@ -63,7 +63,10 @@ void ShowMessageBox(std::string title, std::string body, MessageLevel level)
6363 */
6464void RenderMessageBoxes ()
6565{
66+ static bool isClosing = false ;
67+
6668 if (messageBoxQueue.size () <= 0 ) {
69+ isClosing = false ;
6770 return ;
6871 }
6972
@@ -81,15 +84,25 @@ void RenderMessageBoxes()
8184 static const float scrollFriction = 0 .95f ;
8285 static const float minVelocityThreshold = 0 .01f ;
8386
84- float opacityAnimation = EaseInOutFloat (" MessageAlertPopupAnimation" , 0 .f , 1 .f , true , 0 .3f );
87+ float opacityAnimation = EaseInOutFloat (" MessageAlertPopupAnimation" , 0 .f , 1 .f , !isClosing, 0 .3f );
88+
89+ // When fade-out animation completes, actually close the popup
90+ if (isClosing && opacityAnimation <= 0 .01f ) {
91+ CloseCurrentPopup ();
92+ messageBoxQueue.pop ();
93+ isClosing = false ;
94+ hasSkippedFirstFrame = false ;
95+ scrollPosition = 0 .0f ;
96+ scrollVelocity = 0 .0f ;
97+ }
8598
86- PushStyleColor (ImGuiCol_PopupBg, ImVec4 (0 .098f , 0 .102f , 0 .11f , 1 .0f ));
87- PushStyleColor (ImGuiCol_Border, ImVec4 (0 .48f , 0 .484f , 0 .492f , 0 .5f ));
99+ PushStyleColor (ImGuiCol_PopupBg, ImVec4 (0 .067f , 0 .071f , 0 .078f , 1 .0f ));
100+ PushStyleColor (ImGuiCol_Border, ImVec4 (0 .48f , 0 .484f , 0 .492f , 0 .3f ));
88101 PushStyleVar (ImGuiStyleVar_Alpha, opacityAnimation);
89102 PushStyleVar (ImGuiStyleVar_WindowRounding, ScaleX (10 .0f ));
90103 PushStyleVar (ImGuiStyleVar_WindowBorderSize, ScaleX (1 .0f ));
91104
92- SetNextWindowSizeConstraints (ImVec2 (ScaleX (500 ), 0 ), ImVec2 (ScaleX (700 ), FLT_MAX ));
105+ SetNextWindowSizeConstraints (ImVec2 (ScaleX (650 ), 0 ), ImVec2 (ScaleX (900 ), FLT_MAX ));
93106
94107 if (BeginPopupModal (" MessageAlertPopup" , nullptr ,
95108 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove |
@@ -120,9 +133,7 @@ void RenderMessageBoxes()
120133
121134 TextWrapped (currentBox.title .c_str ());
122135 PopFont ();
123- SetCursorPosY (GetCursorPosY () + ScaleY (15 ));
124- Separator ();
125- SetCursorPosY (GetCursorPosY () + ScaleY (20 ));
136+ SetCursorPosY (GetCursorPosY () + ScaleY (25 ));
126137
127138 TextWrapped (currentBox.body .c_str ());
128139
@@ -134,25 +145,28 @@ void RenderMessageBoxes()
134145
135146 SetScrollY (scrollPosition);
136147 if (hasSkippedFirstFrame && !ImGui::IsWindowHovered () && ImGui::IsMouseClicked (0 )) {
137- CloseCurrentPopup ();
138- messageBoxQueue.pop ();
148+ isClosing = true ;
139149 }
140150 hasSkippedFirstFrame = true ;
141151
142152 SetCursorPosY (GetCursorPosY () + ScaleY (40 ));
143153
144154 PushStyleColor (ImGuiCol_Button, ImVec4 (1 .f , 1 .f , 1 .f , 1 .f ));
145155 PushStyleColor (ImGuiCol_ButtonHovered, ImVec4 (1 .f , 1 .f , 1 .f , 1 .f ));
156+ PushStyleColor (ImGuiCol_ButtonActive, ImVec4 (0 .9f , 0 .9f , 0 .9f , 1 .f ));
146157 PushStyleColor (ImGuiCol_Text, ImVec4 (0 .f , 0 .f , 0 .f , 1 .f ));
147158
148159 SetCursorPosX (GetCursorPosX () + GetContentRegionAvail ().x - ScaleX (140 ));
149160
150161 if (Button (" Continue" , ImVec2 (ScaleX (140 ), ScaleY (50 )))) {
151- CloseCurrentPopup ();
152- messageBoxQueue.pop ();
162+ isClosing = true ;
163+ }
164+
165+ if (IsItemHovered ()) {
166+ SetMouseCursor (ImGuiMouseCursor_Hand);
153167 }
154168
155- PopStyleColor (3 );
169+ PopStyleColor (4 );
156170 EndPopup ();
157171 }
158172
0 commit comments