2023-01-05 13:25:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  flow_container.cpp                                                    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                         This file is part of:                          */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                             GODOT ENGINE                               */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                        https://godotengine.org                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* a copy of this software and associated documentation files (the        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* the following conditions:                                              */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* The above copyright notice and this permission notice shall be         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* included in all copies or substantial portions of the Software.        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "flow_container.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												Avoid FlowContainer crash with TextureRect using EXPAND_FIT_* expand modes
When a FlowContainer had a TextureRect child using any of the EXPAND_FIT_* expand modes, it could crash when changing the FlowContainer's minimum size, or that of its children.  This was due to the TextureRect resizing in FlowContainer::_resort, updating its minimum size, and triggering another _resort.  If the TextureRect's minimum size changed in a way that caused any of the FlowContainer's children to be put on a different line, it could repeatedly cause _resort to be called again, moving the children back and forth between the old and new lines.
This change is for FlowContainer::_resort to give a warning for TextureRects with EXPAND_FIT_* expand modes when multiple lines are used, and just keep the TextureRect size the same in that case.  This is similar to the check added to AspectRatioContainer in godotengine#73396, but attempting to still support it in FlowContainer when possible.  In the case where the TextureRect is forced to stay the same size, there may be some overlap between the FlowContainer's children, but should no longer crash.
											 
										 
										
											2024-07-12 16:57:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "scene/gui/texture_rect.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-09-08 21:00:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "scene/theme/theme_db.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								struct  _LineData  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  child_count  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  min_line_height  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  min_line_length  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  stretch_avail  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									float  stretch_ratio_total  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  is_filled  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  FlowContainer : : _resort ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-03-15 11:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Avoid resorting if invisible.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									bool  rtl  =  is_layout_rtl ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HashMap < Control  * ,  Size2i >  children_minsize_cache ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < _LineData >  lines_data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector2i  ofs ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  line_height  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  line_length  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									float  line_stretch_ratio_total  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-21 19:13:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  current_container_size  =  vertical  ?  get_size ( ) . y  :  get_size ( ) . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									int  children_in_current_line  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Control  * last_child  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// First pass for line wrapping and minimum size calculation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 12:38:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Control  * child  =  as_sortable_control ( get_child ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! child )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Size2i  child_msc  =  child - > get_combined_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( vertical )  {  /* VERTICAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( children_in_current_line  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . y  + =  theme_cache . v_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ofs . y  +  child_msc . y  >  current_container_size )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												line_length  =  ofs . y  -  theme_cache . v_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												lines_data . push_back ( _LineData {  children_in_current_line ,  line_height ,  line_length ,  current_container_size  -  line_length ,  line_stretch_ratio_total ,  true  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// Move in new column (vertical line).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . x  + =  line_height  +  theme_cache . h_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												ofs . y  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												line_height  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												line_stretch_ratio_total  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												children_in_current_line  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											line_height  =  MAX ( line_height ,  child_msc . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_v_size_flags ( ) . has_flag ( SIZE_EXPAND ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												line_stretch_ratio_total  + =  child - > get_stretch_ratio ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ofs . y  + =  child_msc . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  {  /* HORIZONTAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( children_in_current_line  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . x  + =  theme_cache . h_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ofs . x  +  child_msc . x  >  current_container_size )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												line_length  =  ofs . x  -  theme_cache . h_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												lines_data . push_back ( _LineData {  children_in_current_line ,  line_height ,  line_length ,  current_container_size  -  line_length ,  line_stretch_ratio_total ,  true  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// Move in new line.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . y  + =  line_height  +  theme_cache . v_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												ofs . x  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												line_height  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												line_stretch_ratio_total  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												children_in_current_line  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											line_height  =  MAX ( line_height ,  child_msc . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_h_size_flags ( ) . has_flag ( SIZE_EXPAND ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												line_stretch_ratio_total  + =  child - > get_stretch_ratio ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ofs . x  + =  child_msc . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										last_child  =  child ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										children_minsize_cache [ child ]  =  child_msc ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										children_in_current_line + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									line_length  =  vertical  ?  ( ofs . y )  :  ( ofs . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  is_filled  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( last_child  ! =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										is_filled  =  vertical  ?  ( ofs . y  +  last_child - > get_combined_minimum_size ( ) . y  >  current_container_size  ?  true  :  false )  :  ( ofs . x  +  last_child - > get_combined_minimum_size ( ) . x  >  current_container_size  ?  true  :  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									lines_data . push_back ( _LineData {  children_in_current_line ,  line_height ,  line_length ,  current_container_size  -  line_length ,  line_stretch_ratio_total ,  is_filled  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Second pass for in-line expansion and alignment.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  current_line_idx  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  child_idx_in_line  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ofs . x  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ofs . y  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 12:38:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Control  * child  =  as_sortable_control ( get_child ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! child )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Size2i  child_size  =  children_minsize_cache [ child ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_LineData  line_data  =  lines_data [ current_line_idx ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( child_idx_in_line  > =  lines_data [ current_line_idx ] . child_count )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											current_line_idx + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											child_idx_in_line  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( vertical )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . x  + =  line_data . min_line_height  +  theme_cache . h_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												ofs . y  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ofs . x  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ofs . y  + =  line_data . min_line_height  +  theme_cache . v_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											line_data  =  lines_data [ current_line_idx ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// The first child of each line adds the offset caused by the alignment,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// but only if the line doesn't contain a child that expands.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( child_idx_in_line  = =  0  & &  Math : : is_equal_approx ( line_data . stretch_ratio_total ,  0 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											int  alignment_ofs  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											bool  is_not_first_line_and_not_filled  =  current_line_idx  ! =  0  & &  ! line_data . is_filled ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											float  prior_stretch_avail  =  is_not_first_line_and_not_filled  ?  lines_data [ current_line_idx  -  1 ] . stretch_avail  :  0.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											switch  ( alignment )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												case  ALIGNMENT_BEGIN :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( last_wrap_alignment  ! =  LAST_WRAP_ALIGNMENT_INHERIT  & &  is_not_first_line_and_not_filled )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  ( last_wrap_alignment  = =  LAST_WRAP_ALIGNMENT_END )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  line_data . stretch_avail  -  prior_stretch_avail ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														}  else  if  ( last_wrap_alignment  = =  LAST_WRAP_ALIGNMENT_CENTER )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  ( line_data . stretch_avail  -  prior_stretch_avail )  *  0.5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  ALIGNMENT_CENTER :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( last_wrap_alignment  ! =  LAST_WRAP_ALIGNMENT_INHERIT  & &  last_wrap_alignment  ! =  LAST_WRAP_ALIGNMENT_CENTER  & &  is_not_first_line_and_not_filled )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  ( last_wrap_alignment  = =  LAST_WRAP_ALIGNMENT_END )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  line_data . stretch_avail  -  ( prior_stretch_avail  *  0.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														}  else  {  // Is LAST_WRAP_ALIGNMENT_BEGIN
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  prior_stretch_avail  *  0.5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														alignment_ofs  =  line_data . stretch_avail  *  0.5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  ALIGNMENT_END :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( last_wrap_alignment  ! =  LAST_WRAP_ALIGNMENT_INHERIT  & &  last_wrap_alignment  ! =  LAST_WRAP_ALIGNMENT_END  & &  is_not_first_line_and_not_filled )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  ( last_wrap_alignment  = =  LAST_WRAP_ALIGNMENT_BEGIN )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  prior_stretch_avail ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														}  else  {  // Is LAST_WRAP_ALIGNMENT_CENTER
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															alignment_ofs  =  prior_stretch_avail  +  ( line_data . stretch_avail  -  prior_stretch_avail )  *  0.5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														alignment_ofs  =  line_data . stretch_avail ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( vertical )  {  /* VERTICAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ofs . y  + =  alignment_ofs ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  {  /* HORIZONTAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ofs . x  + =  alignment_ofs ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												Avoid FlowContainer crash with TextureRect using EXPAND_FIT_* expand modes
When a FlowContainer had a TextureRect child using any of the EXPAND_FIT_* expand modes, it could crash when changing the FlowContainer's minimum size, or that of its children.  This was due to the TextureRect resizing in FlowContainer::_resort, updating its minimum size, and triggering another _resort.  If the TextureRect's minimum size changed in a way that caused any of the FlowContainer's children to be put on a different line, it could repeatedly cause _resort to be called again, moving the children back and forth between the old and new lines.
This change is for FlowContainer::_resort to give a warning for TextureRects with EXPAND_FIT_* expand modes when multiple lines are used, and just keep the TextureRect size the same in that case.  This is similar to the check added to AspectRatioContainer in godotengine#73396, but attempting to still support it in FlowContainer when possible.  In the case where the TextureRect is forced to stay the same size, there may be some overlap between the FlowContainer's children, but should no longer crash.
											 
										 
										
											2024-07-12 16:57:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										bool  is_unsupported_texture_rect  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( lines_data . size ( )  >  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											TextureRect  * trect  =  Object : : cast_to < TextureRect > ( child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( trect )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												TextureRect : : ExpandMode  mode  =  trect - > get_expand_mode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( mode  = =  TextureRect : : EXPAND_FIT_WIDTH  | |  mode  = =  TextureRect : : EXPAND_FIT_WIDTH_PROPORTIONAL  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														mode  = =  TextureRect : : EXPAND_FIT_HEIGHT  | |  mode  = =  TextureRect : : EXPAND_FIT_HEIGHT_PROPORTIONAL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													is_unsupported_texture_rect  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( is_unsupported_texture_rect )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Temporary fix for editor crash. Changing size of TextureRect with EXPAND_FIT_* ExpandModes can lead to infinite loop if child items are moved between lines.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											WARN_PRINT_ONCE ( " TextureRects with Fit Expand Modes are currently not supported inside FlowContainers with multiple lines " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											child_size  =  child - > get_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  if  ( vertical )  {  /* VERTICAL */ 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_h_size_flags ( ) . has_flag ( SIZE_FILL )  | |  child - > get_h_size_flags ( ) . has_flag ( SIZE_SHRINK_CENTER )  | |  child - > get_h_size_flags ( ) . has_flag ( SIZE_SHRINK_END ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												child_size . width  =  line_data . min_line_height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_v_size_flags ( ) . has_flag ( SIZE_EXPAND ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												int  stretch  =  line_data . stretch_avail  *  child - > get_stretch_ratio ( )  /  line_data . stretch_ratio_total ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												child_size . height  + =  stretch ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  {  /* HORIZONTAL */ 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_v_size_flags ( ) . has_flag ( SIZE_FILL )  | |  child - > get_v_size_flags ( ) . has_flag ( SIZE_SHRINK_CENTER )  | |  child - > get_v_size_flags ( ) . has_flag ( SIZE_SHRINK_END ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												child_size . height  =  line_data . min_line_height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-07 20:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( child - > get_h_size_flags ( ) . has_flag ( SIZE_EXPAND ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												int  stretch  =  line_data . stretch_avail  *  child - > get_stretch_ratio ( )  /  line_data . stretch_ratio_total ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												child_size . width  + =  stretch ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Rect2  child_rect  =  Rect2 ( ofs ,  child_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 00:41:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( reverse_fill  & &  ! vertical )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											child_rect . position . y  =  get_rect ( ) . size . y  -  child_rect . position . y  -  child_rect . size . height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ( rtl  & &  ! vertical )  | |  ( ( rtl  ! =  reverse_fill )  & &  vertical ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											child_rect . position . x  =  get_rect ( ) . size . x  -  child_rect . position . x  -  child_rect . size . width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fit_child_in_rect ( child ,  child_rect ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( vertical )  {  /* VERTICAL */ 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ofs . y  + =  child_size . height  +  theme_cache . v_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}  else  {  /* HORIZONTAL */ 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 15:02:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ofs . x  + =  child_size . width  +  theme_cache . h_separation ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										child_idx_in_line + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									cached_size  =  ( vertical  ?  ofs . x  :  ofs . y )  +  line_height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									cached_line_count  =  lines_data . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Size2  FlowContainer : : get_minimum_size ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Size2i  minimum ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-08 18:35:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Control  * c  =  as_sortable_control ( get_child ( i ) ,  SortableVisbilityMode : : VISIBLE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  ( ! c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Size2i  size  =  c - > get_combined_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( vertical )  {  /* VERTICAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											minimum . height  =  MAX ( minimum . height ,  size . height ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											minimum . width  =  cached_size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  {  /* HORIZONTAL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											minimum . width  =  MAX ( minimum . width ,  size . width ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											minimum . height  =  cached_size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  minimum ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 23:53:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < int >  FlowContainer : : get_allowed_size_flags_horizontal ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < int >  flags ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! vertical )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										flags . append ( SIZE_EXPAND ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_BEGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_END ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  flags ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Vector < int >  FlowContainer : : get_allowed_size_flags_vertical ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < int >  flags ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( vertical )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										flags . append ( SIZE_EXPAND ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_BEGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									flags . append ( SIZE_SHRINK_END ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  flags ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  FlowContainer : : _notification ( int  p_what )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									switch  ( p_what )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_SORT_CHILDREN :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											_resort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											update_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 18:06:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_THEME_CHANGED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											update_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 18:06:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_TRANSLATION_CHANGED : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_LAYOUT_DIRECTION_CHANGED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											queue_sort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FlowContainer : : _validate_property ( PropertyInfo  & p_property )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( is_fixed  & &  p_property . name  = =  " vertical " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_property . usage  =  PROPERTY_USAGE_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								int  FlowContainer : : get_line_count ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  cached_line_count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FlowContainer : : set_alignment ( AlignmentMode  p_alignment )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( alignment  = =  p_alignment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									alignment  =  p_alignment ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_resort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FlowContainer : : AlignmentMode  FlowContainer : : get_alignment ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  alignment ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FlowContainer : : set_last_wrap_alignment ( LastWrapAlignmentMode  p_last_wrap_alignment )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( last_wrap_alignment  = =  p_last_wrap_alignment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									last_wrap_alignment  =  p_last_wrap_alignment ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_resort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FlowContainer : : LastWrapAlignmentMode  FlowContainer : : get_last_wrap_alignment ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  last_wrap_alignment ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FlowContainer : : set_vertical ( bool  p_vertical )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( is_fixed ,  " Can't change orientation of  "  +  get_class ( )  +  " . " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									vertical  =  p_vertical ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									update_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_resort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  FlowContainer : : is_vertical ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  vertical ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 00:41:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FlowContainer : : set_reverse_fill ( bool  p_reverse_fill )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( reverse_fill  = =  p_reverse_fill )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									reverse_fill  =  p_reverse_fill ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_resort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  FlowContainer : : is_reverse_fill ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  reverse_fill ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								FlowContainer : : FlowContainer ( bool  p_vertical )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									vertical  =  p_vertical ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  FlowContainer : : _bind_methods ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_line_count " ) ,  & FlowContainer : : get_line_count ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_alignment " ,  " alignment " ) ,  & FlowContainer : : set_alignment ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_alignment " ) ,  & FlowContainer : : get_alignment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_last_wrap_alignment " ,  " last_wrap_alignment " ) ,  & FlowContainer : : set_last_wrap_alignment ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_last_wrap_alignment " ) ,  & FlowContainer : : get_last_wrap_alignment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_vertical " ,  " vertical " ) ,  & FlowContainer : : set_vertical ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " is_vertical " ) ,  & FlowContainer : : is_vertical ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 00:41:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_reverse_fill " ,  " reverse_fill " ) ,  & FlowContainer : : set_reverse_fill ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " is_reverse_fill " ) ,  & FlowContainer : : is_reverse_fill ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( ALIGNMENT_BEGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( ALIGNMENT_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( ALIGNMENT_END ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( LAST_WRAP_ALIGNMENT_INHERIT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( LAST_WRAP_ALIGNMENT_BEGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( LAST_WRAP_ALIGNMENT_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( LAST_WRAP_ALIGNMENT_END ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 11:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : INT ,  " alignment " ,  PROPERTY_HINT_ENUM ,  " Begin,Center,End " ) ,  " set_alignment " ,  " get_alignment " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 11:31:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : INT ,  " last_wrap_alignment " ,  PROPERTY_HINT_ENUM ,  " Inherit,Begin,Center,End " ) ,  " set_last_wrap_alignment " ,  " get_last_wrap_alignment " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 13:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL ,  " vertical " ) ,  " set_vertical " ,  " is_vertical " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-29 00:41:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL ,  " reverse_fill " ) ,  " set_reverse_fill " ,  " is_reverse_fill " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-08 21:00:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_THEME_ITEM ( Theme : : DATA_TYPE_CONSTANT ,  FlowContainer ,  h_separation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_THEME_ITEM ( Theme : : DATA_TYPE_CONSTANT ,  FlowContainer ,  v_separation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-07 15:51:49 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}