1 /* 2 * Copyright 2006-2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LAYOUT_UTILS_H 6 #define _LAYOUT_UTILS_H 7 8 9 #include <Alignment.h> 10 #include <Rect.h> 11 #include <Size.h> 12 #include <String.h> 13 14 15 class BLayoutItem; 16 class BView; 17 18 19 class BLayoutUtils { 20 public: 21 // static float AddSizesFloat(float a, float b); 22 // static float AddSizesFloat(float a, float b, float c); 23 static float AddDistances(float a, float b); 24 static float AddDistances(float a, float b, float c); 25 static int32 AddSizesInt32(int32 a, int32 b); 26 static int32 AddSizesInt32(int32 a, int32 b, int32 c); 27 // static float SubtractSizesFloat(float a, float b); 28 static int32 SubtractSizesInt32(int32 a, int32 b); 29 static float SubtractDistances(float a, float b); 30 31 static void FixSizeConstraints(float& min, float& max, 32 float& preferred); 33 static void FixSizeConstraints(BSize& min, BSize& max, 34 BSize& preferred); 35 36 static BSize ComposeSize(BSize size, BSize layoutSize); 37 static BAlignment ComposeAlignment(BAlignment alignment, 38 BAlignment layoutAlignment); 39 40 static BRect AlignInFrame(BRect frame, BSize maxSize, 41 BAlignment alignment); 42 static void AlignInFrame(BView* view, BRect frame); 43 static BRect AlignOnRect(BRect rect, BSize size, BAlignment alignment); 44 static BRect MoveIntoFrame(BRect rect, BSize frameSize); 45 46 // debugging 47 static BString GetLayoutTreeDump(BView* view); 48 static BString GetLayoutTreeDump(BLayoutItem* item); 49 50 private: 51 static void _GetLayoutTreeDump(BView* view, int level, 52 BString& _output); 53 static void _GetLayoutTreeDump(BLayoutItem* item, 54 int level, bool isViewLayout, 55 BString& _output); 56 }; 57 58 #endif // _LAYOUT_UTILS_H 59