* 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:
@@ -79,7 +79,8 @@ public:
|
|||||||
|
|
||||||
/* TODO: virtual*/
|
/* TODO: virtual*/
|
||||||
float DefaultItemSpacing() const;
|
float DefaultItemSpacing() const;
|
||||||
static float ComposeItemSpacing(float spacing);
|
|
||||||
|
static float ComposeSpacing(float spacing);
|
||||||
|
|
||||||
uint32 Flags(BControl* control) const;
|
uint32 Flags(BControl* control) const;
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,23 @@ enum vertical_alignment {
|
|||||||
B_ALIGN_USE_FULL_HEIGHT = -2L
|
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
|
// Line join and cap modes
|
||||||
|
|||||||
@@ -51,14 +51,21 @@ BControlLook::DefaultItemSpacing() const
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BControlLook::ComposeItemSpacing(float spacing)
|
BControlLook::ComposeSpacing(float spacing)
|
||||||
{
|
{
|
||||||
if (spacing != B_USE_DEFAULT_SPACING)
|
// We only need to check one of each synonym (B_*_SPACING | B_*_INSETS)
|
||||||
return spacing;
|
if (spacing == B_USE_ITEM_SPACING) {
|
||||||
|
|
||||||
if (be_control_look)
|
|
||||||
return be_control_look->DefaultItemSpacing();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ BGridLayout::VerticalSpacing() const
|
|||||||
void
|
void
|
||||||
BGridLayout::SetHorizontalSpacing(float spacing)
|
BGridLayout::SetHorizontalSpacing(float spacing)
|
||||||
{
|
{
|
||||||
spacing = BControlLook::ComposeItemSpacing(spacing);
|
spacing = BControlLook::ComposeSpacing(spacing);
|
||||||
if (spacing != fHSpacing) {
|
if (spacing != fHSpacing) {
|
||||||
fHSpacing = spacing;
|
fHSpacing = spacing;
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ BGridLayout::SetHorizontalSpacing(float spacing)
|
|||||||
void
|
void
|
||||||
BGridLayout::SetVerticalSpacing(float spacing)
|
BGridLayout::SetVerticalSpacing(float spacing)
|
||||||
{
|
{
|
||||||
spacing = BControlLook::ComposeItemSpacing(spacing);
|
spacing = BControlLook::ComposeSpacing(spacing);
|
||||||
if (spacing != fVSpacing) {
|
if (spacing != fVSpacing) {
|
||||||
fVSpacing = spacing;
|
fVSpacing = spacing;
|
||||||
|
|
||||||
@@ -277,8 +277,8 @@ BGridLayout::SetVerticalSpacing(float spacing)
|
|||||||
void
|
void
|
||||||
BGridLayout::SetSpacing(float horizontal, float vertical)
|
BGridLayout::SetSpacing(float horizontal, float vertical)
|
||||||
{
|
{
|
||||||
horizontal = BControlLook::ComposeItemSpacing(horizontal);
|
horizontal = BControlLook::ComposeSpacing(horizontal);
|
||||||
vertical = BControlLook::ComposeItemSpacing(vertical);
|
vertical = BControlLook::ComposeSpacing(vertical);
|
||||||
if (horizontal != fHSpacing || vertical != fVSpacing) {
|
if (horizontal != fHSpacing || vertical != fVSpacing) {
|
||||||
fHSpacing = horizontal;
|
fHSpacing = horizontal;
|
||||||
fVSpacing = vertical;
|
fVSpacing = vertical;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ BGroupLayout::Spacing() const
|
|||||||
void
|
void
|
||||||
BGroupLayout::SetSpacing(float spacing)
|
BGroupLayout::SetSpacing(float spacing)
|
||||||
{
|
{
|
||||||
spacing = BControlLook::ComposeItemSpacing(spacing);
|
spacing = BControlLook::ComposeSpacing(spacing);
|
||||||
if (spacing != fHSpacing) {
|
if (spacing != fHSpacing) {
|
||||||
fHSpacing = spacing;
|
fHSpacing = spacing;
|
||||||
fVSpacing = spacing;
|
fVSpacing = spacing;
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
|||||||
fTopInset(0),
|
fTopInset(0),
|
||||||
fBottomInset(0),
|
fBottomInset(0),
|
||||||
fSplitterSize(6),
|
fSplitterSize(6),
|
||||||
fSpacing(BControlLook::ComposeItemSpacing(spacing)),
|
fSpacing(BControlLook::ComposeSpacing(spacing)),
|
||||||
|
|
||||||
fSplitterItems(),
|
fSplitterItems(),
|
||||||
fVisibleItems(),
|
fVisibleItems(),
|
||||||
@@ -268,10 +268,10 @@ BSplitLayout::~BSplitLayout()
|
|||||||
void
|
void
|
||||||
BSplitLayout::SetInsets(float left, float top, float right, float bottom)
|
BSplitLayout::SetInsets(float left, float top, float right, float bottom)
|
||||||
{
|
{
|
||||||
fLeftInset = BControlLook::ComposeItemSpacing(left);
|
fLeftInset = BControlLook::ComposeSpacing(left);
|
||||||
fTopInset = BControlLook::ComposeItemSpacing(top);
|
fTopInset = BControlLook::ComposeSpacing(top);
|
||||||
fRightInset = BControlLook::ComposeItemSpacing(right);
|
fRightInset = BControlLook::ComposeSpacing(right);
|
||||||
fBottomInset = BControlLook::ComposeItemSpacing(bottom);
|
fBottomInset = BControlLook::ComposeSpacing(bottom);
|
||||||
|
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ BSplitLayout::Spacing() const
|
|||||||
void
|
void
|
||||||
BSplitLayout::SetSpacing(float spacing)
|
BSplitLayout::SetSpacing(float spacing)
|
||||||
{
|
{
|
||||||
spacing = BControlLook::ComposeItemSpacing(spacing);
|
spacing = BControlLook::ComposeSpacing(spacing);
|
||||||
if (spacing != fSpacing) {
|
if (spacing != fSpacing) {
|
||||||
fSpacing = spacing;
|
fSpacing = spacing;
|
||||||
|
|
||||||
|
|||||||
@@ -285,10 +285,10 @@ void
|
|||||||
BTwoDimensionalLayout::SetInsets(float left, float top, float right,
|
BTwoDimensionalLayout::SetInsets(float left, float top, float right,
|
||||||
float bottom)
|
float bottom)
|
||||||
{
|
{
|
||||||
fLeftInset = BControlLook::ComposeItemSpacing(left);
|
fLeftInset = BControlLook::ComposeSpacing(left);
|
||||||
fTopInset = BControlLook::ComposeItemSpacing(top);
|
fTopInset = BControlLook::ComposeSpacing(top);
|
||||||
fRightInset = BControlLook::ComposeItemSpacing(right);
|
fRightInset = BControlLook::ComposeSpacing(right);
|
||||||
fBottomInset = BControlLook::ComposeItemSpacing(bottom);
|
fBottomInset = BControlLook::ComposeSpacing(bottom);
|
||||||
|
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user