MCPcopy Create free account
hub / github.com/Illation/ETEngine / AdjustLayout

Method AdjustLayout

Engine/source/EtEditor/Layout/EditorSplitNode.cpp:87–147  ·  view source on GitHub ↗

--------------------------------- EditorSplitNode::AdjustLayout Set the pane position once the widget is realized

Source from the content-addressed store, hash-verified

85// Set the pane position once the widget is realized
86//
87void EditorSplitNode::AdjustLayout()
88{
89 if (m_LayoutAdjusted)
90 {
91 return;
92 }
93
94 // set the position of the handle
95 int32 size = 0;
96
97 if (m_IsHorizontal)
98 {
99 size = m_Attachment->get_allocated_width();
100 }
101 else
102 {
103 size = m_Attachment->get_allocated_height();
104 }
105
106 m_Paned->set_position(static_cast<int32>(m_SplitRatio * static_cast<float>(size)));
107
108 // propagate this to children
109 if (!(m_Child1->IsLeaf()))
110 {
111 static_cast<EditorSplitNode*>(m_Child1)->AdjustLayout();
112 }
113
114 if (!(m_Child2->IsLeaf()))
115 {
116 static_cast<EditorSplitNode*>(m_Child2)->AdjustLayout();
117 }
118
119 m_LayoutAdjusted = true;
120
121 // ensure the split ratio is updated if the user drags the handle
122 auto positionChangedCallback = [this]()
123 {
124 if (!m_LayoutAdjusted)
125 {
126 return;
127 }
128
129 float size = 0.f;
130 if (m_IsHorizontal)
131 {
132 size = static_cast<float>(m_Attachment->get_allocated_width());
133 }
134 else
135 {
136 size = static_cast<float>(m_Attachment->get_allocated_height());
137 }
138
139 if (size == 0.f)
140 {
141 return;
142 }
143
144 m_SplitRatio = static_cast<float>(m_Paned->get_position()) / size;

Callers 2

OnAllocationAvailableMethod · 0.80
SplitNodeMethod · 0.80

Calls 1

IsLeafMethod · 0.45

Tested by

no test coverage detected