MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / drawObjectsList_

Method drawObjectsList_

source/MRViewer/MRSceneObjectsListDrawer.cpp:265–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265void SceneObjectsListDrawer::drawObjectsList_()
266{
267 const auto& all = SceneCache::getAllObjects<Object, ObjectSelectivityType::Selectable>();
268 std::vector<int> depths( all.size(), -1 );
269 auto getDepth = [&] ( int i )
270 {
271 if ( depths[i] == -1 )
272 {
273 const Object* obj = all[i].get();
274 int depth = 0;
275 while ( obj->parent() && obj->parent() != SceneRoot::getSharedPtr().get() )
276 {
277 obj = obj->parent();
278 if ( obj->isAncillary() )
279 --depth;
280 ++depth;
281 }
282 depths[i] = depth;
283 }
284 return depths[i];
285 };
286
287 int currentDepth = 0;
288 std::stack<std::shared_ptr<Object>> objDepthStack;
289
290 SkippableRenderer skippableRenderer;
291
292 int collapsedHeaderDepth = -1;
293 const float itemSpacingY = ImGui::GetStyle().ItemSpacing.y;
294 const float frameHeight = ImGui::GetFrameHeight();
295
296 bool firstSelectedIsFound = false;
297 bool previousWasSelected = false;
298
299 const float borderShift = ImGui::GetFrameHeight();
300 const float scrollPosY = ImGui::GetScrollY();
301 const float windowHeight = ImGui::GetWindowHeight();
302 if ( upFirstSelected_.needScroll && upFirstSelected_.posY < ( scrollPosY + ImGui::GetStyle().WindowPadding.y + borderShift ) )
303 ImGui::SetScrollY( upFirstSelected_.posY - ImGui::GetStyle().WindowPadding.y - borderShift );
304 if ( downLastSelected_.needScroll && downLastSelected_.posY > ( scrollPosY + windowHeight - borderShift ) )
305 ImGui::SetScrollY( downLastSelected_.posY - windowHeight + ImGui::GetStyle().WindowPadding.y + borderShift );
306 if ( nextVisible_.needScroll )
307 {
308 if ( nextVisible_.posY < ( scrollPosY + ImGui::GetStyle().WindowPadding.y + borderShift ) )
309 ImGui::SetScrollY( nextVisible_.posY - ImGui::GetStyle().WindowPadding.y - borderShift );
310 else if ( ( nextVisible_.posY + frameHeight ) > ( scrollPosY + windowHeight - borderShift ) )
311 ImGui::SetScrollY( nextVisible_.posY + frameHeight - windowHeight + ImGui::GetStyle().WindowPadding.y + borderShift );
312 nextVisible_ = MoveAndScrollData();
313 }
314
315 upFirstSelected_ = MoveAndScrollData();
316 downLastSelected_ = MoveAndScrollData();
317
318 for ( int i = 0; i < all.size(); ++i )
319 {
320 const bool isLast = i == int( all.size() ) - 1;
321 const int nextDepth = isLast ? 0 : getDepth( i + 1 );
322 // skip child elements after collapsed header

Callers

nothing calls this directly

Calls 12

MoveAndScrollDataClass · 0.85
drawSceneContextMenu_Function · 0.85
isSelectedMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45
parentMethod · 0.45
drawMethod · 0.45
popMethod · 0.45
pushMethod · 0.45
getCursorPosYMethod · 0.45
endDrawMethod · 0.45

Tested by

no test coverage detected