BColorControl: Refactor _LayoutView()
In a few cases we were doing the work of _LayoutView() twice because we called _LayoutView() and then called ResizeToPreferred() which called _LayoutView() again. Now only call ResizeToPreferred() which calls _LayoutView().
This commit is contained in:
@@ -168,7 +168,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||||||
AddChild(fBlueText);
|
AddChild(fBlueText);
|
||||||
}
|
}
|
||||||
|
|
||||||
_LayoutView();
|
ResizeToPreferred();
|
||||||
|
|
||||||
if (useOffscreen) {
|
if (useOffscreen) {
|
||||||
BRect bounds = _PaletteFrame();
|
BRect bounds = _PaletteFrame();
|
||||||
@@ -199,9 +199,6 @@ BColorControl::_LayoutView()
|
|||||||
BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing);
|
BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing);
|
||||||
// frame including bevel
|
// frame including bevel
|
||||||
|
|
||||||
if (rect.Height() < fBlueText->Frame().bottom)
|
|
||||||
rect.bottom = fBlueText->Frame().bottom;
|
|
||||||
|
|
||||||
float offset = floorf(rect.bottom / 4);
|
float offset = floorf(rect.bottom / 4);
|
||||||
float y = offset;
|
float y = offset;
|
||||||
if (offset < _TextRectOffset()) {
|
if (offset < _TextRectOffset()) {
|
||||||
@@ -216,9 +213,6 @@ BColorControl::_LayoutView()
|
|||||||
|
|
||||||
y += offset;
|
y += offset;
|
||||||
fBlueText->MoveTo(rect.right + kTextFieldsHSpacing, y);
|
fBlueText->MoveTo(rect.right + kTextFieldsHSpacing, y);
|
||||||
|
|
||||||
ResizeTo(rect.Width() + kTextFieldsHSpacing + fRedText->Bounds().Width(),
|
|
||||||
rect.Height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -662,7 +656,6 @@ void
|
|||||||
BColorControl::SetCellSize(float size)
|
BColorControl::SetCellSize(float size)
|
||||||
{
|
{
|
||||||
_SetCellSize(size);
|
_SetCellSize(size);
|
||||||
_LayoutView();
|
|
||||||
ResizeToPreferred();
|
ResizeToPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,8 +693,6 @@ BColorControl::SetLayout(color_control_layout layout)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_LayoutView();
|
|
||||||
|
|
||||||
ResizeToPreferred();
|
ResizeToPreferred();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
@@ -877,9 +868,8 @@ BColorControl::GetPreferredSize(float* _width, float* _height)
|
|||||||
void
|
void
|
||||||
BColorControl::ResizeToPreferred()
|
BColorControl::ResizeToPreferred()
|
||||||
{
|
{
|
||||||
BControl::ResizeToPreferred();
|
|
||||||
|
|
||||||
_LayoutView();
|
_LayoutView();
|
||||||
|
BControl::ResizeToPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user