| 263 | } |
| 264 | |
| 265 | void 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 |
nothing calls this directly
no test coverage detected