* Add new spacing/inset constants for the layout API. For now, leave B_USE_DEFAULT_SPACING, but this will go soon.

* Rename BControlLook::ComposeItemSpacing() to ComposeSpacing(), and extend it to handle the new constants.
* Adjust users of BControlLook::ComposeItemSpacing() accordingly.
* part of #7447


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42025 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alex Wilson 2011-06-07 20:40:56 +00:00
parent 0bae414087
commit 6648dd3cf1
7 changed files with 47 additions and 23 deletions

View File

@ -79,7 +79,8 @@ public:
/* TODO: virtual*/
float DefaultItemSpacing() const;
static float ComposeItemSpacing(float spacing);
static float ComposeSpacing(float spacing);
uint32 Flags(BControl* control) const;

View File

@ -223,7 +223,23 @@ enum vertical_alignment {
B_ALIGN_USE_FULL_HEIGHT = -2L
};
const float B_USE_DEFAULT_SPACING = -2.0f;
// Layout spacing and insets, see BControlLook::ComposeSpacing()
enum {
B_USE_DEFAULT_SPACING = -2,
B_USE_ITEM_SPACING = -2,
B_USE_ITEM_INSETS = -2,
B_USE_HALF_ITEM_SPACING = -3,
B_USE_HALF_ITEM_INSETS = -3,
B_USE_WINDOW_INSETS = -4,
B_USE_WINDOW_SPACING = -4,
B_USE_SMALL_INSETS = -5,
B_USE_SMALL_SPACING = -5,
B_USE_BIG_INSETS = -6,
B_USE_BIG_SPACING = -6
};
// Line join and cap modes

View File

@ -51,14 +51,21 @@ BControlLook::DefaultItemSpacing() const
float
BControlLook::ComposeItemSpacing(float spacing)
BControlLook::ComposeSpacing(float spacing)
{
if (spacing != B_USE_DEFAULT_SPACING)
return spacing;
if (be_control_look)
// We only need to check one of each synonym (B_*_SPACING | B_*_INSETS)
if (spacing == B_USE_ITEM_SPACING) {
return be_control_look->DefaultItemSpacing();
return 0;
} else if (spacing == B_USE_HALF_ITEM_SPACING) {
return be_control_look->DefaultItemSpacing() * 0.5f;
} else if (spacing == B_USE_WINDOW_INSETS) {
return be_control_look->DefaultItemSpacing();
} else if (spacing == B_USE_SMALL_SPACING) {
return be_control_look->DefaultItemSpacing() * 0.7f;
} else if (spacing == B_USE_BIG_SPACING) {
return be_control_look->DefaultItemSpacing() * 1.3f;
}
return spacing;
}

View File

@ -253,7 +253,7 @@ BGridLayout::VerticalSpacing() const
void
BGridLayout::SetHorizontalSpacing(float spacing)
{
spacing = BControlLook::ComposeItemSpacing(spacing);
spacing = BControlLook::ComposeSpacing(spacing);
if (spacing != fHSpacing) {
fHSpacing = spacing;
@ -265,7 +265,7 @@ BGridLayout::SetHorizontalSpacing(float spacing)
void
BGridLayout::SetVerticalSpacing(float spacing)
{
spacing = BControlLook::ComposeItemSpacing(spacing);
spacing = BControlLook::ComposeSpacing(spacing);
if (spacing != fVSpacing) {
fVSpacing = spacing;
@ -277,8 +277,8 @@ BGridLayout::SetVerticalSpacing(float spacing)
void
BGridLayout::SetSpacing(float horizontal, float vertical)
{
horizontal = BControlLook::ComposeItemSpacing(horizontal);
vertical = BControlLook::ComposeItemSpacing(vertical);
horizontal = BControlLook::ComposeSpacing(horizontal);
vertical = BControlLook::ComposeSpacing(vertical);
if (horizontal != fHSpacing || vertical != fVSpacing) {
fHSpacing = horizontal;
fVSpacing = vertical;

View File

@ -68,7 +68,7 @@ BGroupLayout::Spacing() const
void
BGroupLayout::SetSpacing(float spacing)
{
spacing = BControlLook::ComposeItemSpacing(spacing);
spacing = BControlLook::ComposeSpacing(spacing);
if (spacing != fHSpacing) {
fHSpacing = spacing;
fVSpacing = spacing;

View File

@ -162,7 +162,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
fTopInset(0),
fBottomInset(0),
fSplitterSize(6),
fSpacing(BControlLook::ComposeItemSpacing(spacing)),
fSpacing(BControlLook::ComposeSpacing(spacing)),
fSplitterItems(),
fVisibleItems(),
@ -268,10 +268,10 @@ BSplitLayout::~BSplitLayout()
void
BSplitLayout::SetInsets(float left, float top, float right, float bottom)
{
fLeftInset = BControlLook::ComposeItemSpacing(left);
fTopInset = BControlLook::ComposeItemSpacing(top);
fRightInset = BControlLook::ComposeItemSpacing(right);
fBottomInset = BControlLook::ComposeItemSpacing(bottom);
fLeftInset = BControlLook::ComposeSpacing(left);
fTopInset = BControlLook::ComposeSpacing(top);
fRightInset = BControlLook::ComposeSpacing(right);
fBottomInset = BControlLook::ComposeSpacing(bottom);
InvalidateLayout();
}
@ -302,7 +302,7 @@ BSplitLayout::Spacing() const
void
BSplitLayout::SetSpacing(float spacing)
{
spacing = BControlLook::ComposeItemSpacing(spacing);
spacing = BControlLook::ComposeSpacing(spacing);
if (spacing != fSpacing) {
fSpacing = spacing;

View File

@ -285,10 +285,10 @@ void
BTwoDimensionalLayout::SetInsets(float left, float top, float right,
float bottom)
{
fLeftInset = BControlLook::ComposeItemSpacing(left);
fTopInset = BControlLook::ComposeItemSpacing(top);
fRightInset = BControlLook::ComposeItemSpacing(right);
fBottomInset = BControlLook::ComposeItemSpacing(bottom);
fLeftInset = BControlLook::ComposeSpacing(left);
fTopInset = BControlLook::ComposeSpacing(top);
fRightInset = BControlLook::ComposeSpacing(right);
fBottomInset = BControlLook::ComposeSpacing(bottom);
InvalidateLayout();
}