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);
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);

View File

@ -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