mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 05:28:15 +08:00 
			
		
		
		
	Component decorators (#354)
Add decorator variants for decorator components Add the "pipe" operator for components, similar to what was done for Elements. We are able to put something like: ``` Button(...) | Maybe(&show_button) ``` Add decorators for: - `Maybe` - `CatchEvent` - `Renderer` Signed-off-by: Kefu Chai <tchaikov@gmail.com> Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
		@@ -66,6 +66,22 @@ Element operator|(Element element, Decorator decorator) {
 | 
			
		||||
  return decorator(std::move(element));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// @brief Apply a decorator to an element.
 | 
			
		||||
/// @return the decorated element.
 | 
			
		||||
/// @ingroup dom
 | 
			
		||||
///
 | 
			
		||||
/// ### Example
 | 
			
		||||
///
 | 
			
		||||
/// Both of these are equivalent:
 | 
			
		||||
/// ```cpp
 | 
			
		||||
/// auto element = text("Hello");
 | 
			
		||||
/// element |= bold;
 | 
			
		||||
/// ```
 | 
			
		||||
Element& operator|=(Element& e, Decorator d) {
 | 
			
		||||
  e = e | d;
 | 
			
		||||
  return e;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// The minimal dimension that will fit the given element.
 | 
			
		||||
/// @see Fixed
 | 
			
		||||
/// @see Full
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user