haiku/headers/os/interface/LayoutUtils.h
John Scipione e439b00397 Fix button label position, try number 2
Create and use BLayoutUtils::AlignOnRect() to position the button label
in BControlLook::DrawLabel().

AlignOnRect(), unlike AlignInFrame(), provides the possibility to return
a rectangle with dimensions greater than the available size.

Add some comments above the methods in LayoutUtils that indicate such.

Also update copyright headers in LayoutUtils and ControlLook
2014-04-08 14:10:10 -04:00

59 lines
1.8 KiB
C++

/*
* Copyright 2006-2014 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_UTILS_H
#define _LAYOUT_UTILS_H
#include <Alignment.h>
#include <Rect.h>
#include <Size.h>
#include <String.h>
class BLayoutItem;
class BView;
class BLayoutUtils {
public:
// static float AddSizesFloat(float a, float b);
// static float AddSizesFloat(float a, float b, float c);
static float AddDistances(float a, float b);
static float AddDistances(float a, float b, float c);
static int32 AddSizesInt32(int32 a, int32 b);
static int32 AddSizesInt32(int32 a, int32 b, int32 c);
// static float SubtractSizesFloat(float a, float b);
static int32 SubtractSizesInt32(int32 a, int32 b);
static float SubtractDistances(float a, float b);
static void FixSizeConstraints(float& min, float& max,
float& preferred);
static void FixSizeConstraints(BSize& min, BSize& max,
BSize& preferred);
static BSize ComposeSize(BSize size, BSize layoutSize);
static BAlignment ComposeAlignment(BAlignment alignment,
BAlignment layoutAlignment);
static BRect AlignInFrame(BRect frame, BSize maxSize,
BAlignment alignment);
static void AlignInFrame(BView* view, BRect frame);
static BRect AlignOnRect(BRect rect, BSize size, BAlignment alignment);
static BRect MoveIntoFrame(BRect rect, BSize frameSize);
// debugging
static BString GetLayoutTreeDump(BView* view);
static BString GetLayoutTreeDump(BLayoutItem* item);
private:
static void _GetLayoutTreeDump(BView* view, int level,
BString& _output);
static void _GetLayoutTreeDump(BLayoutItem* item,
int level, bool isViewLayout,
BString& _output);
};
#endif // _LAYOUT_UTILS_H