From 1186916f06ee1662d1708603ef40704b8d2abedb Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 31 May 2013 00:43:15 -0400 Subject: [PATCH] BColorControl: Create _SetCellSize() method ...eliminating duplicated code. --- headers/os/interface/ColorControl.h | 3 ++- src/kits/interface/ColorControl.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/headers/os/interface/ColorControl.h b/headers/os/interface/ColorControl.h index 647a30aae3..83900982ef 100644 --- a/headers/os/interface/ColorControl.h +++ b/headers/os/interface/ColorControl.h @@ -102,7 +102,8 @@ private: uint8 shade) const; BRect _PaletteSelectorFrame(uint8 colorIndex) const; BRect _RampFrame(uint8 rampIndex) const; - + void _SetCellSize(float size); + private: BRect fPaletteFrame; int16 fSelectedPaletteColorIndex; diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index c9edb40269..ad450cca22 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -84,7 +84,8 @@ BColorControl::_InitData(color_control_layout layout, float size, // so we take the main_screen colorspace at startup fColumns = layout; fRows = 256 / fColumns; - fCellSize = ceil(max_c(kMinCellSize, size)); + + _SetCellSize(size); fSelectedPaletteColorIndex = -1; fPreviousSelectedPaletteColorIndex = -1; @@ -611,6 +612,13 @@ BColorControl::_RampFrame(uint8 rampIndex) const } +void +BColorControl::_SetCellSize(float size) +{ + fCellSize = ceilf(max_c(kMinCellSize, size)); +} + + BRect BColorControl::_PaletteSelectorFrame(uint8 colorIndex) const { @@ -635,9 +643,9 @@ BColorControl::_InitOffscreen() void -BColorControl::SetCellSize(float cellSide) +BColorControl::SetCellSize(float size) { - fCellSize = ceil(max_c(kMinCellSize, cellSide)); + _SetCellSize(size); _LayoutView(); ResizeToPreferred(); }