Make Area insets more consistent with other HAIKU inset APIs.

This commit is contained in:
Alex Wilson
2012-05-03 08:44:29 +12:00
parent b99cf18c18
commit 7dd17203c8
2 changed files with 66 additions and 0 deletions
+7
View File
@@ -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);
+59
View File
@@ -12,6 +12,7 @@
#include <Button.h>
#include <CheckBox.h>
#include <ControlLook.h>
#include <PictureButton.h>
#include <RadioButton.h>
#include <StatusBar.h>
@@ -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.
*/