* 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.bottom = rect.top + 75;
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 |
B_FOLLOW_TOP, 0, false, true);
fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_ALL_SIDES,
0, false, true);
AddChild(fScrollView);
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]);
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.right = wellrect.right;
rect.OffsetTo((Bounds().Width()-rect.Width())/2,rect.top);
BRect wellrect(0, 0, 50, 50);
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",
new BMessage(UPDATE_COLOR));
fPicker = new BColorControl(BPoint(wellrect.right + kBorderSpace, wellrect.top),
B_CELLS_32x8, 5.0, "fPicker", new BMessage(UPDATE_COLOR));
fPicker->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
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)
+22 -11
View File
@@ -7,10 +7,10 @@
*/
#include "ColorWell.h"
ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle)
: BView(frame,"ColorWell", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW)
ColorWell::ColorWell(BRect frame, BMessage *msg, uint32 resizingMode, uint32 flags)
: BView(frame,"ColorWell", resizingMode, flags | B_WILL_DRAW)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0,0,0);
invoker=new BInvoker(msg,this);
disabledcol.red=128;
@@ -18,7 +18,7 @@ ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle)
disabledcol.blue=128;
disabledcol.alpha=255;
is_enabled=true;
is_rect=is_rectangle;
is_rect = true;
}
ColorWell::~ColorWell(void)
@@ -84,20 +84,20 @@ ColorWell::SetEnabled(bool value)
void
ColorWell::Draw(BRect update)
{
if(is_enabled)
SetHighColor(currentcol);
rgb_color color;
if (is_enabled)
color = currentcol;
else
SetHighColor(disabledcol);
color = disabledcol;
if(is_rect) {
FillRect(Bounds());
if(is_enabled) {
BRect r(Bounds());
SetHighColor(184,184,184);
StrokeRect(r);
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);
@@ -107,10 +107,21 @@ ColorWell::Draw(BRect update)
SetHighColor(96,96,96);
StrokeLine(r.LeftTop(), r.RightTop());
StrokeLine(r.LeftTop(), r.LeftBottom());
r.InsetBy(1, 1);
SetHighColor(color);
FillRect(r);
} else {
SetHighColor(color);
FillRect(Bounds());
}
}
else {
// fill background
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
FillRect(update);
SetHighColor(color);
FillEllipse(Bounds());
if(is_enabled)
StrokeEllipse(Bounds(),B_SOLID_LOW);
+3 -1
View File
@@ -15,7 +15,9 @@
class ColorWell : public BView
{
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);
void SetColor(rgb_color col);
rgb_color Color(void) const;