Tracker: Make selected pose text semi-transparent on drag.
- cut items 75% opaque - dragged items 50% opaque - cut dragged items 25% opaque Fixes #19429. Change-Id: I0278d5aa57d06e11907dd17810feb539cd5b22ab Reviewed-on: https://review.haiku-os.org/c/haiku/+/10887 Haiku-Format: Haiku-format Bot <[email protected]> Reviewed-by: John Scipione <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -144,7 +144,7 @@ DraggableContainerIcon::MouseMoved(BPoint where, uint32, const BMessage*)
|
|||||||
view->SetDrawingMode(B_OP_ALPHA);
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
|
||||||
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
|
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||||
textColor.alpha = 192; // 75% opaque
|
textColor.alpha = 128; // 50% opaque
|
||||||
view->SetHighColor(textColor);
|
view->SetHighColor(textColor);
|
||||||
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||||
|
|
||||||
|
|||||||
+23
-13
@@ -536,6 +536,9 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
|
|||||||
fBackgroundClean = false;
|
fBackgroundClean = false;
|
||||||
|
|
||||||
bool direct = drawView == poseView;
|
bool direct = drawView == poseView;
|
||||||
|
bool dragging = false;
|
||||||
|
if (!direct && poseView->Window() != NULL && poseView->Window()->CurrentMessage() != NULL)
|
||||||
|
dragging = poseView->Window()->CurrentMessage()->what == kMsgMouseDragged;
|
||||||
bool windowActive = poseView->Window()->IsActive();
|
bool windowActive = poseView->Window()->IsActive();
|
||||||
bool showSelectionWhenInactive = poseView->ShowSelectionWhenInactive();
|
bool showSelectionWhenInactive = poseView->ShowSelectionWhenInactive();
|
||||||
bool drawIconUnselected = !windowActive && !showSelectionWhenInactive;
|
bool drawIconUnselected = !windowActive && !showSelectionWhenInactive;
|
||||||
@@ -543,11 +546,20 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
|
|||||||
if (direct)
|
if (direct)
|
||||||
poseView->PushState();
|
poseView->PushState();
|
||||||
|
|
||||||
// This is so that the cut icon will be drawn semi-transparent.
|
// This is so that cut and dragged items will be drawn semi-transparent.
|
||||||
if (fClipboardMode == kMoveSelectionTo) {
|
if (fClipboardMode == kMoveSelectionTo || dragging) {
|
||||||
drawView->SetDrawingMode(B_OP_ALPHA);
|
drawView->SetDrawingMode(B_OP_ALPHA);
|
||||||
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||||
uint8 alpha = 128; // 50% opaque
|
uint8 alpha;
|
||||||
|
if (fClipboardMode == kMoveSelectionTo && dragging)
|
||||||
|
alpha = 64; // cut and dragging, 25% opaque
|
||||||
|
else if (dragging)
|
||||||
|
alpha = 128; // dragging, 50% opaque
|
||||||
|
else if (fClipboardMode == kMoveSelectionTo)
|
||||||
|
alpha = 192; // cut, 75% opaque
|
||||||
|
else
|
||||||
|
alpha = 255;
|
||||||
|
|
||||||
if (poseView->HighColor().IsDark())
|
if (poseView->HighColor().IsDark())
|
||||||
drawView->SetHighColor(0, 0, 0, alpha);
|
drawView->SetHighColor(0, 0, 0, alpha);
|
||||||
else
|
else
|
||||||
@@ -639,36 +651,34 @@ BPose::DrawTextWidget(BRect rect, BRect textRect, BTextWidget* widget,
|
|||||||
widget->Draw(rect, textRect, poseView, drawView, selected, fClipboardMode, offset);
|
widget->Draw(rect, textRect, poseView, drawView, selected, fClipboardMode, offset);
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
// the selection rect is alpha-blended on top
|
||||||
BRect invertRect(textRect.OffsetByCopy(offset));
|
BRect invertRect(textRect.OffsetByCopy(offset));
|
||||||
invertRect.left = ceilf(invertRect.left);
|
invertRect.left = ceilf(invertRect.left);
|
||||||
invertRect.top = ceilf(invertRect.top);
|
invertRect.top = ceilf(invertRect.top);
|
||||||
invertRect.right = floorf(invertRect.right);
|
invertRect.right = floorf(invertRect.right);
|
||||||
invertRect.bottom = floorf(invertRect.bottom);
|
invertRect.bottom = floorf(invertRect.bottom);
|
||||||
|
|
||||||
if (windowActive || isDrawingSelectionRect) {
|
if (windowActive || isDrawingSelectionRect) {
|
||||||
// invert colors to select label using "reverse video"
|
// invert colors to select label using "reverse video"
|
||||||
drawView->InvertRect(invertRect);
|
drawView->InvertRect(invertRect);
|
||||||
if (clipboardMode == kMoveSelectionTo) {
|
|
||||||
// blend selected cut item background with gray
|
|
||||||
drawView->SetDrawingMode(B_OP_BLEND);
|
|
||||||
drawView->SetHighColor(128, 128, 128, 128);
|
|
||||||
drawView->FillRect(invertRect);
|
|
||||||
drawView->SetDrawingMode(B_OP_OVER);
|
|
||||||
}
|
|
||||||
} else if (!windowActive && showSelectionWhenInactive) {
|
} else if (!windowActive && showSelectionWhenInactive) {
|
||||||
if (direct)
|
if (direct)
|
||||||
drawView->PushState();
|
drawView->PushState();
|
||||||
|
|
||||||
// the selection rect is alpha-blended on top for inactive windows
|
// invert colors to select label using "reverse video"
|
||||||
drawView->InvertRect(invertRect);
|
drawView->InvertRect(invertRect);
|
||||||
|
|
||||||
drawView->SetDrawingMode(B_OP_BLEND);
|
drawView->SetDrawingMode(B_OP_BLEND);
|
||||||
// blend cut item background with less contrast
|
|
||||||
if (clipboardMode == kMoveSelectionTo) {
|
if (clipboardMode == kMoveSelectionTo) {
|
||||||
|
// blend inactive cut item background with less contrast
|
||||||
if (drawView->LowColor().IsLight())
|
if (drawView->LowColor().IsLight())
|
||||||
drawView->SetHighColor(192, 192, 192, 255);
|
drawView->SetHighColor(192, 192, 192, 255);
|
||||||
else
|
else
|
||||||
drawView->SetHighColor(64, 64, 64, 255);
|
drawView->SetHighColor(64, 64, 64, 255);
|
||||||
} else
|
} else {
|
||||||
|
// blend inactive background with gray
|
||||||
drawView->SetHighColor(128, 128, 128, 255);
|
drawView->SetHighColor(128, 128, 128, 255);
|
||||||
|
}
|
||||||
drawView->FillRect(invertRect);
|
drawView->FillRect(invertRect);
|
||||||
drawView->SetDrawingMode(B_OP_OVER);
|
drawView->SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
|
|||||||
@@ -651,10 +651,19 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
|
|||||||
// BPose::Draw before and after calling this function.
|
// BPose::Draw before and after calling this function.
|
||||||
|
|
||||||
bool direct = drawView == view;
|
bool direct = drawView == view;
|
||||||
|
bool dragging = false;
|
||||||
|
if (!direct && view->Window() != NULL && view->Window()->CurrentMessage() != NULL)
|
||||||
|
dragging = view->Window()->CurrentMessage()->what == kMsgMouseDragged;
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
// erase selection rect background
|
if (dragging) {
|
||||||
drawView->SetDrawingMode(B_OP_COPY);
|
drawView->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||||
|
} else {
|
||||||
|
// erase selection rect background
|
||||||
|
drawView->SetDrawingMode(B_OP_COPY);
|
||||||
|
}
|
||||||
|
|
||||||
BRect invertRect(textRect);
|
BRect invertRect(textRect);
|
||||||
invertRect.left = ceilf(invertRect.left);
|
invertRect.left = ceilf(invertRect.left);
|
||||||
invertRect.top = ceilf(invertRect.top);
|
invertRect.top = ceilf(invertRect.top);
|
||||||
@@ -665,38 +674,32 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
|
|||||||
// High color is set to inverted low, then the whole thing is
|
// High color is set to inverted low, then the whole thing is
|
||||||
// inverted again so that the background color "shines through".
|
// inverted again so that the background color "shines through".
|
||||||
drawView->SetHighColor(InvertColorSmart(drawView->LowColor()));
|
drawView->SetHighColor(InvertColorSmart(drawView->LowColor()));
|
||||||
} else if (clipboardMode == kMoveSelectionTo) {
|
|
||||||
drawView->SetDrawingMode(B_OP_ALPHA);
|
|
||||||
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
|
||||||
uint8 alpha = 128; // 50% opaque
|
|
||||||
if (drawView->LowColor().IsLight())
|
|
||||||
drawView->SetHighColor(0, 0, 0, alpha);
|
|
||||||
else
|
|
||||||
drawView->SetHighColor(255, 255, 255, alpha);
|
|
||||||
} else {
|
} else {
|
||||||
drawView->SetDrawingMode(B_OP_OVER);
|
|
||||||
if (view->IsDesktopView())
|
if (view->IsDesktopView())
|
||||||
drawView->SetHighColor(view->HighColor());
|
drawView->SetHighColor(view->HighColor());
|
||||||
else
|
else
|
||||||
drawView->SetHighUIColor(view->HighUIColor());
|
drawView->SetHighUIColor(view->HighUIColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dragging || (direct && clipboardMode == kMoveSelectionTo)) {
|
||||||
|
drawView->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||||
|
} else {
|
||||||
|
drawView->SetDrawingMode(B_OP_OVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// high color and drawing mode are set to draw text
|
||||||
|
|
||||||
float decenderHeight = roundf(view->FontInfo().descent);
|
float decenderHeight = roundf(view->FontInfo().descent);
|
||||||
BPoint location(textRect.left, textRect.bottom - decenderHeight);
|
BPoint location(textRect.left, textRect.bottom - decenderHeight);
|
||||||
|
|
||||||
const char* fittingText = fText->FittingText(view);
|
const char* fittingText = fText->FittingText(view);
|
||||||
|
|
||||||
// Draw text outline unless selected or column resizing.
|
// Draw text outline if enabled unless selected or column resizing.
|
||||||
// The direct parameter is false when dragging or column resizing.
|
if (view->WidgetTextOutline() && !selected && (direct || dragging)) {
|
||||||
if (!selected && direct && view->WidgetTextOutline()) {
|
|
||||||
// draw a halo around the text by using the "false bold"
|
// draw a halo around the text by using the "false bold"
|
||||||
// feature for text rendering. Either black or white is used for
|
// feature for text rendering. Either black or white is used for
|
||||||
// the glow (whatever acts as contrast) with a some alpha value,
|
// the glow (whatever acts as contrast) with a some alpha value,
|
||||||
if (direct && clipboardMode != kMoveSelectionTo) {
|
|
||||||
drawView->SetDrawingMode(B_OP_ALPHA);
|
|
||||||
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
drawView->GetFont(&font);
|
drawView->GetFont(&font);
|
||||||
|
|
||||||
@@ -741,9 +744,6 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
|
|||||||
drawView->DrawString(fittingText, location + BPoint(1, 1));
|
drawView->DrawString(fittingText, location + BPoint(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direct && clipboardMode != kMoveSelectionTo)
|
|
||||||
drawView->SetDrawingMode(B_OP_OVER);
|
|
||||||
|
|
||||||
drawView->SetHighColor(textColor);
|
drawView->SetHighColor(textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,23 +753,11 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
|
|||||||
// TODO:
|
// TODO:
|
||||||
// this should be exported to the WidgetAttribute class, probably
|
// this should be exported to the WidgetAttribute class, probably
|
||||||
// by having a per widget kind style
|
// by having a per widget kind style
|
||||||
if (direct && clipboardMode != kMoveSelectionTo) {
|
|
||||||
rgb_color underlineColor = drawView->HighColor();
|
|
||||||
underlineColor.alpha = 180;
|
|
||||||
|
|
||||||
drawView->SetDrawingMode(B_OP_ALPHA);
|
|
||||||
drawView->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
|
||||||
drawView->SetHighColor(underlineColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
BRect lineRect(textRect.OffsetByCopy(0, decenderHeight > 2 ? -(decenderHeight - 2) : 0));
|
BRect lineRect(textRect.OffsetByCopy(0, decenderHeight > 2 ? -(decenderHeight - 2) : 0));
|
||||||
// move underline 2px under text
|
// move underline 2px under text
|
||||||
lineRect.InsetBy(roundf(textRect.Width() - fText->Width(view)), 0);
|
lineRect.InsetBy(roundf(textRect.Width() - fText->Width(view)), 0);
|
||||||
// only underline text part
|
// only underline text part
|
||||||
drawView->StrokeLine(lineRect.LeftBottom(), lineRect.RightBottom(), B_MIXED_COLORS);
|
drawView->StrokeLine(lineRect.LeftBottom(), lineRect.RightBottom(), B_MIXED_COLORS);
|
||||||
|
|
||||||
if (direct && clipboardMode != kMoveSelectionTo)
|
|
||||||
drawView->SetDrawingMode(B_OP_OVER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawView->ConstrainClippingRegion(NULL);
|
drawView->ConstrainClippingRegion(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user