@ -30,8 +30,8 @@ WindowBaseImpl::WindowBaseImpl(IAvnWindowBaseEvents *events, IAvnGlContext *gl)
View = [[AvnView alloc] initWithParent:this];
StandardContainer = [[AutoFitContentView new] initWithContent:View];
lastPositionSet.X = 100 ;
lastPositionSet.Y = 100 ;
lastPositionSet.X = - 1;
lastPositionSet.Y = - 1;
lastSize = NSSize { 100, 100 };
lastMaxSize = NSSize { CGFLOAT_MAX, CGFLOAT_MAX};
lastMinSize = NSSize { 0, 0 };
@ -92,7 +92,11 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) {
CreateNSWindow(isDialog);
InitialiseNSWindow();
SetPosition(lastPositionSet);
if(lastPositionSet.X >= 0 && lastPositionSet.Y >= 0)
{
SetPosition(lastPositionSet);
}
UpdateStyle();
[Window setTitle:_lastTitle];
@ -112,6 +116,11 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) {
}
}
bool WindowBaseImpl::IsShown ()
{
return _shown;
}
bool WindowBaseImpl::ShouldTakeFocusOnShow() {
return true;
}
@ -191,9 +200,8 @@ HRESULT WindowBaseImpl::GetClientSize(AvnSize *ret) {
if (ret == nullptr)
return E_POINTER;
auto frame = [View frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
ret->Width = lastSize.width;
ret->Height = lastSize.height;
return S_OK;
}
@ -206,9 +214,11 @@ HRESULT WindowBaseImpl::GetFrameSize(AvnSize *ret) {
if (ret == nullptr)
return E_POINTER;
auto frame = [Window frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
if(Window != nullptr){
auto frame = [Window frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
}
return S_OK;
}
@ -354,12 +364,17 @@ HRESULT WindowBaseImpl::GetPosition(AvnPoint *ret) {
return E_POINTER;
}
auto frame = [Window frame];
if(Window != nullptr) {
auto frame = [Window frame];
ret->X = frame.origin.x;
ret->Y = frame.origin.y + frame.size.height;
ret->X = frame.origin.x;
ret->Y = frame.origin.y + frame.size.height;
*ret = ConvertPointY(*ret);
*ret = ConvertPointY(*ret);
} else
{
*ret = lastPositionSet;
}
return S_OK;
}
@ -370,7 +385,10 @@ HRESULT WindowBaseImpl::SetPosition(AvnPoint point) {
@autoreleasepool {
lastPositionSet = point;
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(point))];
if(Window != nullptr) {
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(point))];
}
return S_OK;
}
@ -559,6 +577,7 @@ void WindowBaseImpl::InitialiseNSWindow() {
[Window setContentMaxSize:lastMaxSize];
[Window setOpaque:false];
[Window center];
if (lastMenu != nullptr) {
[GetWindowProtocol() applyMenu:lastMenu];
@ -576,7 +595,7 @@ id <AvnWindowProtocol> WindowBaseImpl::GetWindowProtocol() {
return nullptr;
}
return static_cast<id <AvnWindowProtocol>>(Window) ;
return (id <AvnWindowProtocol>) Window ;
}
extern IAvnWindow* CreateAvnWindow(IAvnWindowEvents*events, IAvnGlContext* gl)