ActivityMonitor (when used as replicant) :
* Use the "Icon Label Outline" setting to improve readability * It is using the same algorithm as Tracker to outline and glow the text, and determine the color of the text. Implements enhancement suggestion #5105. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35084 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d4ffeadd1a
commit
bb7cffd0d1
@ -19,10 +19,12 @@
|
||||
#include <Autolock.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Dragger.h>
|
||||
#include <fs_attr.h>
|
||||
#include <MenuItem.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Shape.h>
|
||||
#include <StorageKit.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "ActivityMonitor.h"
|
||||
@ -174,6 +176,7 @@ const uint32 kMsgUpdateResolution = 'ures';
|
||||
|
||||
extern const char* kSignature;
|
||||
|
||||
const char* kDesktopAttrName = "be:bgndimginfo";
|
||||
|
||||
Scale::Scale(scale_type type)
|
||||
:
|
||||
@ -540,6 +543,10 @@ ActivityView::LegendLayoutItem::BaseAlignment()
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
const rgb_color kWhite = (rgb_color){255, 255, 255, 255};
|
||||
const rgb_color kBlack = (rgb_color){0, 0, 0, 255};
|
||||
|
||||
|
||||
ActivityView::ActivityView(BRect frame, const char* name,
|
||||
const BMessage* settings, uint32 resizingMode)
|
||||
: BView(frame, name, resizingMode,
|
||||
@ -588,6 +595,7 @@ ActivityView::ActivityView(BMessage* archive)
|
||||
|
||||
ActivityView::~ActivityView()
|
||||
{
|
||||
stop_watching(this);
|
||||
delete fOffscreen;
|
||||
delete fSystemInfoHandler;
|
||||
}
|
||||
@ -879,6 +887,9 @@ ActivityView::RemoveAllDataSources()
|
||||
void
|
||||
ActivityView::AttachedToWindow()
|
||||
{
|
||||
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
|
||||
_LoadBackgroundInfo(true);
|
||||
|
||||
Looper()->AddHandler(fSystemInfoHandler);
|
||||
fSystemInfoHandler->StartWatching();
|
||||
|
||||
@ -1097,6 +1108,17 @@ ActivityView::MessageReceived(BMessage* message)
|
||||
ActivityMonitor::ShowAbout();
|
||||
break;
|
||||
|
||||
case B_NODE_MONITOR:
|
||||
{
|
||||
BString attrName;
|
||||
if (message->FindString("attr", &attrName) == B_OK) {
|
||||
if (attrName == kDesktopAttrName)
|
||||
_LoadBackgroundInfo(false);
|
||||
} else
|
||||
_LoadBackgroundInfo(false);
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgUpdateResolution:
|
||||
{
|
||||
int32 resolution;
|
||||
@ -1413,6 +1435,37 @@ ActivityView::_UpdateResolution(int32 resolution, bool broadcast)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ActivityView::_LoadBackgroundInfo(bool watch)
|
||||
{
|
||||
fCachedOutline = false;
|
||||
fCachedWorkspace = -1;
|
||||
BPath path;
|
||||
if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) {
|
||||
BNode desktopNode = BNode(path.Path());
|
||||
|
||||
attr_info info;
|
||||
if (desktopNode.GetAttrInfo(kDesktopAttrName, &info) != B_OK)
|
||||
return;
|
||||
|
||||
char *buffer = new char[info.size];
|
||||
if (desktopNode.ReadAttr(kDesktopAttrName, B_MESSAGE_TYPE, 0,
|
||||
buffer, (size_t)info.size) == info.size) {
|
||||
BMessage message;
|
||||
if (message.Unflatten(buffer) == B_OK)
|
||||
fBackgroundInfo = message;
|
||||
}
|
||||
delete[] buffer;
|
||||
|
||||
if (watch) {
|
||||
node_ref nref;
|
||||
desktopNode.GetNodeRef(&nref);
|
||||
watch_node(&nref, B_WATCH_ATTR, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ActivityView::Draw(BRect updateRect)
|
||||
{
|
||||
@ -1467,12 +1520,83 @@ ActivityView::Draw(BRect updateRect)
|
||||
if (drawBackground)
|
||||
SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
|
||||
else {
|
||||
rgb_color c = Parent()->ViewColor();
|
||||
rgb_color textColor = c.red + c.green * 1.5f + c.blue * 0.50f
|
||||
>= 300 ? kBlack : kWhite;
|
||||
|
||||
int32 mask;
|
||||
bool tmpOutline = false;
|
||||
bool outline = fCachedOutline;
|
||||
int8 indice = 0;
|
||||
|
||||
if (fCachedWorkspace != current_workspace()) {
|
||||
while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
|
||||
indice, &mask) == B_OK
|
||||
&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
|
||||
indice, &tmpOutline) == B_OK) {
|
||||
if (((1 << current_workspace()) & mask) != 0) {
|
||||
outline = tmpOutline;
|
||||
fCachedWorkspace = current_workspace();
|
||||
fCachedOutline = outline;
|
||||
break;
|
||||
}
|
||||
indice++;
|
||||
}
|
||||
}
|
||||
|
||||
if (outline) {
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
||||
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
if (textColor == kBlack) {
|
||||
// Black text with white halo/glow
|
||||
rgb_color glowColor = kWhite;
|
||||
|
||||
font.SetFalseBoldWidth(2.0);
|
||||
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 30;
|
||||
SetHighColor(glowColor);
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
|
||||
font.SetFalseBoldWidth(1.0);
|
||||
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 65;
|
||||
SetHighColor(glowColor);
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
|
||||
font.SetFalseBoldWidth(0.0);
|
||||
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
} else {
|
||||
// white text with black outline
|
||||
rgb_color outlineColor = kBlack;
|
||||
|
||||
font.SetFalseBoldWidth(1.0);
|
||||
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
outlineColor.alpha = 30;
|
||||
SetHighColor(outlineColor);
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
|
||||
font.SetFalseBoldWidth(0.0);
|
||||
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
outlineColor.alpha = 200;
|
||||
SetHighColor(outlineColor);
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right + 1,
|
||||
y + 1));
|
||||
DrawString(text.String(), BPoint(frame.right - width + 1,
|
||||
y + 1));
|
||||
}
|
||||
}
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
rgb_color c = Parent()->LowColor();
|
||||
if (c.red + c.green + c.blue > 128 * 3)
|
||||
SetHighColor(0, 0, 0);
|
||||
else
|
||||
SetHighColor(255, 255, 255);
|
||||
SetHighColor(textColor);
|
||||
}
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <map>
|
||||
|
||||
#include <Locker.h>
|
||||
#include <Message.h>
|
||||
#include <ObjectList.h>
|
||||
#include <View.h>
|
||||
|
||||
@ -113,6 +114,7 @@ private:
|
||||
void _DrawHistory(bool drawBackground);
|
||||
void _UpdateResolution(int32 resolution,
|
||||
bool broadcast = true);
|
||||
void _LoadBackgroundInfo(bool watch);
|
||||
|
||||
private:
|
||||
class HistoryLayoutItem;
|
||||
@ -128,6 +130,11 @@ private:
|
||||
BLayoutItem* fHistoryLayoutItem;
|
||||
BLayoutItem* fLegendLayoutItem;
|
||||
#endif
|
||||
|
||||
BMessage fBackgroundInfo;
|
||||
bool fCachedOutline;
|
||||
int32 fCachedWorkspace;
|
||||
|
||||
mutable BLocker fSourcesLock;
|
||||
BObjectList<DataSource> fSources;
|
||||
BObjectList<DataHistory> fValues;
|
||||
|
Loading…
Reference in New Issue
Block a user