Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Externals/imgui
Submodule imgui updated 257 files
32 changes: 16 additions & 16 deletions ImWindow/ImwContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ namespace ImWindow
{
float iFirstHeight = oSize.y * m_fSplitRatio - iSeparatorSize - pWindow->WindowPadding.x;

ImVec4 oBackupColor = oStyle.Colors[ImGuiCol_ChildWindowBg];
ImVec4 oBackupColor = oStyle.Colors[ImGuiCol_ChildBg];

oStyle.Colors[ImGuiCol_ChildWindowBg].w = 0.f;
oStyle.Colors[ImGuiCol_ChildBg].w = 0.f;
ImGui::BeginChild("Top", ImVec2(0, iFirstHeight), false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
oStyle.Colors[ImGuiCol_ChildWindowBg] = oBackupColor;
oStyle.Colors[ImGuiCol_ChildBg] = oBackupColor;
m_pSplits[0]->Paint(/*iX, iY, iWidth, iFirstHeight*/);
ImGui::EndChild();

Expand Down Expand Up @@ -501,21 +501,21 @@ namespace ImWindow

ImGui::SetCursorPosY(ImGui::GetCursorPosY() - oStyle.ItemSpacing.y);

oStyle.Colors[ImGuiCol_ChildWindowBg].w = 0.f;
oStyle.Colors[ImGuiCol_ChildBg].w = 0.f;
ImGui::BeginChild("Bottom", ImVec2(0, 0), false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
oStyle.Colors[ImGuiCol_ChildWindowBg] = oBackupColor;
oStyle.Colors[ImGuiCol_ChildBg] = oBackupColor;
m_pSplits[1]->Paint(/*iX, iY + iFirstHeight, iWidth, iSecondHeight*/);
ImGui::EndChild();
}
else
{
float iFirstWidth = oSize.x * m_fSplitRatio - iSeparatorSize - pWindow->WindowPadding.y;

ImVec4 oBackupColor = oStyle.Colors[ImGuiCol_ChildWindowBg];
ImVec4 oBackupColor = oStyle.Colors[ImGuiCol_ChildBg];

oStyle.Colors[ImGuiCol_ChildWindowBg].w = 0.f;
oStyle.Colors[ImGuiCol_ChildBg].w = 0.f;
ImGui::BeginChild("Left", ImVec2(iFirstWidth, 0), false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
oStyle.Colors[ImGuiCol_ChildWindowBg] = oBackupColor;
oStyle.Colors[ImGuiCol_ChildBg] = oBackupColor;
m_pSplits[0]->Paint();
ImGui::EndChild();

Expand Down Expand Up @@ -548,9 +548,9 @@ namespace ImWindow

ImGui::SameLine(0.f, 0.f);

oStyle.Colors[ImGuiCol_ChildWindowBg].w = 0.f;
oStyle.Colors[ImGuiCol_ChildBg].w = 0.f;
ImGui::BeginChild("Right", ImVec2(0, 0), false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
oStyle.Colors[ImGuiCol_ChildWindowBg] = oBackupColor;
oStyle.Colors[ImGuiCol_ChildBg] = oBackupColor;
m_pSplits[1]->Paint();
ImGui::EndChild();
}
Expand Down Expand Up @@ -697,7 +697,7 @@ namespace ImWindow

if (ImGui::IsItemActive())
{
if (ImGui::IsMouseDragging())
if (ImGui::IsMouseDragging( ImGuiMouseButton_Left ))
{
float fOffsetX = (oCursorPos.x - ImGui::GetItemRectMin().x) + (oFirstTabPos.x - oPos.x);
float fOffsetY = (oCursorPos.y - ImGui::GetItemRectMin().y);
Expand Down Expand Up @@ -918,12 +918,12 @@ namespace ImWindow
break;
case ImwWindowManager::E_TABCOLORMODE_BACKGROUND:
oNormalTab = ImColor(
oStyle.Colors[ImGuiCol_WindowBg].x + (oStyle.Colors[ImGuiCol_ChildWindowBg].x - oStyle.Colors[ImGuiCol_WindowBg].x) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].y + (oStyle.Colors[ImGuiCol_ChildWindowBg].y - oStyle.Colors[ImGuiCol_WindowBg].y) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].z + (oStyle.Colors[ImGuiCol_ChildWindowBg].z - oStyle.Colors[ImGuiCol_WindowBg].z) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].w + (oStyle.Colors[ImGuiCol_ChildWindowBg].w - oStyle.Colors[ImGuiCol_WindowBg].w) * 0.5f
oStyle.Colors[ImGuiCol_WindowBg].x + (oStyle.Colors[ImGuiCol_ChildBg].x - oStyle.Colors[ImGuiCol_WindowBg].x) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].y + (oStyle.Colors[ImGuiCol_ChildBg].y - oStyle.Colors[ImGuiCol_WindowBg].y) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].z + (oStyle.Colors[ImGuiCol_ChildBg].z - oStyle.Colors[ImGuiCol_WindowBg].z) * 0.5f,
oStyle.Colors[ImGuiCol_WindowBg].w + (oStyle.Colors[ImGuiCol_ChildBg].w - oStyle.Colors[ImGuiCol_WindowBg].w) * 0.5f
);
oSelectedTab = oStyle.Colors[ImGuiCol_ChildWindowBg];
oSelectedTab = oStyle.Colors[ImGuiCol_ChildBg];
oBorderColor = oStyle.Colors[ImGuiCol_Border];
break;
case ImwWindowManager::E_TABCOLORMODE_CUSTOM:
Expand Down
15 changes: 9 additions & 6 deletions ImWindow/ImwPlatformWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ namespace ImWindow
ImGuiContext* pGlobalContext = ImGui::GetCurrentContext();
IM_ASSERT(pGlobalContext != NULL);

m_pContext = ImGui::CreateContext( pGlobalContext->IO.MemAllocFn, pGlobalContext->IO.MemFreeFn );

m_pContext = ImGui::CreateContext( pGlobalContext->IO.Fonts );
ImGuiIO& oGlobalIO = pGlobalContext->IO;
ImGuiIO& oNewIO = m_pContext->IO;

memcpy(&(oNewIO.KeyMap), &(oGlobalIO.KeyMap ), sizeof( pGlobalContext->IO.KeyMap ));
oNewIO.RenderDrawListsFn = NULL;
oNewIO.ClipboardUserData = oGlobalIO.ClipboardUserData;
oNewIO.GetClipboardTextFn = oGlobalIO.GetClipboardTextFn;
oNewIO.SetClipboardTextFn = oGlobalIO.SetClipboardTextFn;
Expand All @@ -45,6 +43,11 @@ namespace ImWindow
return true;
}

void ImwPlatformWindow::RegenFontTexture( ImwPlatformWindow* /*pMain*/ )
{

}

EPlatformWindowType ImwPlatformWindow::GetType() const
{
return m_eType;
Expand Down Expand Up @@ -142,9 +145,8 @@ namespace ImWindow

if (m_pContext != NULL)
{
m_pContext->IO.Fonts = NULL;
SetContext(false);
ImGui::Shutdown();
ImGui::Shutdown( m_pContext );
RestoreContext(false);
ImGui::DestroyContext(m_pContext);
m_pContext = NULL;
Expand All @@ -167,7 +169,8 @@ namespace ImWindow

if (NULL != m_pContext)
{
m_pContext->SetNextWindowPosCond = m_pContext->SetNextWindowSizeCond = m_pContext->SetNextWindowContentSizeCond = m_pContext->SetNextWindowCollapsedCond = m_pContext->SetNextWindowFocus = 0;
m_pContext->NextWindowData.PosCond = m_pContext->NextWindowData.SizeCond = m_pContext->NextWindowData.CollapsedCond = 0;
m_pContext->NextWindowData.Flags = m_pContext->NextWindowData.Flags & ~( ImGuiNextWindowDataFlags_HasFocus | ImGuiNextWindowDataFlags_HasContentSize );
m_pContext->ActiveId = 0;

for (int i = 0; i < 512; ++i)
Expand Down
1 change: 1 addition & 0 deletions ImWindow/ImwPlatformWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace ImWindow
virtual ~ImwPlatformWindow();

virtual bool Init(ImwPlatformWindow* pParent);
virtual void RegenFontTexture(ImwPlatformWindow* pMain);

EPlatformWindowType GetType() const;
bool IsMainWindow() const;
Expand Down
2 changes: 1 addition & 1 deletion ImWindow/ImwWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ImWindow
{
//SFF_BEGIN
int ImwWindow::s_iNextId = 0;
int ImwWindow::s_iNextId = 1;

#ifdef IMW_CUSTOM_IMPLEMENT_IMWWINDOW
IMW_CUSTOM_IMPLEMENT_IMWWINDOW
Expand Down
41 changes: 30 additions & 11 deletions ImWindow/ImwWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ namespace ImWindow

bool ImwWindowManager::Init()
{
ImGuiContext* pContext = ImGui::CreateContext();
ImGui::SetCurrentContext(pContext);

InternalInit();

ImGuiIO& io = ImGui::GetIO();
Expand Down Expand Up @@ -182,6 +185,12 @@ namespace ImWindow
}

InternalDestroy();
ImGuiContext* pContext = ImGui::GetCurrentContext();
if(pContext)
{
ImGui::Shutdown(pContext);
ImGui::DestroyContext(pContext);
}
}

ImwPlatformWindow* ImwWindowManager::GetMainPlatformWindow() const
Expand Down Expand Up @@ -945,8 +954,7 @@ namespace ImWindow
ImGuiContext* pContext = ImGui::GetCurrentContext();
ImGuiIO& oIO = pContext->IO;
oIO.DisplaySize = pWindow->GetSize();
if (pContext->FrameCountEnded >= pContext->FrameCount || !pContext->Initialized)
ImGui::NewFrame();
ImGui::NewFrame();

ImGuiStyle& oStyle = ImGui::GetStyle();

Expand All @@ -968,10 +976,10 @@ namespace ImWindow
bool bDisplayMenus = pWindow->IsShowContent() || oIO.MousePos.y <= 50.f || pContext->OpenPopupStack.size() > 0;
bool bDisplayWindow = bDisplayMenus || IsUsingCustomFrame();

ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiSetCond_Always);
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
if (pWindow->IsShowContent())
{
ImGui::SetNextWindowSize(pWindow->GetSize(), ImGuiSetCond_Always);
ImGui::SetNextWindowSize(pWindow->GetSize(), ImGuiCond_Always);
}
else
{
Expand All @@ -987,7 +995,7 @@ namespace ImWindow
oSize.y += ImGui::GetCurrentWindowRead()->MenuBarHeight();

}
ImGui::SetNextWindowSize(oSize, ImGuiSetCond_Always);
ImGui::SetNextWindowSize(oSize, ImGuiCond_Always);
}
int iFlags = c_iWindowFlags;

Expand All @@ -1004,7 +1012,7 @@ namespace ImWindow
oStyle.WindowRounding = 0.f;
oStyle.WindowPadding = ImVec2(0.f, 0.f);
oStyle.WindowMinSize = ImVec2(0.f, 0.f);
bool bWindowDraw = ImGui::Begin("ImWindow", NULL, ImVec2(0.f, 0.f), 1.f, iFlags);
bool bWindowDraw = ImGui::Begin("ImWindow", NULL, iFlags);
oStyle.WindowRounding = fWindowRoundingBackup;
oStyle.WindowPadding = oWindowPaddingBackup;
oStyle.WindowMinSize = oWindowMinSizeBackup;
Expand Down Expand Up @@ -1080,7 +1088,7 @@ namespace ImWindow

if (BeginTransparentChild("##ImWindowStatusBars", ImVec2(0.f, 0.f), false, c_iWindowChildFlags))
{
ImGui::AlignFirstTextHeightToWidgets();
ImGui::AlignTextToFramePadding();

ImGui::Columns((int)m_lStatusBars.size());
for (ImwStatusBarVector::iterator it = m_lStatusBars.begin(); it != m_lStatusBars.end(); ++it)
Expand Down Expand Up @@ -1117,7 +1125,7 @@ namespace ImWindow
m_pCurrentPlatformWindow = pWindow;
pWindow->SetContext(true);

ImDrawList* pDrawList = &(ImGui::GetCurrentContext()->OverlayDrawList);
ImDrawList* pDrawList = ImGui::GetOverlayDrawList();
for (ImVector<DrawWindowAreaAction>::iterator it = m_lDrawWindowAreas.begin(); it != m_lDrawWindowAreas.end(); ++it)
{
DrawWindowAreaAction& oAction = *it;
Expand Down Expand Up @@ -1570,10 +1578,10 @@ void ImwWindowManager::AddStatusBar(ImwStatusBar* pStatusBar)
bool ImwWindowManager::BeginTransparentChild(const char* pName, const ImVec2& oSize, bool bBorder, ImGuiWindowFlags iFlags)
{
ImGuiStyle& oStyle = ImGui::GetStyle();
ImVec4 oBackupChildWindowBg = oStyle.Colors[ImGuiCol_ChildWindowBg];
oStyle.Colors[ImGuiCol_ChildWindowBg].w = 0.f;
ImVec4 oBackupChildWindowBg = oStyle.Colors[ImGuiCol_ChildBg];
oStyle.Colors[ImGuiCol_ChildBg].w = 0.f;
bool bRet = ImGui::BeginChild(pName, oSize, bBorder, iFlags);
oStyle.Colors[ImGuiCol_ChildWindowBg] = oBackupChildWindowBg;
oStyle.Colors[ImGuiCol_ChildBg] = oBackupChildWindowBg;
return bRet;
}

Expand All @@ -1582,5 +1590,16 @@ void ImwWindowManager::AddStatusBar(ImwStatusBar* pStatusBar)
{
return s_pInstance;
}

void ImwWindowManager::RegenFontTexture()
{
m_pMainPlatformWindow->RegenFontTexture(NULL);
m_pDragPlatformWindow->RegenFontTexture(m_pMainPlatformWindow);
for (ImwPlatformWindow* pWindow : m_lPlatformWindows)
{
pWindow->RegenFontTexture(m_pMainPlatformWindow);
}
}

//SFF_END
}
1 change: 1 addition & 0 deletions ImWindow/ImwWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace ImWindow
virtual ImwWindow* CreateWindowByClassName(const char* pName);

virtual bool IsUsingCustomFrame() const;
void RegenFontTexture();
protected:
//To override for use multi window mode
virtual bool CanCreateMultipleWindow();
Expand Down
60 changes: 38 additions & 22 deletions ImWindowBGFX/ImwPlatformWindowBGFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ ImwPlatformWindowBGFX::ImwPlatformWindowBGFX(EPlatformWindowType eType, bool bCr
{
m_eRenderer = eRenderer;
m_iViewId = ++s_iCurrentViewId;

m_hTexture = BGFX_INVALID_HANDLE;
m_hUniformTexture = BGFX_INVALID_HANDLE;
}

ImwPlatformWindowBGFX::~ImwPlatformWindowBGFX()
Expand Down Expand Up @@ -79,36 +82,15 @@ bool ImwPlatformWindowBGFX::Init(ImwPlatformWindow* pMain)
m_hFrameBufferHandle = bgfx::createFrameBuffer(m_pWindow->GetHandle(), uint16_t(iWidth), uint16_t(iHeight));
bgfx::setViewFrameBuffer(m_iViewId, m_hFrameBufferHandle);

ImGuiIO& io = GetContext()->IO;

RegenFontTexture(pMain);
if (pMain != NULL)
{
ImwPlatformWindowBGFX* pMainBGFX = ((ImwPlatformWindowBGFX*)pMain);
m_hTexture = pMainBGFX->m_hTexture;
m_hUniformTexture = pMainBGFX->m_hUniformTexture;
m_hProgram = pMainBGFX->m_hProgram;
m_oVertexDecl = pMainBGFX->m_oVertexDecl;
}
else
{
uint8_t* data;
int32_t width;
int32_t height;
io.Fonts->AddFontDefault();
io.Fonts->GetTexDataAsRGBA32(&data, &width, &height);

m_hTexture = bgfx::createTexture2D(
(uint16_t)width
, (uint16_t)height
, false
, 1
, bgfx::TextureFormat::BGRA8
, 0
, bgfx::copy(data, width*height * 4)
);

m_hUniformTexture = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);

m_hProgram = bgfx::createProgram(
bgfx::createEmbeddedShader(s_embeddedShaders, m_eRenderer, "vs_ocornut_imgui")
, bgfx::createEmbeddedShader(s_embeddedShaders, m_eRenderer, "fs_ocornut_imgui")
Expand All @@ -134,6 +116,40 @@ bool ImwPlatformWindowBGFX::Init(ImwPlatformWindow* pMain)
return false;
}

void ImwPlatformWindowBGFX::RegenFontTexture(ImwPlatformWindow* pMain)
{
ImGuiIO& io = ImGui::GetIO();
if (pMain != NULL)
{
//Copy texture reference
m_hTexture = ((ImwPlatformWindowBGFX*)pMain)->m_hTexture;
m_hUniformTexture = ((ImwPlatformWindowBGFX*)pMain)->m_hUniformTexture;
}
else
{
if (bgfx::isValid(m_hTexture))
bgfx::destroy(m_hTexture);
if (bgfx::isValid(m_hUniformTexture))
bgfx::destroy(m_hUniformTexture);
uint8_t* data = NULL;
int32_t width = 0;
int32_t height = 0;
io.Fonts->AddFontDefault();
io.Fonts->GetTexDataAsRGBA32(&data, &width, &height);

m_hTexture = bgfx::createTexture2D(
(uint16_t)width
, (uint16_t)height
, false
, 1
, bgfx::TextureFormat::BGRA8
, 0
, bgfx::copy(data, width*height * 4)
);
m_hUniformTexture = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);
}
}

void ImwPlatformWindowBGFX::OnClientSize(int iClientWidth, int iClientHeight)
{
bgfx::frame();
Expand Down
1 change: 1 addition & 0 deletions ImWindowBGFX/ImwPlatformWindowBGFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace ImWindow
virtual ~ImwPlatformWindowBGFX();

virtual bool Init(ImwPlatformWindow* pMain);
virtual void RegenFontTexture(ImwPlatformWindow* pMain);

protected:

Expand Down
2 changes: 0 additions & 2 deletions ImWindowBGFX/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ int main()

while (oMgr.Run(false) && oMgr.Run(true)) Sleep(16);

ImGui::Shutdown();

return 0;
}
Loading