mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Merged latest.
This commit is contained in:
parent
9bf22e0a24
commit
d0accb67da
2 changed files with 100 additions and 19 deletions
110
3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
110
3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
|
@ -19,6 +19,15 @@
|
|||
|
||||
namespace ImGuiWM
|
||||
{
|
||||
enum EPlatformWindowAction
|
||||
{
|
||||
E_PLATFORM_WINDOW_ACTION_DESTOY = 1,
|
||||
E_PLATFORM_WINDOW_ACTION_SHOW = 2,
|
||||
E_PLATFORM_WINDOW_ACTION_HIDE = 4,
|
||||
E_PLATFORM_WINDOW_ACTION_SET_POSITION = 8,
|
||||
E_PLATFORM_WINDOW_ACTION_SET_SIZE = 16,
|
||||
};
|
||||
|
||||
static const ImVec2 IM_VEC2_0 = ImVec2(0, 0);
|
||||
static const ImVec2 IM_VEC2_N1 = ImVec2(-1, -1);
|
||||
|
||||
|
@ -394,9 +403,12 @@ namespace ImGuiWM
|
|||
WindowManager* pWindowManager = WindowManager::GetInstance();
|
||||
ImGuiWindow* pWindow = ImGui::GetCurrentWindow();
|
||||
const ImGuiStyle& oStyle = ImGui::GetStyle();
|
||||
ImDrawList* pDrawList = ImGui::GetWindowDrawList();
|
||||
|
||||
const ImVec2 oPos = ImGui::GetWindowPos();
|
||||
const ImVec2 oSize = ImGui::GetWindowSize();
|
||||
const ImVec2 oMin = ImVec2(oPos.x + 1, oPos.y + 1);
|
||||
const ImVec2 oMax = ImVec2(oPos.x + oSize.x - 2, oPos.y + oSize.y - 2);
|
||||
|
||||
m_oLastPosition = oPos;
|
||||
m_oLastSize = oSize;
|
||||
|
@ -509,22 +521,23 @@ namespace ImGuiWM
|
|||
ImVec2 oButtonMin = ImGui::GetItemRectMin();
|
||||
ImVec2 oButtonMax = ImGui::GetItemRectMax();
|
||||
ImVec2 oButtonSize = ImVec2(oButtonMax.x - oButtonMin.x, oButtonMax.y - oButtonMin.y);
|
||||
ImDrawList* pList = ImGui::GetWindowDrawList();
|
||||
pList->AddLine(
|
||||
pDrawList->AddLine(
|
||||
ImVec2(oButtonMin.x + 1, oButtonMin.y + oButtonSize.y / 2),
|
||||
ImVec2(oButtonMax.x - 1, oButtonMin.y + oButtonSize.y / 2),
|
||||
oLinesColor);
|
||||
|
||||
pList->AddLine(
|
||||
pDrawList->AddLine(
|
||||
ImVec2(oButtonMin.x + 1, oButtonMin.y + oButtonSize.y / 2 - 4),
|
||||
ImVec2(oButtonMax.x - 1, oButtonMin.y + oButtonSize.y / 2 - 4),
|
||||
oLinesColor);
|
||||
|
||||
pList->AddLine(
|
||||
pDrawList->AddLine(
|
||||
ImVec2(oButtonMin.x + 1, oButtonMin.y + oButtonSize.y / 2 + 4),
|
||||
ImVec2(oButtonMax.x - 1, oButtonMin.y + oButtonSize.y / 2 + 4),
|
||||
oLinesColor);
|
||||
|
||||
pDrawList->ChannelsSplit(2);
|
||||
|
||||
//Tabs
|
||||
int iIndex = 0;
|
||||
int iNewActive = m_iActiveWindow;
|
||||
|
@ -532,12 +545,12 @@ namespace ImGuiWM
|
|||
for (WindowList::iterator it = m_lWindows.begin(); it != m_lWindows.end(); ++it)
|
||||
{
|
||||
const ImVec2 oTextSize = ImGui::CalcTextSize((*it)->GetTitle());
|
||||
const ImVec2 oRectSize(oTextSize.x + 4, oTextSize.y+2);
|
||||
ImVec2 oRectSize(oTextSize.x + 15, 25);
|
||||
|
||||
ImGui::PushID(iIndex);
|
||||
|
||||
bool bSelected = iIndex == m_iActiveWindow;
|
||||
if (ImGui::Selectable((*it)->GetTitle(), &bSelected, 0, oRectSize))
|
||||
if (ImGui::InvisibleButton((*it)->GetId(), oRectSize))
|
||||
{
|
||||
iNewActive = iIndex;
|
||||
}
|
||||
|
@ -554,6 +567,84 @@ namespace ImGuiWM
|
|||
}
|
||||
}
|
||||
|
||||
ImColor oNormalTab(50, 50, 50, 255); // normal
|
||||
ImColor oSelectedTab(37, 37, 37, 255); // selected
|
||||
ImColor oBorderColor(72, 72, 72, 255); // border
|
||||
|
||||
ImVec2 oRectMin = ImGui::GetItemBoxMin();
|
||||
ImVec2 oRectMax = ImGui::GetItemBoxMax();
|
||||
|
||||
const float fOverlap = 10.f;
|
||||
const float fSlopWidth = 30.f;
|
||||
const float sSlopP1Ratio = 0.6f;
|
||||
const float fSlopP2Ratio = 0.4f;
|
||||
const float fSlopHRatio = 0.f;
|
||||
const float fShadowDropSize = 15.f;
|
||||
const float fShadowSlopRatio = 0.6f;
|
||||
const float fShadowAlpha = 0.75f;
|
||||
|
||||
pDrawList->PathClear();
|
||||
if (bSelected)
|
||||
{
|
||||
pDrawList->ChannelsSetCurrent(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDrawList->ChannelsSetCurrent(0);
|
||||
}
|
||||
|
||||
//Drop shadows
|
||||
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
||||
pDrawList->PrimReserve(3, 3);
|
||||
pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx)); pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx + 1)); pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx + 2));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMin.x - fOverlap - fShadowDropSize, oRectMax.y), uv, ImColor(0.f, 0.f, 0.f, 0.f));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMin.x - fOverlap + fSlopWidth * fShadowSlopRatio, oRectMin.y), uv, ImColor(0.f, 0.f, 0.f, 0.f));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMin.x - fOverlap + fSlopWidth * fShadowSlopRatio, oRectMax.y), uv, ImColor(0.f, 0.f, 0.f, fShadowAlpha));
|
||||
if (bSelected)
|
||||
{
|
||||
pDrawList->PrimReserve(3, 3);
|
||||
pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx)); pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx + 1)); pDrawList->PrimWriteIdx((ImDrawIdx)(pDrawList->_VtxCurrentIdx + 2));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMax.x + fOverlap + fShadowDropSize, oRectMax.y), uv, ImColor(0.f, 0.f, 0.f, 0.f));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMax.x + fOverlap - fSlopWidth * fShadowSlopRatio, oRectMin.y), uv, ImColor(0.f, 0.f, 0.f, 0.f));
|
||||
pDrawList->PrimWriteVtx(ImVec2(oRectMax.x + fOverlap - fSlopWidth * fShadowSlopRatio, oRectMax.y), uv, ImColor(0.f, 0.f, 0.f, fShadowAlpha));
|
||||
}
|
||||
|
||||
// Draw tab and border
|
||||
if (bSelected)
|
||||
{
|
||||
pDrawList->PathLineTo(ImVec2(oMin.x, oRectMax.y));
|
||||
}
|
||||
pDrawList->PathLineTo(ImVec2(oRectMin.x - fOverlap, oRectMax.y));
|
||||
pDrawList->PathBezierCurveTo(
|
||||
ImVec2(oRectMin.x + fSlopWidth * sSlopP1Ratio - fOverlap, oRectMin.y + (oRectMax.y - oRectMin.y) * fSlopHRatio),
|
||||
ImVec2(oRectMin.x + fSlopWidth * fSlopP2Ratio - fOverlap, oRectMin.y),
|
||||
ImVec2(oRectMin.x + fSlopWidth - fOverlap, oRectMin.y)
|
||||
);
|
||||
pDrawList->PathLineTo(ImVec2(oRectMax.x - fSlopWidth + fOverlap, oRectMin.y));
|
||||
pDrawList->PathBezierCurveTo(
|
||||
ImVec2(oRectMax.x - fSlopWidth * fSlopP2Ratio + fOverlap, oRectMin.y),
|
||||
ImVec2(oRectMax.x - fSlopWidth * sSlopP1Ratio + fOverlap, oRectMin.y + (oRectMax.y - oRectMin.y) * fSlopHRatio),
|
||||
ImVec2(oRectMax.x + fOverlap, oRectMax.y)
|
||||
);
|
||||
|
||||
if (bSelected)
|
||||
{
|
||||
pDrawList->AddConvexPolyFilled(pDrawList->_Path.Data + 1, pDrawList->_Path.Size - 1, bSelected ? oSelectedTab : oNormalTab, true);
|
||||
if (oMax.x > (oRectMax.x + fOverlap))
|
||||
{
|
||||
pDrawList->PathLineTo(ImVec2(oMax.x, oRectMax.y));
|
||||
}
|
||||
pDrawList->AddPolyline(pDrawList->_Path.Data, pDrawList->_Path.Size, oBorderColor, false, 1.5f, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDrawList->AddConvexPolyFilled(pDrawList->_Path.Data, pDrawList->_Path.Size, bSelected ? oSelectedTab : oNormalTab, true);
|
||||
}
|
||||
|
||||
pDrawList->PathClear();
|
||||
|
||||
ImGui::RenderTextClipped(oRectMin, ImVec2(oRectMax.x, oRectMax.y), (*it)->GetTitle(), NULL, &oTextSize, ImGuiAlign_Center | ImGuiAlign_VCenter);
|
||||
|
||||
if (ImGui::BeginPopupContextItem("TabMenu"))
|
||||
{
|
||||
if (ImGui::Selectable("Close"))
|
||||
|
@ -660,6 +751,7 @@ namespace ImGuiWM
|
|||
++iIndex;
|
||||
}
|
||||
m_iActiveWindow = iNewActive;
|
||||
pDrawList->ChannelsMerge();
|
||||
|
||||
WindowList::iterator itActiveWindow = m_lWindows.begin();
|
||||
std::advance(itActiveWindow, m_iActiveWindow);
|
||||
|
@ -1301,8 +1393,7 @@ namespace ImGuiWM
|
|||
ImGui::End();
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TooltipBg, ImColor(0, 0, 0, 0));
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Begin("##Overlay", NULL, ImVec2(0, 0), 0.f, ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImDrawList* pDrawList = ImGui::GetWindowDrawList();
|
||||
for (ImwList<DrawWindowAreaAction>::iterator it = m_lDrawWindowAreas.begin(); it != m_lDrawWindowAreas.end();)
|
||||
{
|
||||
|
@ -1328,8 +1419,7 @@ namespace ImGuiWM
|
|||
}
|
||||
}
|
||||
|
||||
ImGui::EndTooltip();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
9
3rdparty/ocornut-imgui/imgui_wm.h
vendored
9
3rdparty/ocornut-imgui/imgui_wm.h
vendored
|
@ -182,15 +182,6 @@ namespace ImGuiWM
|
|||
friend class PlatformWindow;
|
||||
friend class Container;
|
||||
|
||||
enum EPlatformWindowAction
|
||||
{
|
||||
E_PLATFORM_WINDOW_ACTION_DESTOY = 1,
|
||||
E_PLATFORM_WINDOW_ACTION_SHOW = 2,
|
||||
E_PLATFORM_WINDOW_ACTION_HIDE = 4,
|
||||
E_PLATFORM_WINDOW_ACTION_SET_POSITION = 8,
|
||||
E_PLATFORM_WINDOW_ACTION_SET_SIZE = 16,
|
||||
};
|
||||
|
||||
struct PlatformWindowAction
|
||||
{
|
||||
PlatformWindow* m_pPlatformWindow;
|
||||
|
|
Loading…
Reference in a new issue