* Always draw entire ColorWell to avoid flickering

* Moved ColorWell infront of ColorPicker. It was hidden behinde the attribute list.
* Made ColorWell and ColorPicker follow its parent frame bottom when resized.
* Made attribute list follows its parent frame top and bottom when resized. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27344 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2008-09-06 09:13:16 +00:00
parent 19a1d666b3
commit 7b1c4ba38f
3 changed files with 49 additions and 28 deletions
+24 -16
View File
@@ -122,10 +122,10 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
rect.right -= B_V_SCROLL_BAR_WIDTH; rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom = rect.top + 75; rect.bottom = rect.top + 75;
fAttrList = new BListView(rect,"AttributeList", B_SINGLE_SELECTION_LIST, fAttrList = new BListView(rect,"AttributeList", B_SINGLE_SELECTION_LIST,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); B_FOLLOW_ALL_SIDES);
fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_LEFT_RIGHT | fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_ALL_SIDES,
B_FOLLOW_TOP, 0, false, true); 0, false, true);
AddChild(fScrollView); AddChild(fScrollView);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -137,23 +137,31 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
printf("Adding color item for which: %ld\n", sColorConsts[i]); printf("Adding color item for which: %ld\n", sColorConsts[i]);
fAttrList->AddItem(new ColorWhichItem((color_which)sColorConsts[i])); fAttrList->AddItem(new ColorWhichItem((color_which)sColorConsts[i]));
} }
BRect wellrect(0,0,50,50);
wellrect.OffsetTo(rect.right + 30, rect.top +
(fScrollView->Bounds().Height() - wellrect.Height())/2 );
fColorWell = new ColorWell(wellrect,new BMessage(COLOR_DROPPED),true);
AddChild(fColorWell);
// Center the list and color well
rect = fScrollView->Frame(); rect = fScrollView->Frame();
rect.right = wellrect.right; BRect wellrect(0, 0, 50, 50);
rect.OffsetTo((Bounds().Width()-rect.Width())/2,rect.top); wellrect.OffsetBy(rect.left, rect.bottom + kBorderSpace);
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED),
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fColorWell);
fPicker = new BColorControl(BPoint(fScrollView->Frame().left,fScrollView->Frame().bottom+kBorderSpace),B_CELLS_32x8,5.0,"fPicker", fPicker = new BColorControl(BPoint(wellrect.right + kBorderSpace, wellrect.top),
new BMessage(UPDATE_COLOR)); B_CELLS_32x8, 5.0, "fPicker", new BMessage(UPDATE_COLOR));
fPicker->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fPicker); AddChild(fPicker);
// bottom align ColorWell and ColorPicker
float bottom = Bounds().bottom - kBorderSpace;
float colorWellBottom = fColorWell->Frame().bottom;
float pickerBottom = fPicker->Frame().bottom;
float delta = bottom - max_c(colorWellBottom, pickerBottom);
fColorWell->MoveBy(0, delta);
fPicker->MoveBy(0, delta);
fScrollView->ResizeBy(0, delta);
// TODO fix BView::ResizeBy(...):
// the child views should resize with its parent view (fScrollView)
fScrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, delta);
fAttrList->ResizeBy(0, delta);
} }
APRView::~APRView(void) APRView::~APRView(void)
+22 -11
View File
@@ -7,10 +7,10 @@
*/ */
#include "ColorWell.h" #include "ColorWell.h"
ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle) ColorWell::ColorWell(BRect frame, BMessage *msg, uint32 resizingMode, uint32 flags)
: BView(frame,"ColorWell", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW) : BView(frame,"ColorWell", resizingMode, flags | B_WILL_DRAW)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0,0,0); SetLowColor(0,0,0);
invoker=new BInvoker(msg,this); invoker=new BInvoker(msg,this);
disabledcol.red=128; disabledcol.red=128;
@@ -18,7 +18,7 @@ ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle)
disabledcol.blue=128; disabledcol.blue=128;
disabledcol.alpha=255; disabledcol.alpha=255;
is_enabled=true; is_enabled=true;
is_rect=is_rectangle; is_rect = true;
} }
ColorWell::~ColorWell(void) ColorWell::~ColorWell(void)
@@ -84,20 +84,20 @@ ColorWell::SetEnabled(bool value)
void void
ColorWell::Draw(BRect update) ColorWell::Draw(BRect update)
{ {
if(is_enabled) rgb_color color;
SetHighColor(currentcol); if (is_enabled)
color = currentcol;
else else
SetHighColor(disabledcol); color = disabledcol;
if(is_rect) { if(is_rect) {
FillRect(Bounds());
if(is_enabled) { if(is_enabled) {
BRect r(Bounds()); BRect r(Bounds());
SetHighColor(184,184,184); SetHighColor(184,184,184);
StrokeRect(r); StrokeRect(r);
SetHighColor(255,255,255); SetHighColor(255,255,255);
StrokeLine(BPoint(r.right,r.top+1), r.RightBottom()); StrokeLine(BPoint(r.right, r.top+1), r.RightBottom());
r.InsetBy(1,1); r.InsetBy(1,1);
@@ -107,10 +107,21 @@ ColorWell::Draw(BRect update)
SetHighColor(96,96,96); SetHighColor(96,96,96);
StrokeLine(r.LeftTop(), r.RightTop()); StrokeLine(r.LeftTop(), r.RightTop());
StrokeLine(r.LeftTop(), r.LeftBottom()); StrokeLine(r.LeftTop(), r.LeftBottom());
r.InsetBy(1, 1);
SetHighColor(color);
FillRect(r);
} else {
SetHighColor(color);
FillRect(Bounds());
} }
} }
else { else {
// fill background
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
FillRect(update);
SetHighColor(color);
FillEllipse(Bounds()); FillEllipse(Bounds());
if(is_enabled) if(is_enabled)
StrokeEllipse(Bounds(),B_SOLID_LOW); StrokeEllipse(Bounds(),B_SOLID_LOW);
+3 -1
View File
@@ -15,7 +15,9 @@
class ColorWell : public BView class ColorWell : public BView
{ {
public: public:
ColorWell(BRect frame, BMessage *msg, bool is_rectangle=false); ColorWell(BRect frame, BMessage *msg,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
~ColorWell(void); ~ColorWell(void);
void SetColor(rgb_color col); void SetColor(rgb_color col);
rgb_color Color(void) const; rgb_color Color(void) const;