- Minor fixes to my last BColorControl patch

- Changed Backgrounds preflet to account for the fixes in BColorControl

First commit :) Hi everybody!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23680 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexandre Deckner
2008-01-21 11:54:53 +00:00
parent 731262c6dd
commit 68c0d50c01
2 changed files with 18 additions and 11 deletions
+12 -5
View File
@@ -64,6 +64,9 @@ void
BColorControl::_InitData(color_control_layout layout, float size, BColorControl::_InitData(color_control_layout layout, float size,
bool useOffscreen, BMessage* archive) bool useOffscreen, BMessage* archive)
{ {
fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8;
//TODO: we don't support workspace and colorspace changing for now
// 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)); fCellSize = ceil(max_c(kMinCellSize, size));
@@ -140,7 +143,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
BRect bounds = fPaletteFrame; BRect bounds = fPaletteFrame;
bounds.InsetBy(-2.0f, -2.0f); bounds.InsetBy(-2.0f, -2.0f);
fBitmap = new BBitmap(bounds, /*BScreen(Window()).ColorSpace()*/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);
fBitmap->Lock(); fBitmap->Lock();
@@ -156,11 +159,17 @@ BColorControl::_InitData(color_control_layout layout, float size,
void void
BColorControl::_LayoutView() BColorControl::_LayoutView()
{ {
if (fPaletteMode){
fPaletteFrame.Set(2.0f, 2.0f,
float(fColumns) * fCellSize + 2.0,
float(fRows) * fCellSize + 2.0);
} else {
fPaletteFrame.Set(2.0f, 2.0f, fPaletteFrame.Set(2.0f, 2.0f,
float(fColumns) * fCellSize + 2.0, float(fColumns) * fCellSize + 2.0,
float(fRows) * fCellSize + 2.0 - 1.0); float(fRows) * fCellSize + 2.0 - 1.0);
//1 pixel adjust so that the inner space //1 pixel adjust so that the inner space
//has exactly rows*cellsize pixels in height //has exactly rows*cellsize pixels in height
}
BRect rect = fPaletteFrame.InsetByCopy(-2.0,-2.0); //bevel BRect rect = fPaletteFrame.InsetByCopy(-2.0,-2.0); //bevel
@@ -341,8 +350,6 @@ BColorControl::SetEnabled(bool enabled)
void void
BColorControl::AttachedToWindow() BColorControl::AttachedToWindow()
{ {
fPaletteMode = BScreen(Window()).ColorSpace() == B_CMAP8;
if (Parent()) if (Parent())
SetViewColor(Parent()->ViewColor()); SetViewColor(Parent()->ViewColor());
else else
@@ -551,9 +558,9 @@ BColorControl::_SelectorPosition(const BRect& rampRect, uint8 shade) const
BRect BRect
BColorControl::_RampFrame(uint8 rampIndex) const BColorControl::_RampFrame(uint8 rampIndex) const
{ {
float rampHeight = fPaletteFrame.Height() / 4; float rampHeight = float(fRows) * fCellSize / 4.0f;
return BRect(fPaletteFrame.left, return BRect( fPaletteFrame.left,
fPaletteFrame.top + float(rampIndex) * rampHeight, fPaletteFrame.top + float(rampIndex) * rampHeight,
fPaletteFrame.right, fPaletteFrame.right,
fPaletteFrame.top + float(rampIndex + 1) * rampHeight); fPaletteFrame.top + float(rampIndex + 1) * rampHeight);
@@ -216,7 +216,7 @@ BackgroundsView::BackgroundsView(BRect frame, const char *name, int32 resize,
rightbox->AddChild(fIconLabelOutline); rightbox->AddChild(fIconLabelOutline);
rect.top += fIconLabelOutline->Bounds().Height() + 15; rect.top += fIconLabelOutline->Bounds().Height() + 15;
fPicker = new BColorControl(BPoint(10, rect.top), B_CELLS_32x8, 5.0, "Picker", fPicker = new BColorControl(BPoint(10, rect.top), B_CELLS_32x8, 7.0, "Picker",
new BMessage(kMsgUpdateColor)); new BMessage(kMsgUpdateColor));
rightbox->AddChild(fPicker); rightbox->AddChild(fPicker);