From 8fc6a8e4737407a52a4f5325a4ad0d3723c1ad4a Mon Sep 17 00:00:00 2001
From: RD42 <42702181+dashr9230@users.noreply.github.com>
Date: Fri, 24 May 2024 22:46:03 +0800
Subject: [PATCH] [saco] Implement `CDXUTDialog::Refresh()`

---
 saco/d3d9/common/DXUTgui.cpp | 21 +++++++++++++++++++++
 saco/d3d9/common/DXUTgui.h   |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/saco/d3d9/common/DXUTgui.cpp b/saco/d3d9/common/DXUTgui.cpp
index a910d0b..9b892fa 100644
--- a/saco/d3d9/common/DXUTgui.cpp
+++ b/saco/d3d9/common/DXUTgui.cpp
@@ -179,7 +179,28 @@ void CDXUTDialogResourceManager::OnDestroyDevice()
 }
 
 
+//--------------------------------------------------------------------------------------
+void CDXUTDialog::Refresh()
+{
+    if( s_pControlFocus )
+        s_pControlFocus->OnFocusOut();
 
+    if( m_pControlMouseOver )
+        m_pControlMouseOver->OnMouseLeave();
+
+    s_pControlFocus = NULL;
+    s_pControlPressed = NULL;
+    m_pControlMouseOver = NULL;
+
+    for( int i=0; i < m_Controls.GetSize(); i++ )
+    {
+        CDXUTControl* pControl = m_Controls.GetAt(i);
+        pControl->Refresh();
+    }
+
+    if( m_bKeyboardInput )
+        FocusDefaultControl();
+}
 
 
 //--------------------------------------------------------------------------------------
diff --git a/saco/d3d9/common/DXUTgui.h b/saco/d3d9/common/DXUTgui.h
index 71659cd..f19e879 100644
--- a/saco/d3d9/common/DXUTgui.h
+++ b/saco/d3d9/common/DXUTgui.h
@@ -96,6 +96,9 @@ public:
     // Sets the callback used to notify the app of control events
     void SetCallback( PCALLBACKDXUTGUIEVENT pCallback, void* pUserContext = NULL );
 
+    // Device state notification
+    void Refresh();
+
 
     bool m_bNonUserEvents;
     bool m_bKeyboardInput;