mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	LibCore: Add Object::remove_all_children()
This commit is contained in:
		
							parent
							
								
									ddaedbca87
								
							
						
					
					
						commit
						e955c024b2
					
				
					 3 changed files with 8 additions and 4 deletions
				
			
		|  | @ -46,10 +46,7 @@ int main(int argc, char** argv) | ||||||
|     editor.set_automatic_indentation_enabled(true); |     editor.set_automatic_indentation_enabled(true); | ||||||
| 
 | 
 | ||||||
|     editor.on_change = [&] { |     editor.on_change = [&] { | ||||||
|         // FIXME: This is not a very expressive way to remove all children..
 |         preview.remove_all_children(); | ||||||
|         while (!preview.children().is_empty()) |  | ||||||
|             preview.children().first().remove_from_parent(); |  | ||||||
| 
 |  | ||||||
|         preview.load_from_gml(editor.text()); |         preview.load_from_gml(editor.text()); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -130,6 +130,12 @@ void Object::remove_child(Object& object) | ||||||
|     ASSERT_NOT_REACHED(); |     ASSERT_NOT_REACHED(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void Object::remove_all_children() | ||||||
|  | { | ||||||
|  |     while (!m_children.is_empty()) | ||||||
|  |         m_children.first().remove_from_parent(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void Object::timer_event(Core::TimerEvent&) | void Object::timer_event(Core::TimerEvent&) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -105,6 +105,7 @@ public: | ||||||
|     void add_child(Object&); |     void add_child(Object&); | ||||||
|     void insert_child_before(Object& new_child, Object& before_child); |     void insert_child_before(Object& new_child, Object& before_child); | ||||||
|     void remove_child(Object&); |     void remove_child(Object&); | ||||||
|  |     void remove_all_children(); | ||||||
| 
 | 
 | ||||||
|     void dump_tree(int indent = 0); |     void dump_tree(int indent = 0); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh