Update release

This commit is contained in:
Zihan Chen
2018-07-10 00:04:57 -07:00
parent 167547854c
commit 4ac5de559b
5 changed files with 120 additions and 76 deletions
+41 -12
View File
@@ -6411,7 +6411,7 @@ GuiControlHost
control=control->GetParent();
}
}
return 0;
return nullptr;
}
void GuiControlHost::MoveIntoTooltipControl(GuiControl* tooltipControl, Point location)
@@ -6547,7 +6547,15 @@ GuiControlHost
void GuiControlHost::Destroying()
{
WindowDestroying.Execute(GetNotifyEventArguments());
SetNativeWindow(0);
calledDestroyed = true;
if (deleteWhenDestroyed)
{
GetApplication()->InvokeInMainThread(this, [=]()
{
delete this;
});
}
SetNativeWindow(nullptr);
}
void GuiControlHost::UpdateClientSizeAfterRendering(Size clientSize)
@@ -6580,6 +6588,20 @@ GuiControlHost
delete host;
}
void GuiControlHost::DeleteAfterProcessingAllEvents()
{
auto window = host->GetNativeWindow();
if (calledDestroyed || !window)
{
delete this;
}
else
{
deleteWhenDestroyed = true;
GetCurrentController()->WindowService()->DestroyNativeWindow(window);
}
}
compositions::GuiGraphicsHost* GuiControlHost::GetGraphicsHost()
{
return host;
@@ -6902,17 +6924,17 @@ GuiControlHost
void GuiControlHost::Close()
{
INativeWindow* window=host->GetNativeWindow();
if(window)
if (auto window = host->GetNativeWindow())
{
if(GetCurrentController()->WindowService()->GetMainWindow()!=window)
auto mainWindow = GetCurrentController()->WindowService()->GetMainWindow();
if (mainWindow == window)
{
window->Hide(false);
SetNativeWindow(nullptr);
GetCurrentController()->WindowService()->DestroyNativeWindow(window);
}
else
{
SetNativeWindow(0);
GetCurrentController()->WindowService()->DestroyNativeWindow(window);
window->Hide(false);
}
}
}
@@ -7054,7 +7076,7 @@ GuiWindow
INativeWindow* window=host->GetNativeWindow();
if(window)
{
SetNativeWindow(0);
SetNativeWindow(nullptr);
GetCurrentController()->WindowService()->DestroyNativeWindow(window);
}
}
@@ -7153,7 +7175,7 @@ GuiWindow
ShowModal(owner, [=]()
{
callback();
delete this;
DeleteAfterProcessingAllEvents();
});
}
@@ -8599,8 +8621,15 @@ Helper Functions
void SafeDeleteControl(controls::GuiControl* value)
{
NotifyFinalizeInstance(value);
SafeDeleteControlInternal(value);
if (auto controlHost = dynamic_cast<controls::GuiControlHost*>(value))
{
controlHost->DeleteAfterProcessingAllEvents();
}
else
{
NotifyFinalizeInstance(value);
SafeDeleteControlInternal(value);
}
}
void SafeDeleteComposition(GuiGraphicsComposition* value)
+14 -8
View File
@@ -2218,28 +2218,28 @@ Native Window Services
/// Create a window.
/// </summary>
/// <returns>The created window.</returns>
virtual INativeWindow* CreateNativeWindow()=0;
virtual INativeWindow* CreateNativeWindow() = 0;
/// <summary>
/// Destroy a window.
/// </summary>
/// <param name="window">The window to destroy.</param>
virtual void DestroyNativeWindow(INativeWindow* window)=0;
virtual void DestroyNativeWindow(INativeWindow* window) = 0;
/// <summary>
/// Get the main window.
/// </summary>
/// <returns>The main window.</returns>
virtual INativeWindow* GetMainWindow()=0;
virtual INativeWindow* GetMainWindow() = 0;
/// <summary>
/// Get the window that under a specified position in screen space.
/// </summary>
/// <returns>The window that under a specified position in screen space.</returns>
/// <param name="location">The specified position in screen space.</param>
virtual INativeWindow* GetWindow(Point location)=0;
virtual INativeWindow* GetWindow(Point location) = 0;
/// <summary>
/// Make the specified window a main window, show that window, and wait until the windows is closed.
/// </summary>
/// <param name="window">The specified window.</param>
virtual void Run(INativeWindow* window)=0;
virtual void Run(INativeWindow* window) = 0;
};
/// <summary>
@@ -11002,14 +11002,17 @@ Control Host
virtual void OnNativeWindowChanged();
virtual void OnVisualStatusChanged();
protected:
static const vint TooltipDelayOpenTime=500;
static const vint TooltipDelayCloseTime=500;
static const vint TooltipDelayLifeTime=5000;
static const vint TooltipDelayOpenTime = 500;
static const vint TooltipDelayCloseTime = 500;
static const vint TooltipDelayLifeTime = 5000;
Ptr<INativeDelay> tooltipOpenDelay;
Ptr<INativeDelay> tooltipCloseDelay;
Point tooltipLocation;
bool calledDestroyed = false;
bool deleteWhenDestroyed = false;
controls::GuiControlHost* GetControlHostForInstance()override;
GuiControl* GetTooltipOwner(Point location);
void MoveIntoTooltipControl(GuiControl* tooltipControl, Point location);
@@ -11051,6 +11054,9 @@ Control Host
/// <summary>Window destroying event.</summary>
compositions::GuiNotifyEvent WindowDestroying;
/// <summary>Delete this control host after processing all events.</summary>
void DeleteAfterProcessingAllEvents();
/// <summary>Get the internal <see cref="compositions::GuiGraphicsHost"/> object to host the window content.</summary>
/// <returns>The internal <see cref="compositions::GuiGraphicsHost"/> object to host the window content.</returns>
compositions::GuiGraphicsHost* GetGraphicsHost();
+1
View File
@@ -2166,6 +2166,7 @@ Type Declaration (Class)
CLASS_MEMBER_PROPERTY_FAST(ShortcutKeyManager)
CLASS_MEMBER_PROPERTY_READONLY_FAST(RelatedScreen)
CLASS_MEMBER_METHOD(DeleteAfterProcessingAllEvents, NO_PARAMETER)
CLASS_MEMBER_METHOD(ForceCalculateSizeImmediately, NO_PARAMETER)
CLASS_MEMBER_METHOD(GetFocused, NO_PARAMETER)
CLASS_MEMBER_METHOD(SetFocused, NO_PARAMETER)
+63 -55
View File
@@ -13301,30 +13301,22 @@ WindowsForm
protected:
HWND handle;
WString title;
WindowsCursor* cursor;
WindowsCursor* cursor = nullptr;
Point caretPoint;
WindowsForm* parentWindow;
bool alwaysPassFocusToParent;
WindowsForm* parentWindow = nullptr;
bool alwaysPassFocusToParent = false;
List<INativeWindowListener*> listeners;
vint mouseLastX;
vint mouseLastY;
vint mouseHoving;
Interface* graphicsHandler;
bool customFrameMode;
vint mouseLastX = -1;
vint mouseLastY = -1;
bool mouseHoving = false;
Interface* graphicsHandler = nullptr;
bool customFrameMode = false;
List<Ptr<INativeMessageHandler>> messageHandlers;
bool supressingAlt;
bool supressingAlt = false;
Ptr<bool> flagDisposed = new bool(false);
public:
WindowsForm(HWND parent, WString className, HINSTANCE hInstance)
:cursor(0)
,parentWindow(0)
,alwaysPassFocusToParent(false)
,mouseLastX(-1)
,mouseLastY(-1)
,mouseHoving(false)
,graphicsHandler(0)
,customFrameMode(false)
,supressingAlt(false)
{
DWORD exStyle = WS_EX_APPWINDOW | WS_EX_CONTROLPARENT;
DWORD style = WS_BORDER | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
@@ -13333,12 +13325,13 @@ WindowsForm
~WindowsForm()
{
*flagDisposed.Obj() = true;
List<INativeWindowListener*> copiedListeners;
CopyFrom(copiedListeners, listeners);
for(vint i=0;i<copiedListeners.Count();i++)
for (vint i = 0; i < copiedListeners.Count(); i++)
{
INativeWindowListener* listener=copiedListeners[i];
if(listeners.Contains(listener))
INativeWindowListener* listener = copiedListeners[i];
if (listeners.Contains(listener))
{
listener->Destroyed();
}
@@ -13356,11 +13349,14 @@ WindowsForm
bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result)
{
#define CHECK_DISPOSED if (*flag.Obj()) return skip
auto flag = flagDisposed;
bool skip = false;
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
{
handler->BeforeHandle(hwnd, uMsg, wParam, lParam, skip);
CHECK_DISPOSED;
}
if (skip)
{
@@ -13368,14 +13364,17 @@ WindowsForm
}
}
skip = HandleMessageInternal(hwnd, uMsg, wParam, lParam, result);
CHECK_DISPOSED;
if (GetWindowsFormFromHandle(hwnd))
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
{
handler->AfterHandle(hwnd, uMsg, wParam, lParam, skip, result);
CHECK_DISPOSED;
}
}
return skip;
#undef CHECK_DISPOSED
}
HWND GetWindowHandle()override
@@ -13824,6 +13823,7 @@ WindowsController
Dictionary<HWND, WindowsForm*> windows;
INativeWindow* mainWindow;
HWND mainWindowHandle;
vint handleMessageLevelCounter = 0;
WindowsCallbackService callbackService;
WindowsResourceService resourceService;
@@ -13868,51 +13868,59 @@ WindowsController
bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result)
{
bool skipDefaultProcedure=false;
vint index=windows.Keys().IndexOf(hwnd);
if(index!=-1)
handleMessageLevelCounter++;
{
WindowsForm* window=windows.Values().Get(index);
skipDefaultProcedure=window->HandleMessage(hwnd, uMsg, wParam, lParam, result);
switch(uMsg)
vint index = windows.Keys().IndexOf(hwnd);
if (index != -1)
{
case WM_CLOSE:
if(!skipDefaultProcedure)
WindowsForm* window = windows.Values().Get(index);
skipDefaultProcedure = window->HandleMessage(hwnd, uMsg, wParam, lParam, result);
switch (uMsg)
{
ShowWindow(window->GetWindowHandle(), SW_HIDE);
if(window!=mainWindow)
case WM_CLOSE:
if (!skipDefaultProcedure)
{
skipDefaultProcedure=true;
ShowWindow(window->GetWindowHandle(), SW_HIDE);
if (window != mainWindow)
{
skipDefaultProcedure = true;
}
}
break;
case WM_DESTROY:
DestroyNativeWindow(window);
break;
}
}
}
{
if (hwnd == mainWindowHandle && uMsg == WM_DESTROY)
{
for (vint i = 0; i < windows.Count(); i++)
{
if (windows.Values().Get(i)->IsVisible())
{
windows.Values().Get(i)->Hide(true);
}
}
break;
case WM_DESTROY:
DestroyNativeWindow(window);
break;
}
}
if(hwnd==mainWindowHandle && uMsg==WM_DESTROY)
{
for(vint i=0;i<windows.Count();i++)
{
if(windows.Values().Get(i)->IsVisible())
while (windows.Count())
{
windows.Values().Get(i)->Hide(true);
DestroyNativeWindow(windows.Values().Get(0));
}
PostQuitMessage(0);
}
while(windows.Count())
{
DestroyNativeWindow(windows.Values().Get(0));
}
PostQuitMessage(0);
}
asyncService.ExecuteAsyncTasks();
handleMessageLevelCounter--;
if (handleMessageLevelCounter == 0)
{
asyncService.ExecuteAsyncTasks();
}
return skipDefaultProcedure;
}
//=======================================================================
INativeWindow* CreateNativeWindow()
INativeWindow* CreateNativeWindow()override
{
WindowsForm* window=new WindowsForm(godWindow, windowClass.GetName(), hInstance);
windows.Add(window->GetWindowHandle(), window);
@@ -13921,7 +13929,7 @@ WindowsController
return window;
}
void DestroyNativeWindow(INativeWindow* window)
void DestroyNativeWindow(INativeWindow* window)override
{
WindowsForm* windowsForm=dynamic_cast<WindowsForm*>(window);
windowsForm->InvokeDestroying();
@@ -13933,12 +13941,12 @@ WindowsController
}
}
INativeWindow* GetMainWindow()
INativeWindow* GetMainWindow()override
{
return mainWindow;
}
void Run(INativeWindow* window)
void Run(INativeWindow* window)override
{
mainWindow=window;
mainWindowHandle=GetWindowsForm(window)->GetWindowHandle();
@@ -13952,7 +13960,7 @@ WindowsController
}
}
INativeWindow* GetWindow(Point location)
INativeWindow* GetWindow(Point location)override
{
POINT p;
p.x=(int)location.x;
@@ -305,7 +305,7 @@
<![CDATA[
prop FolderName : string = "" {}
var Ready : bool = true;
var Ready : bool = false;
]]>
</ref.Members>
<Window ref.Name="self" Text="New Folder" ClientSize="x:240 y:120" MaximizedBox="false" MinimizedBox="false" SizeBox="false">