BColorControl: Introduce a _PaletteFrame() method

... eliminating duplicate code.
This commit is contained in:
John Scipione 2013-06-05 23:18:29 -04:00
parent abbd44acfb
commit 8b3b14fdfa
2 changed files with 12 additions and 9 deletions

View File

@ -100,6 +100,7 @@ private:
BRect updateRect); BRect updateRect);
BPoint _SelectorPosition(const BRect& rampRect, BPoint _SelectorPosition(const BRect& rampRect,
uint8 shade) const; uint8 shade) const;
BRect _PaletteFrame() 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); void _SetCellSize(float size);

View File

@ -170,9 +170,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
_LayoutView(); _LayoutView();
if (useOffscreen) { if (useOffscreen) {
BRect bounds = fPaletteFrame; BRect bounds = _PaletteFrame();
bounds.InsetBy(-kBevelSpacing, -kBevelSpacing);
fBitmap = new BBitmap(bounds, B_RGB32, true, false); fBitmap = new BBitmap(bounds, B_RGB32, true, false);
fOffscreenView = new BView(bounds, "off_view", 0, 0); fOffscreenView = new BView(bounds, "off_view", 0, 0);
@ -417,8 +415,7 @@ BColorControl::Draw(BRect updateRect)
void void
BColorControl::_DrawColorArea(BView* target, BRect updateRect) BColorControl::_DrawColorArea(BView* target, BRect updateRect)
{ {
BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing); BRect rect = _PaletteFrame();
// frame including bevel
bool enabled = IsEnabled(); bool enabled = IsEnabled();
rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
@ -601,6 +598,13 @@ BColorControl::_SelectorPosition(const BRect& rampRect, uint8 shade) const
} }
BRect
BColorControl::_PaletteFrame() const
{
return fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing);
}
BRect BRect
BColorControl::_RampFrame(uint8 rampIndex) const BColorControl::_RampFrame(uint8 rampIndex) const
{ {
@ -646,8 +650,7 @@ void
BColorControl::_InitOffscreen() BColorControl::_InitOffscreen()
{ {
if (fBitmap->Lock()) { if (fBitmap->Lock()) {
_DrawColorArea(fOffscreenView, _DrawColorArea(fOffscreenView, _PaletteFrame());
fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing));
fOffscreenView->Sync(); fOffscreenView->Sync();
fBitmap->Unlock(); fBitmap->Unlock();
} }
@ -853,8 +856,7 @@ BColorControl::DetachedFromWindow()
void void
BColorControl::GetPreferredSize(float* _width, float* _height) BColorControl::GetPreferredSize(float* _width, float* _height)
{ {
BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing); BRect rect = _PaletteFrame();
// bevel
if (rect.Height() < fBlueText->Frame().bottom) { if (rect.Height() < fBlueText->Frame().bottom) {
// adjust the height to fit // adjust the height to fit