| 
									
										
										
										
											2023-08-19 13:56:36 +02:00
										 |  |  | // Copyright 2020 Arthur Sonzogni. All rights reserved.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be found in
 | 
					
						
							|  |  |  | // the LICENSE file.
 | 
					
						
							| 
									
										
										
										
											2019-01-06 17:10:35 +01:00
										 |  |  | #ifndef FTXUI_DOM_REQUIREMENT_HPP
 | 
					
						
							|  |  |  | #define FTXUI_DOM_REQUIREMENT_HPP
 | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-19 22:06:05 +01:00
										 |  |  | #include "ftxui/screen/box.hpp"
 | 
					
						
							| 
									
										
										
										
											2025-03-19 20:03:05 +05:30
										 |  |  | #include "ftxui/screen/screen.hpp"
 | 
					
						
							| 
									
										
										
										
											2019-01-19 22:06:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-12 15:00:08 +01:00
										 |  |  | namespace ftxui { | 
					
						
							| 
									
										
										
										
											2025-03-19 20:03:05 +05:30
										 |  |  | class Node; | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-05 11:35:14 +02:00
										 |  |  | /// @brief Requirement is a structure that defines the layout requirements for a
 | 
					
						
							|  |  |  | /// Node in the terminal user interface.
 | 
					
						
							|  |  |  | ///
 | 
					
						
							|  |  |  | /// It specifies the minimum size required to fully draw the element,
 | 
					
						
							|  |  |  | /// @ingroup dom
 | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | struct Requirement { | 
					
						
							| 
									
										
										
										
											2019-01-06 16:10:57 +01:00
										 |  |  |   // The required size to fully draw the element.
 | 
					
						
							| 
									
										
										
										
											2020-06-01 16:13:29 +02:00
										 |  |  |   int min_x = 0; | 
					
						
							|  |  |  |   int min_y = 0; | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-06 16:10:57 +01:00
										 |  |  |   // How much flexibility is given to the component.
 | 
					
						
							| 
									
										
										
										
											2020-06-01 23:40:32 +02:00
										 |  |  |   int flex_grow_x = 0; | 
					
						
							|  |  |  |   int flex_grow_y = 0; | 
					
						
							|  |  |  |   int flex_shrink_x = 0; | 
					
						
							|  |  |  |   int flex_shrink_y = 0; | 
					
						
							| 
									
										
										
										
											2019-01-19 22:06:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-01 16:13:29 +02:00
										 |  |  |   // Focus management to support the frame/focus/select element.
 | 
					
						
							| 
									
										
										
										
											2025-03-19 20:03:05 +05:30
										 |  |  |   struct Focused { | 
					
						
							|  |  |  |     bool enabled = false; | 
					
						
							|  |  |  |     Box box; | 
					
						
							|  |  |  |     Node* node = nullptr; | 
					
						
							|  |  |  |     Screen::Cursor::Shape cursor_shape = Screen::Cursor::Shape::Hidden; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Internal for interactions with components.
 | 
					
						
							|  |  |  |     bool component_active = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Return whether this requirement should be preferred over the other.
 | 
					
						
							|  |  |  |     bool Prefer(const Focused& other) const { | 
					
						
							|  |  |  |       if (!other.enabled) { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (!enabled) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return other.component_active && !component_active; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-01 16:13:29 +02:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2025-03-19 20:03:05 +05:30
										 |  |  |   Focused focused; | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-23 21:26:00 +01:00
										 |  |  | }  // namespace ftxui
 | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-31 02:17:43 +02:00
										 |  |  | #endif  // FTXUI_DOM_REQUIREMENT_HPP
 |