hrev45318 adds 1 changeset to branch 'master' old head: ca00f398da7f8cd19698205769fdf8cb6f2bde83 new head: 2c765fafc57141bcb456fc0005b4dbf61d12df22 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=2c765fa+%5Eca00f39 ---------------------------------------------------------------------------- 2c765fa: Rename ColorWell to ColorPreview in Appearance prefs. No functional change intended. I'd like to use the name "ColorWell" for a different type of class eventually so I'm making room for it. ColorPreview is arguably a better name for the class anyway. Also did a style cleanup of the ColorWell => ColorPreview class at the same time. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev45318 Commit: 2c765fafc57141bcb456fc0005b4dbf61d12df22 URL: http://cgit.haiku-os.org/haiku/commit/?id=2c765fa Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Feb 23 20:51:50 2013 UTC ---------------------------------------------------------------------------- 7 files changed, 214 insertions(+), 193 deletions(-) src/preferences/appearance/APRView.cpp | 18 +-- src/preferences/appearance/APRView.h | 7 +- src/preferences/appearance/ColorPreview.cpp | 153 ++++++++++++++++++++++++ src/preferences/appearance/ColorPreview.h | 47 ++++++++ src/preferences/appearance/ColorWell.cpp | 141 ---------------------- src/preferences/appearance/ColorWell.h | 36 ------ src/preferences/appearance/Jamfile | 5 +- ---------------------------------------------------------------------------- diff --git a/src/preferences/appearance/APRView.cpp b/src/preferences/appearance/APRView.cpp index 33b59d5..6b7c1e0 100644 --- a/src/preferences/appearance/APRView.cpp +++ b/src/preferences/appearance/APRView.cpp @@ -25,9 +25,9 @@ #include "APRWindow.h" #include "defs.h" -#include "ColorWell.h" -#include "ColorWhichItem.h" +#include "ColorPreview.h" #include "ColorSet.h" +#include "ColorWhichItem.h" #undef B_TRANSLATION_CONTEXT @@ -87,8 +87,8 @@ APRView::APRView(const char* name) } BRect wellrect(0, 0, 50, 50); - fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED), 0); - fColorWell->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, + fColorPreview = new ColorPreview(wellrect, new BMessage(COLOR_DROPPED), 0); + fColorPreview->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_BOTTOM)); fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0, @@ -100,14 +100,14 @@ APRView::APRView(const char* name) .Add(fScrollView) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BGroupLayoutBuilder(B_HORIZONTAL) - .Add(fColorWell) + .Add(fColorPreview) .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) .Add(fPicker) ) .SetInsets(10, 10, 10, 10) ); - fColorWell->Parent()->SetExplicitMaxSize( + fColorPreview->Parent()->SetExplicitMaxSize( BSize(B_SIZE_UNSET, fPicker->Bounds().Height())); fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN)); } @@ -123,7 +123,7 @@ APRView::AttachedToWindow() { fPicker->SetTarget(this); fAttrList->SetTarget(this); - fColorWell->SetTarget(this); + fColorPreview->SetTarget(this); fAttrList->Select(0); } @@ -257,8 +257,8 @@ APRView::_UpdateControls() } fPicker->SetValue(color); - fColorWell->SetColor(color); - fColorWell->Invalidate(); + fColorPreview->SetColor(color); + fColorPreview->Invalidate(); } diff --git a/src/preferences/appearance/APRView.h b/src/preferences/appearance/APRView.h index 1cfd600..41b65cd 100644 --- a/src/preferences/appearance/APRView.h +++ b/src/preferences/appearance/APRView.h @@ -31,9 +31,8 @@ #include "ColorSet.h" -class ColorWell; class APRWindow; - +class ColorPreview; class APRView : public BView { public: @@ -65,11 +64,11 @@ private: BScrollView* fScrollView; - ColorWell* fColorWell; + ColorPreview* fColorPreview; ColorSet fCurrentSet; ColorSet fPrevSet; ColorSet fDefaultSet; }; -#endif +#endif // APR_VIEW_H_ diff --git a/src/preferences/appearance/ColorPreview.cpp b/src/preferences/appearance/ColorPreview.cpp new file mode 100644 index 0000000..81ce2bf --- /dev/null +++ b/src/preferences/appearance/ColorPreview.cpp @@ -0,0 +1,153 @@ +/* + * Copyright 2002-2013 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm, darkwyrm@xxxxxxxxxxxxx + * John Scipione, jscipione@xxxxxxxxx + */ + + +#include "ColorPreview.h" + + +ColorPreview::ColorPreview(BRect frame, BMessage* message, + uint32 resizingMode, uint32 flags) + : + BView(frame,"ColorPreview", resizingMode, flags | B_WILL_DRAW) +{ + SetViewColor(B_TRANSPARENT_COLOR); + SetLowColor(0, 0, 0); + invoker = new BInvoker(message, this); + disabledcol.red = 128; + disabledcol.green = 128; + disabledcol.blue = 128; + disabledcol.alpha = 255; + is_enabled = true; + is_rect = true; +} + + +ColorPreview::~ColorPreview(void) +{ + delete invoker; +} + + +void +ColorPreview::Draw(BRect update) +{ + rgb_color color; + if (is_enabled) + color = currentcol; + else + color = disabledcol; + + if (is_rect) { + 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()); + + r.InsetBy(1, 1); + + SetHighColor(216, 216, 216); + StrokeLine(r.RightTop(), r.RightBottom()); + + 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); + } +} + + +void +ColorPreview::MessageReceived(BMessage* message) +{ + // If we received a dropped message, see if it contains color data + if (message->WasDropped()) { + rgb_color* col; + uint8* ptr; + ssize_t size; + if (message->FindData("RGBColor", (type_code)'RGBC', + (const void**)&ptr,&size) == B_OK) { + col = (rgb_color*)ptr; + SetHighColor(*col); + } + } + + BView::MessageReceived(message); +} + + +void +ColorPreview::SetEnabled(bool value) +{ + if (is_enabled != value) { + is_enabled = value; + Invalidate(); + } +} + + +void +ColorPreview::SetTarget(BHandler* target) +{ + invoker->SetTarget(target); +} + + +rgb_color +ColorPreview::Color(void) const +{ + return currentcol; +} + + +void +ColorPreview::SetColor(rgb_color col) +{ + SetHighColor(col); + currentcol = col; + Draw(Bounds()); + invoker->Invoke(); +} + + +void +ColorPreview::SetColor(uint8 r,uint8 g, uint8 b) +{ + SetHighColor(r,g,b); + currentcol.red = r; + currentcol.green = g; + currentcol.blue = b; + Draw(Bounds()); + invoker->Invoke(); +} + + +void +ColorPreview::SetMode(bool is_rectangle) +{ + is_rect = is_rectangle; +} diff --git a/src/preferences/appearance/ColorPreview.h b/src/preferences/appearance/ColorPreview.h new file mode 100644 index 0000000..a293e40 --- /dev/null +++ b/src/preferences/appearance/ColorPreview.h @@ -0,0 +1,47 @@ +/* + * Copyright 2002-2013 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm, darkwyrm@xxxxxxxxxxxxx + * John Scipione, jscipione@xxxxxxxxx + */ +#ifndef COLOR_PREVIEW_H_ +#define COLOR_PREVIEW_H_ + + +#include <View.h> +#include <Message.h> +#include <Invoker.h> + + +class ColorPreview : public BView +{ +public: + ColorPreview(BRect frame, BMessage *msg, + uint32 resizingMode = B_FOLLOW_LEFT + | B_FOLLOW_TOP, + uint32 flags = B_WILL_DRAW); + ~ColorPreview(void); + + virtual void Draw(BRect update); + virtual void MessageReceived(BMessage* message); + virtual void SetTarget(BHandler* target); + virtual void SetEnabled(bool value); + + rgb_color Color(void) const; + void SetColor(rgb_color col); + void SetColor(uint8 r,uint8 g, uint8 b); + + void SetMode(bool is_rectangle); + +protected: + BInvoker* invoker; + + bool is_enabled; + bool is_rect; + rgb_color disabledcol; + rgb_color currentcol; +}; + +#endif // COLOR_PREVIEW_H_ diff --git a/src/preferences/appearance/ColorWell.cpp b/src/preferences/appearance/ColorWell.cpp deleted file mode 100644 index 2a5e5ea..0000000 --- a/src/preferences/appearance/ColorWell.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2002-2006, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm (darkwyrm@xxxxxxxxxxxxx) - */ -#include "ColorWell.h" - -ColorWell::ColorWell(BRect frame, BMessage *msg, uint32 resizingMode, uint32 flags) - : BView(frame,"ColorWell", resizingMode, flags | B_WILL_DRAW) -{ - SetViewColor(B_TRANSPARENT_COLOR); - SetLowColor(0,0,0); - invoker=new BInvoker(msg,this); - disabledcol.red=128; - disabledcol.green=128; - disabledcol.blue=128; - disabledcol.alpha=255; - is_enabled=true; - is_rect = true; -} - -ColorWell::~ColorWell(void) -{ - delete invoker; -} - -void -ColorWell::SetTarget(BHandler *tgt) -{ - invoker->SetTarget(tgt); -} - -void -ColorWell::SetColor(rgb_color col) -{ - SetHighColor(col); - currentcol=col; - Draw(Bounds()); - invoker->Invoke(); -} - -void -ColorWell::SetColor(uint8 r,uint8 g, uint8 b) -{ - SetHighColor(r,g,b); - currentcol.red=r; - currentcol.green=g; - currentcol.blue=b; - Draw(Bounds()); - invoker->Invoke(); -} - -void -ColorWell::MessageReceived(BMessage *msg) -{ - // If we received a dropped message, try to see if it has color data - // in it - if(msg->WasDropped()) { - rgb_color *col; - uint8 *ptr; - ssize_t size; - if(msg->FindData("RGBColor",(type_code)'RGBC', - (const void**)&ptr,&size)==B_OK) { - col=(rgb_color*)ptr; - SetHighColor(*col); - } - } - - // The default - BView::MessageReceived(msg); -} - -void -ColorWell::SetEnabled(bool value) -{ - if(is_enabled!=value) { - is_enabled=value; - Invalidate(); - } -} - -void -ColorWell::Draw(BRect update) -{ - rgb_color color; - if (is_enabled) - color = currentcol; - else - color = disabledcol; - - if(is_rect) { - 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()); - - r.InsetBy(1,1); - - SetHighColor(216,216,216); - StrokeLine(r.RightTop(), r.RightBottom()); - - 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); - } -} - -rgb_color -ColorWell::Color(void) const -{ - return currentcol; -} - -void -ColorWell::SetMode(bool is_rectangle) -{ - is_rect=is_rectangle; -} diff --git a/src/preferences/appearance/ColorWell.h b/src/preferences/appearance/ColorWell.h deleted file mode 100644 index 92c2ea5..0000000 --- a/src/preferences/appearance/ColorWell.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2006, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm (darkwyrm@xxxxxxxxxxxxx) - */ -#ifndef COLORWELL_H_ -#define COLORWELL_H_ - -#include <View.h> -#include <Message.h> -#include <Invoker.h> - -class ColorWell : public BView -{ -public: - 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; - void SetColor(uint8 r,uint8 g, uint8 b); - virtual void MessageReceived(BMessage *msg); - virtual void Draw(BRect update); - virtual void SetTarget(BHandler *tgt); - virtual void SetEnabled(bool value); - void SetMode(bool is_rectangle); -protected: - BInvoker *invoker; - bool is_enabled, is_rect; - rgb_color disabledcol, currentcol; -}; - -#endif diff --git a/src/preferences/appearance/Jamfile b/src/preferences/appearance/Jamfile index 1c287a9..ca3eb7d 100644 --- a/src/preferences/appearance/Jamfile +++ b/src/preferences/appearance/Jamfile @@ -15,8 +15,8 @@ Preference Appearance : FontView.cpp APRView.cpp APRWindow.cpp + ColorPreview.cpp ColorSet.cpp - ColorWell.cpp ColorWhichItem.cpp # These are currently disabled while everything else is being worked on @@ -38,11 +38,10 @@ DoCatalogs Appearance : AntialiasingSettingsView.cpp APRView.cpp APRWindow.cpp + ColorPreview.cpp ColorSet.cpp - ColorWell.cpp ColorWhichItem.cpp LookAndFeelSettingsView.cpp FontView.cpp FontSelectionView.cpp ; -