Outline of labels/strings drawn to desktop
* Rather than duplicating the decision taking logic involving wheter or not to draw the outline or glow in every replicant, update be_control_look to make it more generic. * The Monitoring of the background preferences is now only done in Tracker (where it was already being done). * Add a BControlLook::B_IGNORE_OUTLINE flag to avoid this new behaviour. * Remove that said logic from ActivityMonitor and use be_control_look. * Use the ignore flag in DeskCalc to avoid the outline in its case. Should fix #7716, #7291.
This commit is contained in:
@@ -70,6 +70,7 @@ public:
|
||||
B_HOVER = 1 << 3,
|
||||
B_DISABLED = 1 << 4,
|
||||
B_DEFAULT_BUTTON = 1 << 5,
|
||||
B_IGNORE_OUTLINE = 1 << 6,
|
||||
|
||||
B_BLEND_FRAME = 1 << 16
|
||||
};
|
||||
@@ -271,6 +272,8 @@ public:
|
||||
const rgb_color& base, uint32 flags,
|
||||
const BPoint& where);
|
||||
|
||||
void SetBackgroundInfo(BMessage msg);
|
||||
|
||||
protected:
|
||||
void _DrawButtonFrame(BView* view, BRect& rect,
|
||||
const BRect& updateRect,
|
||||
@@ -362,6 +365,11 @@ protected:
|
||||
const rgb_color& bevelTopColor,
|
||||
const rgb_color& bevelRightColor,
|
||||
const BGradientLinear& fillGradient);
|
||||
private:
|
||||
bool fCachedOutline;
|
||||
int32 fCachedWorkspace;
|
||||
BMessage fBackgroundInfo;
|
||||
|
||||
};
|
||||
|
||||
extern BControlLook* be_control_look;
|
||||
|
||||
@@ -20,12 +20,10 @@
|
||||
#include <Bitmap.h>
|
||||
#include <Catalog.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"
|
||||
@@ -179,7 +177,6 @@ const uint32 kMsgUpdateResolution = 'ures';
|
||||
|
||||
extern const char* kSignature;
|
||||
|
||||
const char* kDesktopAttrName = "be:bgndimginfo";
|
||||
|
||||
Scale::Scale(scale_type type)
|
||||
:
|
||||
@@ -599,7 +596,6 @@ ActivityView::ActivityView(BMessage* archive)
|
||||
|
||||
ActivityView::~ActivityView()
|
||||
{
|
||||
stop_watching(this);
|
||||
delete fOffscreen;
|
||||
delete fSystemInfoHandler;
|
||||
}
|
||||
@@ -891,9 +887,6 @@ ActivityView::RemoveAllDataSources()
|
||||
void
|
||||
ActivityView::AttachedToWindow()
|
||||
{
|
||||
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
|
||||
_LoadBackgroundInfo(true);
|
||||
|
||||
Looper()->AddHandler(fSystemInfoHandler);
|
||||
fSystemInfoHandler->StartWatching();
|
||||
|
||||
@@ -1114,17 +1107,6 @@ 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;
|
||||
@@ -1446,37 +1428,6 @@ 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)
|
||||
{
|
||||
@@ -1533,87 +1484,16 @@ 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);
|
||||
SetHighColor(textColor);
|
||||
if (be_control_look == NULL) {
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
} else {
|
||||
be_control_look->DrawLabel(this, label.String(),
|
||||
Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y));
|
||||
be_control_look->DrawLabel(this, text.String(),
|
||||
Parent()->ViewColor(), 0, BPoint(frame.right - width, y));
|
||||
}
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ private:
|
||||
void _DrawHistory(bool drawBackground);
|
||||
void _UpdateResolution(int32 resolution,
|
||||
bool broadcast = true);
|
||||
void _LoadBackgroundInfo(bool watch);
|
||||
|
||||
private:
|
||||
class HistoryLayoutItem;
|
||||
@@ -131,10 +130,6 @@ private:
|
||||
BLayoutItem* fLegendLayoutItem;
|
||||
#endif
|
||||
|
||||
BMessage fBackgroundInfo;
|
||||
bool fCachedOutline;
|
||||
int32 fCachedWorkspace;
|
||||
|
||||
mutable BLocker fSourcesLock;
|
||||
BObjectList<DataSource> fSources;
|
||||
BObjectList<DataHistory> fValues;
|
||||
|
||||
@@ -416,6 +416,7 @@ CalcView::Draw(BRect updateRect)
|
||||
flags |= BControlLook::B_BLEND_FRAME;
|
||||
if (key->flags != 0)
|
||||
flags |= BControlLook::B_ACTIVATED;
|
||||
flags |= BControlLook::B_IGNORE_OUTLINE;
|
||||
|
||||
be_control_look->DrawButtonFrame(this, frame, updateRect,
|
||||
fBaseColor, fBaseColor, flags);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
#include <ControlLook.h>
|
||||
|
||||
#include "ContainerWindow.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Control.h>
|
||||
@@ -12,14 +14,19 @@
|
||||
#include <Shape.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
static const float kEdgeBevelLightTint = 0.59;
|
||||
static const float kEdgeBevelShadowTint = 1.0735;
|
||||
const rgb_color kWhite = (rgb_color){255, 255, 255, 255};
|
||||
const rgb_color kBlack = (rgb_color){0, 0, 0, 255};
|
||||
|
||||
|
||||
BControlLook::BControlLook()
|
||||
BControlLook::BControlLook():
|
||||
fCachedOutline(false),
|
||||
fCachedWorkspace(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1832,20 +1839,107 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
|
||||
// setup the text color
|
||||
// TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here,
|
||||
// or elliminate that constant alltogether (stippi: +1).
|
||||
rgb_color color;
|
||||
if (base.red + base.green + base.blue > 128 * 3)
|
||||
color = tint_color(base, B_DARKEN_MAX_TINT);
|
||||
|
||||
BWindow* window = view->Window();
|
||||
bool isDesktop = window
|
||||
&& window->Feel() == kPrivateDesktopWindowFeel
|
||||
&& window->Look() == kPrivateDesktopWindowLook
|
||||
&& view->Parent()
|
||||
&& view->Parent()->Parent() == NULL
|
||||
&& (flags & B_IGNORE_OUTLINE) == 0;
|
||||
|
||||
rgb_color low;
|
||||
rgb_color color;
|
||||
rgb_color glowColor;
|
||||
|
||||
if (isDesktop)
|
||||
low = view->Parent()->ViewColor();
|
||||
else
|
||||
color = tint_color(base, B_LIGHTEN_MAX_TINT);
|
||||
low = base;
|
||||
|
||||
if (low.red + low.green + low.blue > 128 * 3) {
|
||||
color = tint_color(low, B_DARKEN_MAX_TINT);
|
||||
glowColor = kWhite;
|
||||
} else {
|
||||
color = tint_color(low, B_LIGHTEN_MAX_TINT);
|
||||
glowColor = kBlack;
|
||||
}
|
||||
|
||||
if (flags & B_DISABLED) {
|
||||
color.red = (uint8)(((int32)base.red + color.red + 1) / 2);
|
||||
color.green = (uint8)(((int32)base.green + color.green + 1) / 2);
|
||||
color.blue = (uint8)(((int32)base.blue + color.blue + 1) / 2);
|
||||
color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
|
||||
color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
|
||||
color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
|
||||
}
|
||||
|
||||
drawing_mode oldMode = view->DrawingMode();
|
||||
|
||||
// check if the drawing occurs on the desktop
|
||||
if (isDesktop) {
|
||||
|
||||
if (fCachedWorkspace != current_workspace()) {
|
||||
|
||||
int8 indice = 0;
|
||||
int32 mask;
|
||||
bool tmpOutline;
|
||||
while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
|
||||
indice, &mask) == B_OK
|
||||
&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
|
||||
indice, &tmpOutline) == B_OK) {
|
||||
|
||||
if (((1 << current_workspace()) & mask) != 0) {
|
||||
fCachedOutline = tmpOutline;
|
||||
fCachedWorkspace = current_workspace();
|
||||
break;
|
||||
}
|
||||
indice++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fCachedOutline) {
|
||||
BFont font;
|
||||
view->GetFont(&font);
|
||||
|
||||
view->SetDrawingMode(B_OP_ALPHA);
|
||||
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
||||
// Draw glow or outline
|
||||
if (glowColor == kWhite) {
|
||||
font.SetFalseBoldWidth(2.0);
|
||||
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 30;
|
||||
view->SetHighColor(glowColor);
|
||||
view->DrawString(label, where);
|
||||
|
||||
font.SetFalseBoldWidth(1.0);
|
||||
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 65;
|
||||
view->SetHighColor(glowColor);
|
||||
view->DrawString(label, where);
|
||||
|
||||
font.SetFalseBoldWidth(0.0);
|
||||
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
} else if (glowColor == kBlack) {
|
||||
font.SetFalseBoldWidth(1.0);
|
||||
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 30;
|
||||
view->SetHighColor(glowColor);
|
||||
view->DrawString(label, where);
|
||||
|
||||
font.SetFalseBoldWidth(0.0);
|
||||
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
|
||||
|
||||
glowColor.alpha = 200;
|
||||
view->SetHighColor(glowColor);
|
||||
view->DrawString(label, BPoint(where.x + 1, where.y + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
view->SetHighColor(color);
|
||||
drawing_mode oldMode = view->DrawingMode();
|
||||
|
||||
view->SetDrawingMode(B_OP_OVER);
|
||||
|
||||
view->DrawString(label, where);
|
||||
@@ -1854,6 +1948,14 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BControlLook::SetBackgroundInfo(BMessage msg)
|
||||
{
|
||||
fBackgroundInfo = msg;
|
||||
fCachedWorkspace = -1;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ SetSubDirSupportedPlatforms haiku libbe_test ;
|
||||
UseLibraryHeaders agg ;
|
||||
UsePrivateHeaders app input print interface libbe shared support tracker ;
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
||||
|
||||
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ All rights reserved.
|
||||
//
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Node.h>
|
||||
#include <TranslationKit.h>
|
||||
#include <View.h>
|
||||
@@ -96,6 +97,10 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
|
||||
} else
|
||||
break;
|
||||
|
||||
if (be_control_look != NULL && isDesktop) {
|
||||
be_control_look->SetBackgroundInfo(container);
|
||||
}
|
||||
|
||||
container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
|
||||
container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
|
||||
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
|
||||
|
||||
Reference in New Issue
Block a user