| 
									
										
										
										
											2019-07-01 17:17:32 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-03 07:55:22 +02:00
										 |  |  | #include <AK/AKString.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-01 17:17:32 +02:00
										 |  |  | class Length { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     enum class Type { | 
					
						
							|  |  |  |         Auto, | 
					
						
							|  |  |  |         Absolute, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Length() {} | 
					
						
							|  |  |  |     Length(int value, Type type) | 
					
						
							|  |  |  |         : m_type(type) | 
					
						
							|  |  |  |         , m_value(value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ~Length() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_auto() const { return m_type == Type::Auto; } | 
					
						
							|  |  |  |     bool is_absolute() const { return m_type == Type::Absolute; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int value() const { return m_value; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-03 07:55:22 +02:00
										 |  |  |     String to_string() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (is_auto()) | 
					
						
							|  |  |  |             return "auto"; | 
					
						
							|  |  |  |         return String::format("%d [Length/Absolute]", m_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-24 07:34:07 +02:00
										 |  |  |     int to_px() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (is_auto()) | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         return m_value; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-01 17:17:32 +02:00
										 |  |  | private: | 
					
						
							|  |  |  |     Type m_type { Type::Auto }; | 
					
						
							|  |  |  |     int m_value { 0 }; | 
					
						
							|  |  |  | }; |