* improvement to checkmark and submenu indicator layout and drawing (layout
takes menu margins into account, drawing is now fully scalable) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22371 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -667,22 +667,30 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor)
|
|||||||
fSuper->PushState();
|
fSuper->PushState();
|
||||||
|
|
||||||
BRect r(fBounds);
|
BRect r(fBounds);
|
||||||
r.right = r.left + r.Height();
|
float leftMargin;
|
||||||
r.top += 2;
|
fSuper->GetItemMargins(&leftMargin, NULL, NULL, NULL);
|
||||||
r.bottom -= 2;
|
r.right = r.left + leftMargin - 3;
|
||||||
r.left += 1;
|
r.left += 1;
|
||||||
r.right -= 5;
|
|
||||||
|
BPoint center(floorf((r.left + r.right) / 2.0),
|
||||||
|
floorf((r.top + r.bottom) / 2.0));
|
||||||
|
|
||||||
|
float size = min_c(r.Height() - 2, r.Width());
|
||||||
|
r.top = floorf(center.y - size / 2 + 0.5);
|
||||||
|
r.bottom = floorf(center.y + size / 2 + 0.5);
|
||||||
|
r.left = floorf(center.x - size / 2 + 0.5);
|
||||||
|
r.right = floorf(center.x + size / 2 + 0.5);
|
||||||
|
|
||||||
fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
|
fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
|
||||||
fSuper->FillRect(r);
|
fSuper->FillRoundRect(r, 2, 2);
|
||||||
|
|
||||||
BPoint center(floorf((r.left + r.right) / 2.0) + 0.5,
|
|
||||||
floorf((r.top + r.bottom) / 2.0) + 0.5);
|
|
||||||
// NOTE: center is on X.5, Y.5 on purpose!
|
|
||||||
BShape arrowShape;
|
BShape arrowShape;
|
||||||
arrowShape.MoveTo(BPoint(center.x - 4, center.y - 1.5));
|
center.x += 0.5;
|
||||||
arrowShape.LineTo(BPoint(center.x - 1, center.y + 2.0));
|
center.y += 0.5;
|
||||||
arrowShape.LineTo(BPoint(center.x + 4, center.y - 3.5));
|
size *= 0.3;
|
||||||
|
arrowShape.MoveTo(BPoint(center.x - size, center.y - size * 0.25));
|
||||||
|
arrowShape.LineTo(BPoint(center.x - size * 0.25, center.y + size));
|
||||||
|
arrowShape.LineTo(BPoint(center.x + size, center.y - size));
|
||||||
|
|
||||||
fSuper->SetDrawingMode(B_OP_OVER);
|
fSuper->SetDrawingMode(B_OP_OVER);
|
||||||
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
||||||
@@ -765,23 +773,35 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
|
|||||||
fSuper->PushState();
|
fSuper->PushState();
|
||||||
|
|
||||||
BRect r(fBounds);
|
BRect r(fBounds);
|
||||||
r.left = r.right - r.Height();
|
float rightMargin;
|
||||||
r.InsetBy(2.0, 2.0);
|
fSuper->GetItemMargins(NULL, NULL, &rightMargin, NULL);
|
||||||
|
r.left = r.right - rightMargin + 3;
|
||||||
|
r.right -= 1;
|
||||||
|
|
||||||
|
BPoint center(floorf((r.left + r.right) / 2.0),
|
||||||
|
floorf((r.top + r.bottom) / 2.0));
|
||||||
|
|
||||||
|
float size = min_c(r.Height() - 2, r.Width());
|
||||||
|
r.top = floorf(center.y - size / 2 + 0.5);
|
||||||
|
r.bottom = floorf(center.y + size / 2 + 0.5);
|
||||||
|
r.left = floorf(center.x - size / 2 + 0.5);
|
||||||
|
r.right = floorf(center.x + size / 2 + 0.5);
|
||||||
|
|
||||||
fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
|
fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
|
||||||
fSuper->FillRect(r);
|
fSuper->FillRoundRect(r, 2, 2);
|
||||||
|
|
||||||
BPoint center(floorf((r.left + r.right) / 2.0) + 0.5,
|
|
||||||
floorf((r.top + r.bottom) / 2.0) + 0.5);
|
|
||||||
// NOTE: center is on X.5, Y.5 on purpose!
|
|
||||||
BShape arrowShape;
|
BShape arrowShape;
|
||||||
arrowShape.MoveTo(BPoint(center.x - 1.5, center.y - 3));
|
center.x += 0.5;
|
||||||
arrowShape.LineTo(BPoint(center.x + 2.0, center.y));
|
center.y += 0.5;
|
||||||
arrowShape.LineTo(BPoint(center.x - 1.5, center.y + 3));
|
size *= 0.25;
|
||||||
|
float hSize = size * 0.7;
|
||||||
|
arrowShape.MoveTo(BPoint(center.x - hSize, center.y - size));
|
||||||
|
arrowShape.LineTo(BPoint(center.x + hSize, center.y));
|
||||||
|
arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
|
||||||
|
|
||||||
fSuper->SetDrawingMode(B_OP_OVER);
|
fSuper->SetDrawingMode(B_OP_OVER);
|
||||||
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
|
||||||
fSuper->SetPenSize(2.0);
|
fSuper->SetPenSize(ceilf(size * 0.4));
|
||||||
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
// NOTE: StrokeShape() offsets the shape by the current pen position,
|
||||||
// it is not documented in the BeBook, but it is true!
|
// it is not documented in the BeBook, but it is true!
|
||||||
fSuper->MovePenTo(B_ORIGIN);
|
fSuper->MovePenTo(B_ORIGIN);
|
||||||
|
|||||||
Reference in New Issue
Block a user