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.
This commit is contained in:
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "ColorWell.h"
|
#include "ColorPreview.h"
|
||||||
#include "ColorWhichItem.h"
|
|
||||||
#include "ColorSet.h"
|
#include "ColorSet.h"
|
||||||
|
#include "ColorWhichItem.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
@@ -87,8 +87,8 @@ APRView::APRView(const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BRect wellrect(0, 0, 50, 50);
|
BRect wellrect(0, 0, 50, 50);
|
||||||
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED), 0);
|
fColorPreview = new ColorPreview(wellrect, new BMessage(COLOR_DROPPED), 0);
|
||||||
fColorWell->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
|
fColorPreview->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
|
||||||
B_ALIGN_BOTTOM));
|
B_ALIGN_BOTTOM));
|
||||||
|
|
||||||
fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0,
|
fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0,
|
||||||
@@ -100,14 +100,14 @@ APRView::APRView(const char* name)
|
|||||||
.Add(fScrollView)
|
.Add(fScrollView)
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
.Add(fColorWell)
|
.Add(fColorPreview)
|
||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
||||||
.Add(fPicker)
|
.Add(fPicker)
|
||||||
)
|
)
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(10, 10, 10, 10)
|
||||||
);
|
);
|
||||||
|
|
||||||
fColorWell->Parent()->SetExplicitMaxSize(
|
fColorPreview->Parent()->SetExplicitMaxSize(
|
||||||
BSize(B_SIZE_UNSET, fPicker->Bounds().Height()));
|
BSize(B_SIZE_UNSET, fPicker->Bounds().Height()));
|
||||||
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ APRView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
fPicker->SetTarget(this);
|
fPicker->SetTarget(this);
|
||||||
fAttrList->SetTarget(this);
|
fAttrList->SetTarget(this);
|
||||||
fColorWell->SetTarget(this);
|
fColorPreview->SetTarget(this);
|
||||||
|
|
||||||
fAttrList->Select(0);
|
fAttrList->Select(0);
|
||||||
}
|
}
|
||||||
@@ -257,8 +257,8 @@ APRView::_UpdateControls()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fPicker->SetValue(color);
|
fPicker->SetValue(color);
|
||||||
fColorWell->SetColor(color);
|
fColorPreview->SetColor(color);
|
||||||
fColorWell->Invalidate();
|
fColorPreview->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,8 @@
|
|||||||
#include "ColorSet.h"
|
#include "ColorSet.h"
|
||||||
|
|
||||||
|
|
||||||
class ColorWell;
|
|
||||||
class APRWindow;
|
class APRWindow;
|
||||||
|
class ColorPreview;
|
||||||
|
|
||||||
class APRView : public BView {
|
class APRView : public BView {
|
||||||
public:
|
public:
|
||||||
@@ -65,11 +64,11 @@ private:
|
|||||||
|
|
||||||
BScrollView* fScrollView;
|
BScrollView* fScrollView;
|
||||||
|
|
||||||
ColorWell* fColorWell;
|
ColorPreview* fColorPreview;
|
||||||
|
|
||||||
ColorSet fCurrentSet;
|
ColorSet fCurrentSet;
|
||||||
ColorSet fPrevSet;
|
ColorSet fPrevSet;
|
||||||
ColorSet fDefaultSet;
|
ColorSet fDefaultSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // APR_VIEW_H_
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2013 Haiku Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* DarkWyrm, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2013 Haiku Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* DarkWyrm, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
|
*/
|
||||||
|
#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_
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* DarkWyrm ([email protected])
|
|
||||||
*/
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* DarkWyrm ([email protected])
|
|
||||||
*/
|
|
||||||
#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
|
|
||||||
@@ -15,8 +15,8 @@ Preference Appearance :
|
|||||||
FontView.cpp
|
FontView.cpp
|
||||||
APRView.cpp
|
APRView.cpp
|
||||||
APRWindow.cpp
|
APRWindow.cpp
|
||||||
|
ColorPreview.cpp
|
||||||
ColorSet.cpp
|
ColorSet.cpp
|
||||||
ColorWell.cpp
|
|
||||||
ColorWhichItem.cpp
|
ColorWhichItem.cpp
|
||||||
|
|
||||||
# These are currently disabled while everything else is being worked on
|
# These are currently disabled while everything else is being worked on
|
||||||
@@ -38,11 +38,10 @@ DoCatalogs Appearance :
|
|||||||
AntialiasingSettingsView.cpp
|
AntialiasingSettingsView.cpp
|
||||||
APRView.cpp
|
APRView.cpp
|
||||||
APRWindow.cpp
|
APRWindow.cpp
|
||||||
|
ColorPreview.cpp
|
||||||
ColorSet.cpp
|
ColorSet.cpp
|
||||||
ColorWell.cpp
|
|
||||||
ColorWhichItem.cpp
|
ColorWhichItem.cpp
|
||||||
LookAndFeelSettingsView.cpp
|
LookAndFeelSettingsView.cpp
|
||||||
FontView.cpp
|
FontView.cpp
|
||||||
FontSelectionView.cpp
|
FontSelectionView.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user