BColorControl: Create _SetCellSize() method

...eliminating duplicated code.
This commit is contained in:
John Scipione
2013-06-10 19:15:07 -04:00
parent 0289f92063
commit 1186916f06
2 changed files with 13 additions and 4 deletions
+1
View File
@@ -102,6 +102,7 @@ private:
uint8 shade) const; uint8 shade) const;
BRect _PaletteSelectorFrame(uint8 colorIndex) const; BRect _PaletteSelectorFrame(uint8 colorIndex) const;
BRect _RampFrame(uint8 rampIndex) const; BRect _RampFrame(uint8 rampIndex) const;
void _SetCellSize(float size);
private: private:
BRect fPaletteFrame; BRect fPaletteFrame;
+11 -3
View File
@@ -84,7 +84,8 @@ BColorControl::_InitData(color_control_layout layout, float size,
// so we take the main_screen colorspace at startup // so we take the main_screen colorspace at startup
fColumns = layout; fColumns = layout;
fRows = 256 / fColumns; fRows = 256 / fColumns;
fCellSize = ceil(max_c(kMinCellSize, size));
_SetCellSize(size);
fSelectedPaletteColorIndex = -1; fSelectedPaletteColorIndex = -1;
fPreviousSelectedPaletteColorIndex = -1; fPreviousSelectedPaletteColorIndex = -1;
@@ -611,6 +612,13 @@ BColorControl::_RampFrame(uint8 rampIndex) const
} }
void
BColorControl::_SetCellSize(float size)
{
fCellSize = ceilf(max_c(kMinCellSize, size));
}
BRect BRect
BColorControl::_PaletteSelectorFrame(uint8 colorIndex) const BColorControl::_PaletteSelectorFrame(uint8 colorIndex) const
{ {
@@ -635,9 +643,9 @@ BColorControl::_InitOffscreen()
void void
BColorControl::SetCellSize(float cellSide) BColorControl::SetCellSize(float size)
{ {
fCellSize = ceil(max_c(kMinCellSize, cellSide)); _SetCellSize(size);
_LayoutView(); _LayoutView();
ResizeToPreferred(); ResizeToPreferred();
} }