Appearance and Terminal: Move ColorPreview to shared

Move ColorListView and ColorItem to shared in BPrivate namespace.

ColorItem typedef to BPrivate::BColorItem for apps that are already
using this class.

Gravity screensaver:
* ColorItem => BColorItem.
* Use make_color() to set colors.

Make color drop message name agnostic, check for B_RGB_COLOR_TYPE.
Add be:sender and source to drag message.

Add _SetTermColors() convenience method to set colors on all tabs.

Change-Id: I5a9f55d3ab423ccaa341997cf444603373024553
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8846
Reviewed-by: John Scipione <[email protected]>
This commit is contained in:
John Scipione
2025-01-22 19:28:58 +00:00
committed by waddlesplash
parent 012d90c553
commit 622853ff8e
28 changed files with 694 additions and 1298 deletions
+21 -9
View File
@@ -1,10 +1,7 @@
/*
* Copyright 2016-2022 Haiku, Inc. All rights reserved.
* Copyright 2016-2024 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* John Scipione, [email protected]
*
* Based on ColorWhichItem by DarkWyrm ([email protected])
*/
#ifndef _COLOR_ITEM_H
@@ -15,17 +12,32 @@
#include <StringItem.h>
class ColorItem : public BStringItem {
namespace BPrivate {
class BColorItem : public BStringItem {
public:
ColorItem(const char* string, rgb_color color);
BColorItem(const char* text, rgb_color color);
BColorItem(const char* text, color_which which, rgb_color color);
virtual void DrawItem(BView* owner, BRect frame, bool complete);
void SetColor(rgb_color color) { fColor = color; }
rgb_color Color() const { return fColor; }
void SetColor(rgb_color color) { fColor = color; };
rgb_color Color() { return fColor; };
color_which ColorWhich() { return fColorWhich; };
private:
rgb_color fColor;
color_which fColorWhich;
};
#endif // _COLOR_ITEM_H
} // namespace BPrivate
// remove once apps have been updated to use BColorItem
typedef BPrivate::BColorItem ColorItem;
#endif // _COLOR_ITEM_H
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright 2016-2024 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm, [email protected]
* John Scipione, [email protected]
*/
#ifndef _COLOR_LIST_VIEW_H
#define _COLOR_LIST_VIEW_H
#include <ListView.h>
namespace BPrivate {
class BColorListView : public BListView {
public:
enum {
B_MESSAGE_SET_CURRENT_COLOR = 'sccl',
B_MESSAGE_SET_COLOR = 'sclr'
};
BColorListView(const char* name,
list_view_type type = B_SINGLE_SELECTION_LIST,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
virtual ~BColorListView();
virtual bool InitiateDrag(BPoint where, int32 index,
bool wasSelected);
virtual void MessageReceived(BMessage* message);
};
} // namespace BPrivate
#endif // _COLOR_LIST_VIEW_H
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright 2009-2024 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _COLOR_PREVIEW_H
#define _COLOR_PREVIEW_H
#include <Control.h>
class BMessage;
class BMessageRunner;
namespace BPrivate {
class BColorPreview : public BControl {
public:
BColorPreview(const char* name, const char* label,
BMessage* message, uint32 flags = B_WILL_DRAW);
virtual ~BColorPreview();
virtual void Draw(BRect updateRect);
virtual status_t Invoke(BMessage* message = NULL);
virtual void MessageReceived(BMessage *message);
virtual void MouseDown(BPoint where);
virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* message);
virtual void MouseUp(BPoint where);
rgb_color Color() const;
void SetColor(rgb_color color);
private:
void _DragColor(BPoint where);
rgb_color fColor;
BMessageRunner* fMessageRunner;
};
} // namespace BPrivate
#endif // _COLOR_PREVIEW_H