Skip to content

Commit

Permalink
Add virtual OnClientSize for EasyWindow backend and sub backend
Browse files Browse the repository at this point in the history
  • Loading branch information
thennequin committed Mar 17, 2018
1 parent ae76e53 commit f72f56a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
6 changes: 1 addition & 5 deletions ImWindowBGFX/ImwPlatformWindowBGFX.cpp
Expand Up @@ -129,15 +129,12 @@ bool ImwPlatformWindowBGFX::Init(ImwPlatformWindow* pMain)
return false;
}

void ImwPlatformWindowBGFX::OnSize(int iWidth, int iHeight)
void ImwPlatformWindowBGFX::OnClientSize(int iClientWidth, int iClientHeight)
{
bgfx::frame();
if (bgfx::isValid(m_hFrameBufferHandle))
bgfx::destroyFrameBuffer(m_hFrameBufferHandle);

int iClientWidth, iClientHeight;
m_pWindow->GetClientSize(&iClientWidth, &iClientHeight);

m_hFrameBufferHandle = bgfx::createFrameBuffer(m_pWindow->GetHandle(), uint16_t(iClientWidth), uint16_t(iClientHeight));

if (m_eType == E_PLATFORM_WINDOW_TYPE_MAIN)
Expand All @@ -147,7 +144,6 @@ void ImwPlatformWindowBGFX::OnSize(int iWidth, int iHeight)
}
}


#define IMGUI_FLAGS_NONE UINT8_C(0x00)
#define IMGUI_FLAGS_ALPHA_BLEND UINT8_C(0x01)

Expand Down
2 changes: 1 addition & 1 deletion ImWindowBGFX/ImwPlatformWindowBGFX.h
Expand Up @@ -23,7 +23,7 @@ namespace ImWindow

virtual void RenderDrawLists(ImDrawData* pDrawData);

void OnSize(int iWidth, int iHeight);
void OnClientSize(int iClientWidth, int iClientHeight);

bgfx::RendererType::Enum m_eRenderer;

Expand Down
7 changes: 3 additions & 4 deletions ImWindowDX11/ImwPlatformWindowDX11.cpp
Expand Up @@ -411,7 +411,7 @@ bool ImwPlatformWindowDX11::Init(ImwPlatformWindow* pMain)
}


void ImwPlatformWindowDX11::OnSize(int iWidth, int iHeight)
void ImwPlatformWindowDX11::OnClientSize(int iClientWidth, int iClientHeight)
{
if (NULL != m_pDXGISwapChain)
{
Expand All @@ -437,11 +437,10 @@ void ImwPlatformWindowDX11::OnSize(int iWidth, int iHeight)

m_pDX11DeviceContext->OMSetRenderTargets(1, &m_pDX11RenderTargetView, NULL);

ImVec2 oSize = GetSize();
// Set up the viewport.
D3D11_VIEWPORT oViewport;
oViewport.Width = oSize.x;
oViewport.Height = oSize.y;
oViewport.Width = (float)iClientWidth;
oViewport.Height = (float)iClientHeight;
oViewport.MinDepth = 0.0f;
oViewport.MaxDepth = 1.0f;
oViewport.TopLeftX = 0;
Expand Down
2 changes: 1 addition & 1 deletion ImWindowDX11/ImwPlatformWindowDX11.h
Expand Up @@ -32,7 +32,7 @@ namespace ImWindow
protected:
virtual void RenderDrawLists(ImDrawData* pDrawData);

virtual void OnSize(int iWidth, int iHeight);
virtual void OnClientSize(int iClientWidth, int iClientHeight);

IDXGISwapChain* m_pDXGISwapChain;
ID3D11RenderTargetView* m_pDX11RenderTargetView;
Expand Down
7 changes: 7 additions & 0 deletions ImWindowEasyWindow/ImwPlatformWindowEasyWindow.cpp
Expand Up @@ -170,6 +170,13 @@ bool ImwPlatformWindowEasyWindow::OnClose()
return true;
}

void ImwPlatformWindowEasyWindow::OnSize(int /*iWidth*/, int /*iHeight*/)
{
int iClientWidth, iClientHeight;
m_pWindow->GetClientSize(&iClientWidth, &iClientHeight);
OnClientSize(iClientWidth, iClientHeight);
}

void ImwPlatformWindowEasyWindow::OnFocus(bool bHasFocus)
{
if (!bHasFocus)
Expand Down
3 changes: 2 additions & 1 deletion ImWindowEasyWindow/ImwPlatformWindowEasyWindow.h
Expand Up @@ -33,9 +33,10 @@ namespace ImWindow
protected:
virtual void PreUpdate();
virtual void RenderDrawLists(ImDrawData* pDrawData) = 0;
virtual void OnClientSize(int iClientWidth, int iClientHeight) = 0;

virtual void OnSize(int iWidth, int iHeight) = 0;
bool OnClose();
void OnSize(int iWidth, int iHeight);
void OnFocus(bool bHasFocus);
void OnMouseButton(int iButton, bool bDown);
void OnMouseMove(int iX, int iY);
Expand Down
4 changes: 2 additions & 2 deletions ImWindowOGL/ImwPlatformWindowOGL.cpp
Expand Up @@ -149,12 +149,12 @@ bool ImwPlatformWindowOGL::Init(ImwPlatformWindow* pMain)
return false;
}

void ImwPlatformWindowOGL::OnSize(int iWidth, int iHeight)
void ImwPlatformWindowOGL::OnClientSize(int iClientWidth, int iClientHeight)
{
if (m_hDC != NULL && m_hRC != NULL)
{
wglMakeCurrent(m_hDC, m_hRC);
glViewport(0, 0, iWidth, iHeight);
glViewport(0, 0, iClientWidth, iClientHeight);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ImWindowOGL/ImwPlatformWindowOGL.h
Expand Up @@ -24,7 +24,7 @@ namespace ImWindow
protected:
virtual void RenderDrawLists(ImDrawData* pDrawData);

void OnSize(int iWidth, int iHeight);
void OnClientSize(int iClientWidth, int iClientHeight);

HDC m_hDC;
HGLRC m_hRC;
Expand Down

0 comments on commit f72f56a

Please sign in to comment.