MCPcopy Create free account
hub / github.com/TankOs/SFGUI / SearchContainerForClass

Function SearchContainerForClass

src/SFGUI/Widget.cpp:682–708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682Widget::WidgetsList SearchContainerForClass( Container::PtrConst container, const std::string& class_name ) {
683 Widget::WidgetsList result;
684
685 if( !container ) {
686 return result;
687 }
688
689 for( const auto& child : container->GetChildren() ) {
690 if( child->GetClass() == class_name ) {
691 result.push_back( child );
692 }
693
694 auto child_container = std::dynamic_pointer_cast<Container>( child );
695
696 if( child_container ) {
697 auto child_result = SearchContainerForClass( child_container, class_name );
698
699 // Splice the 2 vectors.
700 if( !child_result.empty() ) {
701 result.reserve( child_result.size() );
702 result.insert( result.end(), child_result.begin(), child_result.end() );
703 }
704 }
705 }
706
707 return result;
708}
709
710Widget::WidgetsList Widget::GetWidgetsByClass( const std::string& class_name ) {
711 WidgetsList result;

Callers 1

GetWidgetsByClassMethod · 0.85

Calls 4

GetClassMethod · 0.80
emptyMethod · 0.80
sizeMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected