From 8b3b14fdfa14986ac57f083e427b8e0ae7d6fe4b Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 5 Jun 2013 23:18:29 -0400 Subject: [PATCH] BColorControl: Introduce a _PaletteFrame() method ... eliminating duplicate code. --- headers/os/interface/ColorControl.h | 1 + src/kits/interface/ColorControl.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/headers/os/interface/ColorControl.h b/headers/os/interface/ColorControl.h index a0d7cd0faa..6875ee2506 100644 --- a/headers/os/interface/ColorControl.h +++ b/headers/os/interface/ColorControl.h @@ -100,6 +100,7 @@ private: BRect updateRect); BPoint _SelectorPosition(const BRect& rampRect, uint8 shade) const; + BRect _PaletteFrame() const; BRect _PaletteSelectorFrame(uint8 colorIndex) const; BRect _RampFrame(uint8 rampIndex) const; void _SetCellSize(float size); diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index f5bf69d083..7c144f9acd 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -170,9 +170,7 @@ BColorControl::_InitData(color_control_layout layout, float size, _LayoutView(); if (useOffscreen) { - BRect bounds = fPaletteFrame; - bounds.InsetBy(-kBevelSpacing, -kBevelSpacing); - + BRect bounds = _PaletteFrame(); fBitmap = new BBitmap(bounds, B_RGB32, true, false); fOffscreenView = new BView(bounds, "off_view", 0, 0); @@ -417,8 +415,7 @@ BColorControl::Draw(BRect updateRect) void BColorControl::_DrawColorArea(BView* target, BRect updateRect) { - BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing); - // frame including bevel + BRect rect = _PaletteFrame(); bool enabled = IsEnabled(); 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 BColorControl::_RampFrame(uint8 rampIndex) const { @@ -646,8 +650,7 @@ void BColorControl::_InitOffscreen() { if (fBitmap->Lock()) { - _DrawColorArea(fOffscreenView, - fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing)); + _DrawColorArea(fOffscreenView, _PaletteFrame()); fOffscreenView->Sync(); fBitmap->Unlock(); } @@ -853,8 +856,7 @@ BColorControl::DetachedFromWindow() void BColorControl::GetPreferredSize(float* _width, float* _height) { - BRect rect = fPaletteFrame.InsetByCopy(-kBevelSpacing, -kBevelSpacing); - // bevel + BRect rect = _PaletteFrame(); if (rect.Height() < fBlueText->Frame().bottom) { // adjust the height to fit