diff --git a/headers/libs/alm/Area.h b/headers/libs/alm/Area.h index 88c331c7cf..c5be1aa588 100644 --- a/headers/libs/alm/Area.h +++ b/headers/libs/alm/Area.h @@ -90,10 +90,17 @@ public: void SetShrinkPenalties(BSize shrink); void SetGrowPenalties(BSize grow); + void GetInsets(float* left, float* top, float* right, + float* bottom) const; float LeftInset() const; float TopInset() const; float RightInset() const; float BottomInset() const; + + void SetInsets(float insets); + void SetInsets(float horizontal, float vertical); + void SetInsets(float left, float top, float right, + float bottom); void SetLeftInset(float left); void SetTopInset(float top); void SetRightInset(float right); diff --git a/src/libs/alm/Area.cpp b/src/libs/alm/Area.cpp index 5233371bd9..fb0d8edbf6 100644 --- a/src/libs/alm/Area.cpp +++ b/src/libs/alm/Area.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -327,6 +328,20 @@ Area::SetContentAspectRatio(double ratio) } +void +Area::GetInsets(float* left, float* top, float* right, float* bottom) const +{ + if (left) + *left = fTopLeftInset.Width(); + if (top) + *top = fTopLeftInset.Height(); + if (right) + *right = fRightBottomInset.Width(); + if (bottom) + *bottom = fRightBottomInset.Height(); +} + + /** * Gets left inset between area and its content. */ @@ -383,6 +398,50 @@ Area::BottomInset() const } +void +Area::SetInsets(float insets) +{ + if (insets != B_SIZE_UNSET) + insets = BControlLook::ComposeSpacing(insets); + + fTopLeftInset.Set(insets, insets); + fRightBottomInset.Set(insets, insets); + fLayoutItem->Layout()->InvalidateLayout(); +} + + +void +Area::SetInsets(float horizontal, float vertical) +{ + if (horizontal != B_SIZE_UNSET) + horizontal = BControlLook::ComposeSpacing(horizontal); + if (vertical != B_SIZE_UNSET) + vertical = BControlLook::ComposeSpacing(vertical); + + fTopLeftInset.Set(horizontal, horizontal); + fRightBottomInset.Set(vertical, vertical); + fLayoutItem->Layout()->InvalidateLayout(); +} + + +void +Area::SetInsets(float left, float top, float right, float bottom) +{ + if (left != B_SIZE_UNSET) + left = BControlLook::ComposeSpacing(left); + if (right != B_SIZE_UNSET) + right = BControlLook::ComposeSpacing(right); + if (top != B_SIZE_UNSET) + top = BControlLook::ComposeSpacing(top); + if (bottom != B_SIZE_UNSET) + bottom = BControlLook::ComposeSpacing(bottom); + + fTopLeftInset.Set(left, top); + fRightBottomInset.Set(right, bottom); + fLayoutItem->Layout()->InvalidateLayout(); +} + + /** * Sets left inset between area and its content. */