@@ -226,6 +226,15 @@ static void ImDrawList_SwapChannels(ImDrawList* drawList, int left, int right)
226
226
ImDrawListSplitter_SwapChannels (&drawList->_Splitter , left, right);
227
227
}
228
228
229
+ static void ImDrawList_SwapSplitter (ImDrawList* drawList, ImDrawListSplitter& splitter)
230
+ {
231
+ auto & currentSplitter = drawList->_Splitter ;
232
+
233
+ std::swap (currentSplitter._Current , splitter._Current );
234
+ std::swap (currentSplitter._Count , splitter._Count );
235
+ currentSplitter._Channels .swap (splitter._Channels );
236
+ }
237
+
229
238
// static void ImDrawList_TransformChannel_Inner(ImVector<ImDrawVert>& vtxBuffer, const ImVector<ImDrawIdx>& idxBuffer, const ImVector<ImDrawCmd>& cmdBuffer, const ImVec2& preOffset, const ImVec2& scale, const ImVec2& postOffset)
230
239
// {
231
240
// auto idxRead = idxBuffer.Data;
@@ -1031,6 +1040,7 @@ ed::EditorContext::EditorContext(const ax::NodeEditor::Config* config)
1031
1040
, m_IsInitialized(false )
1032
1041
, m_Settings()
1033
1042
, m_Config(config)
1043
+ , m_ExternalChannel(0 )
1034
1044
{
1035
1045
}
1036
1046
@@ -1042,6 +1052,8 @@ ed::EditorContext::~EditorContext()
1042
1052
for (auto link : m_Links) delete link .m_Object ;
1043
1053
for (auto pin : m_Pins) delete pin.m_Object ;
1044
1054
for (auto node : m_Nodes) delete node.m_Object ;
1055
+
1056
+ m_Splitter.ClearFreeMemory ();
1045
1057
}
1046
1058
1047
1059
void ed::EditorContext::Begin (const char * id, const ImVec2& size)
@@ -1059,6 +1071,11 @@ void ed::EditorContext::Begin(const char* id, const ImVec2& size)
1059
1071
for (auto pin : m_Pins) pin->Reset ();
1060
1072
for (auto link : m_Links) link ->Reset ();
1061
1073
1074
+ auto drawList = ImGui::GetWindowDrawList ();
1075
+
1076
+ ImDrawList_SwapSplitter (drawList, m_Splitter);
1077
+ m_ExternalChannel = drawList->_Splitter ._Current ;
1078
+
1062
1079
ImGui::PushID (id);
1063
1080
1064
1081
auto availableContentSize = ImGui::GetContentRegionAvail ();
@@ -1095,8 +1112,6 @@ void ed::EditorContext::Begin(const char* id, const ImVec2& size)
1095
1112
1096
1113
m_Canvas.SetView (m_NavigateAction.GetView ());
1097
1114
1098
- auto drawList = ImGui::GetWindowDrawList ();
1099
-
1100
1115
// #debug #clip
1101
1116
// ImGui::Text("CLIP = { x=%g y=%g w=%g h=%g r=%g b=%g }",
1102
1117
// clipMin.x, clipMin.y, clipMax.x - clipMin.x, clipMax.y - clipMin.y, clipMax.x, clipMax.y);
@@ -1408,6 +1423,8 @@ void ed::EditorContext::End()
1408
1423
if (m_IsCanvasVisible)
1409
1424
m_Canvas.End ();
1410
1425
1426
+ ImDrawList_SwapSplitter (drawList, m_Splitter);
1427
+
1411
1428
// Draw border
1412
1429
{
1413
1430
auto & style = ImGui::GetStyle ();
@@ -1650,20 +1667,26 @@ void ed::EditorContext::NotifyLinkDeleted(Link* link)
1650
1667
m_LastActiveLink = nullptr ;
1651
1668
}
1652
1669
1653
- void ed::EditorContext::Suspend ()
1670
+ void ed::EditorContext::Suspend (SuspendFlags flags )
1654
1671
{
1655
- auto lastChannel = ImGui::GetWindowDrawList ()->_Splitter ._Current ;
1656
- ImGui::GetWindowDrawList ()->ChannelsSetCurrent (0 );
1672
+ auto drawList = ImGui::GetWindowDrawList ();
1673
+ auto lastChannel = drawList->_Splitter ._Current ;
1674
+ drawList->ChannelsSetCurrent (m_ExternalChannel);
1657
1675
m_Canvas.Suspend ();
1658
- ImGui::GetWindowDrawList ()->ChannelsSetCurrent (lastChannel);
1676
+ drawList->ChannelsSetCurrent (lastChannel);
1677
+ if ((flags & SuspendFlags::KeepSplitter) != SuspendFlags::KeepSplitter)
1678
+ ImDrawList_SwapSplitter (drawList, m_Splitter);
1659
1679
}
1660
1680
1661
- void ed::EditorContext::Resume ()
1681
+ void ed::EditorContext::Resume (SuspendFlags flags )
1662
1682
{
1663
- auto lastChannel = ImGui::GetWindowDrawList ()->_Splitter ._Current ;
1664
- ImGui::GetWindowDrawList ()->ChannelsSetCurrent (0 );
1683
+ auto drawList = ImGui::GetWindowDrawList ();
1684
+ if ((flags & SuspendFlags::KeepSplitter) != SuspendFlags::KeepSplitter)
1685
+ ImDrawList_SwapSplitter (drawList, m_Splitter);
1686
+ auto lastChannel = drawList->_Splitter ._Current ;
1687
+ drawList->ChannelsSetCurrent (m_ExternalChannel);
1665
1688
m_Canvas.Resume ();
1666
- ImGui::GetWindowDrawList () ->ChannelsSetCurrent (lastChannel);
1689
+ drawList ->ChannelsSetCurrent (lastChannel);
1667
1690
}
1668
1691
1669
1692
bool ed::EditorContext::IsSuspended ()
@@ -4219,7 +4242,7 @@ void ed::CreateItemAction::End()
4219
4242
if (m_IsInGlobalSpace)
4220
4243
{
4221
4244
ImGui::PopClipRect ();
4222
- Editor->Resume ();
4245
+ Editor->Resume (SuspendFlags::KeepSplitter );
4223
4246
4224
4247
auto currentChannel = ImGui::GetWindowDrawList ()->_Splitter ._Current ;
4225
4248
if (currentChannel != m_LastChannel)
@@ -4331,7 +4354,7 @@ ed::CreateItemAction::Result ed::CreateItemAction::QueryLink(PinId* startId, Pin
4331
4354
4332
4355
if (!m_IsInGlobalSpace)
4333
4356
{
4334
- Editor->Suspend ();
4357
+ Editor->Suspend (SuspendFlags::KeepSplitter );
4335
4358
4336
4359
auto rect = Editor->GetRect ();
4337
4360
ImGui::PushClipRect (rect.Min + ImVec2 (1 , 1 ), rect.Max - ImVec2 (1 , 1 ), false );
@@ -4354,7 +4377,7 @@ ed::CreateItemAction::Result ed::CreateItemAction::QueryNode(PinId* pinId)
4354
4377
4355
4378
if (!m_IsInGlobalSpace)
4356
4379
{
4357
- Editor->Suspend ();
4380
+ Editor->Suspend (SuspendFlags::KeepSplitter );
4358
4381
4359
4382
auto rect = Editor->GetRect ();
4360
4383
ImGui::PushClipRect (rect.Min + ImVec2 (1 , 1 ), rect.Max - ImVec2 (1 , 1 ), false );
@@ -4934,7 +4957,7 @@ bool ed::HintBuilder::Begin(NodeId nodeId)
4934
4957
4935
4958
m_LastChannel = ImGui::GetWindowDrawList ()->_Splitter ._Current ;
4936
4959
4937
- Editor->Suspend ();
4960
+ Editor->Suspend (SuspendFlags::KeepSplitter );
4938
4961
4939
4962
const auto alpha = ImMax (0 .0f , std::min (1 .0f , (view.Scale - c_min_zoom) / (c_max_zoom - c_min_zoom)));
4940
4963
@@ -4966,7 +4989,7 @@ void ed::HintBuilder::End()
4966
4989
4967
4990
ImGui::GetWindowDrawList ()->ChannelsSetCurrent (m_LastChannel);
4968
4991
4969
- Editor->Resume ();
4992
+ Editor->Resume (SuspendFlags::KeepSplitter );
4970
4993
4971
4994
m_IsActive = false ;
4972
4995
m_CurrentNode = nullptr ;
0 commit comments