FlatControlLook: fix clipping
Remove ConstrainClippingRegion calls as they do not take into account view transformations. Clip drawing to the drawing rect, not the updated area. Part of #12890 Change-Id: Icbc07f5431cf8ee826f28e6d5683135d1171d75a
This commit is contained in:
@@ -119,7 +119,7 @@ FlatControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders)
|
uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// the surface edges
|
// the surface edges
|
||||||
@@ -244,7 +244,7 @@ FlatControlLook::DrawMenuBackground(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders)
|
uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// surface top color
|
// surface top color
|
||||||
@@ -277,7 +277,7 @@ FlatControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders)
|
uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// surface edges
|
// surface edges
|
||||||
@@ -316,14 +316,13 @@ FlatControlLook::DrawScrollBarBorder(BView* view, BRect rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
orientation orientation)
|
orientation orientation)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
bool isEnabled = (flags & B_DISABLED) == 0;
|
bool isEnabled = (flags & B_DISABLED) == 0;
|
||||||
bool isFocused = (flags & B_FOCUSED) != 0;
|
bool isFocused = (flags & B_FOCUSED) != 0;
|
||||||
@@ -372,7 +371,7 @@ FlatControlLook::DrawScrollBarButton(BView* view, BRect rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
int32 direction, orientation orientation, bool down)
|
int32 direction, orientation orientation, bool down)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool dark = (base.red + base.green + base.blue <= 128 * 3);
|
bool dark = (base.red + base.green + base.blue <= 128 * 3);
|
||||||
@@ -395,8 +394,8 @@ FlatControlLook::DrawScrollBarButton(BView* view, BRect rect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clip to button
|
// clip to button
|
||||||
BRegion buttonRegion(rect);
|
view->PushState();
|
||||||
view->ConstrainClippingRegion(&buttonRegion);
|
view->ClipToRect(rect);
|
||||||
|
|
||||||
flags &= ~B_FLAT;
|
flags &= ~B_FLAT;
|
||||||
|
|
||||||
@@ -405,8 +404,7 @@ FlatControlLook::DrawScrollBarButton(BView* view, BRect rect,
|
|||||||
DrawArrowShape(view, rect, updateRect, arrowColor, direction, flags, 1.0f);
|
DrawArrowShape(view, rect, updateRect, arrowColor, direction, flags, 1.0f);
|
||||||
|
|
||||||
// revert clipping constraints
|
// revert clipping constraints
|
||||||
BRegion clipping(updateRect);
|
view->PopState();
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -425,14 +423,13 @@ FlatControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
orientation orientation)
|
orientation orientation)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
bool isEnabled = (flags & B_DISABLED) == 0;
|
bool isEnabled = (flags & B_DISABLED) == 0;
|
||||||
|
|
||||||
@@ -475,14 +472,13 @@ FlatControlLook::DrawScrollBarThumb(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
orientation orientation, uint32 knobStyle)
|
orientation orientation, uint32 knobStyle)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
bool isEnabled = (flags & B_DISABLED) == 0;
|
bool isEnabled = (flags & B_DISABLED) == 0;
|
||||||
@@ -504,9 +500,7 @@ FlatControlLook::DrawScrollBarThumb(BView* view, BRect& rect,
|
|||||||
// draw scroll thumb
|
// draw scroll thumb
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
// fill the clickable surface of the thumb
|
// fill the clickable surface of the thumb
|
||||||
// set clipping constraints to updateRect
|
|
||||||
BRegion clipping(updateRect);
|
BRegion clipping(updateRect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
DrawScrollBarBackground(view, rect, updateRect, base_panel, flags, orientation);
|
DrawScrollBarBackground(view, rect, updateRect, base_panel, flags, orientation);
|
||||||
rect.InsetBy(3, 3);
|
rect.InsetBy(3, 3);
|
||||||
view->SetHighColor(base_panel);
|
view->SetHighColor(base_panel);
|
||||||
@@ -752,12 +746,9 @@ FlatControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
|
const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
|
||||||
float sliderScale, uint32 flags, orientation orientation)
|
float sliderScale, uint32 flags, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// save the clipping constraints of the view
|
|
||||||
view->PushState();
|
|
||||||
|
|
||||||
// separate the bar in two sides
|
// separate the bar in two sides
|
||||||
float sliderPosition;
|
float sliderPosition;
|
||||||
BRect leftBarSide = rect;
|
BRect leftBarSide = rect;
|
||||||
@@ -776,31 +767,21 @@ FlatControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
rightBarSide.bottom = sliderPosition - 1;
|
rightBarSide.bottom = sliderPosition - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the background for the corners, exclude the middle bar for now
|
|
||||||
BRegion region(rect);
|
|
||||||
region.Exclude(rightBarSide);
|
|
||||||
view->ConstrainClippingRegion(®ion);
|
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
view->ClipToRect(leftBarSide);
|
||||||
|
|
||||||
DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
|
DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
|
||||||
orientation);
|
orientation);
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
|
|
||||||
region.Set(rect);
|
|
||||||
region.Exclude(leftBarSide);
|
|
||||||
view->ConstrainClippingRegion(®ion);
|
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
view->ClipToRect(rightBarSide);
|
||||||
|
|
||||||
DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
|
DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
|
||||||
orientation);
|
orientation);
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
|
|
||||||
// restore the clipping constraints of the view
|
|
||||||
view->PopState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -809,7 +790,7 @@ FlatControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
const rgb_color& base, rgb_color fillColor, uint32 flags,
|
const rgb_color& base, rgb_color fillColor, uint32 flags,
|
||||||
orientation orientation)
|
orientation orientation)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// separate the rect into corners
|
// separate the rect into corners
|
||||||
@@ -830,9 +811,9 @@ FlatControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fill the background for the corners, exclude the middle bar for now
|
// fill the background for the corners, exclude the middle bar for now
|
||||||
BRegion region(rect);
|
view->PushState();
|
||||||
region.Exclude(barRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(®ion);
|
view->ClipToInverseRect(barRect);
|
||||||
|
|
||||||
if ((flags & B_BLEND_FRAME) == 0) {
|
if ((flags & B_BLEND_FRAME) == 0) {
|
||||||
view->SetHighColor(base);
|
view->SetHighColor(base);
|
||||||
@@ -920,7 +901,9 @@ FlatControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
|
fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
view->ConstrainClippingRegion(NULL);
|
view->PopState();
|
||||||
|
if ((flags & B_BLEND_FRAME) != 0)
|
||||||
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
view->BeginLineArray(4);
|
||||||
if (orientation == B_HORIZONTAL) {
|
if (orientation == B_HORIZONTAL) {
|
||||||
@@ -959,7 +942,7 @@ void
|
|||||||
FlatControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
FlatControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, orientation orientation)
|
const rgb_color& base, uint32 flags, orientation orientation)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rgb_color thumbColor = tint_color(ui_color(B_SCROLL_BAR_THUMB_COLOR), 1.0);
|
rgb_color thumbColor = tint_color(ui_color(B_SCROLL_BAR_THUMB_COLOR), 1.0);
|
||||||
@@ -1037,7 +1020,7 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders, uint32 side, int32, int32, int32, int32)
|
uint32 borders, uint32 side, int32, int32, int32, int32)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Snap the rectangle to pixels to avoid rounding errors.
|
// Snap the rectangle to pixels to avoid rounding errors.
|
||||||
@@ -1049,9 +1032,8 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
// save the clipping constraints of the view
|
// save the clipping constraints of the view
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
rgb_color edgeShadowColor;
|
rgb_color edgeShadowColor;
|
||||||
rgb_color edgeLightColor;
|
rgb_color edgeLightColor;
|
||||||
@@ -1106,10 +1088,12 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
- kRoundCornerRadius);
|
- kRoundCornerRadius);
|
||||||
rightBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
|
rightBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
|
||||||
|
|
||||||
|
BRect roundCorner[2];
|
||||||
|
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case B_TOP_BORDER:
|
case B_TOP_BORDER:
|
||||||
clipping.Exclude(leftTopCorner);
|
roundCorner[0] = leftTopCorner;
|
||||||
clipping.Exclude(rightTopCorner);
|
roundCorner[1] = rightTopCorner;
|
||||||
|
|
||||||
// draw the left top corner
|
// draw the left top corner
|
||||||
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
||||||
@@ -1122,8 +1106,8 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
fillGradient);
|
fillGradient);
|
||||||
break;
|
break;
|
||||||
case B_BOTTOM_BORDER:
|
case B_BOTTOM_BORDER:
|
||||||
clipping.Exclude(leftBottomCorner);
|
roundCorner[0] = leftBottomCorner;
|
||||||
clipping.Exclude(rightBottomCorner);
|
roundCorner[1] = rightBottomCorner;
|
||||||
|
|
||||||
// draw the left bottom corner
|
// draw the left bottom corner
|
||||||
_DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
|
_DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
|
||||||
@@ -1136,8 +1120,8 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
fillGradient);
|
fillGradient);
|
||||||
break;
|
break;
|
||||||
case B_LEFT_BORDER:
|
case B_LEFT_BORDER:
|
||||||
clipping.Exclude(leftTopCorner);
|
roundCorner[0] = leftTopCorner;
|
||||||
clipping.Exclude(leftBottomCorner);
|
roundCorner[1] = leftBottomCorner;
|
||||||
|
|
||||||
// draw the left top corner
|
// draw the left top corner
|
||||||
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
||||||
@@ -1150,8 +1134,8 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
fillGradient);
|
fillGradient);
|
||||||
break;
|
break;
|
||||||
case B_RIGHT_BORDER:
|
case B_RIGHT_BORDER:
|
||||||
clipping.Exclude(rightTopCorner);
|
roundCorner[0] = rightTopCorner;
|
||||||
clipping.Exclude(rightBottomCorner);
|
roundCorner[1] = rightBottomCorner;
|
||||||
|
|
||||||
// draw the right top corner
|
// draw the right top corner
|
||||||
_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
|
_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
|
||||||
@@ -1166,7 +1150,8 @@ FlatControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clip out the corners
|
// clip out the corners
|
||||||
view->ConstrainClippingRegion(&clipping);
|
view->ClipToInverseRect(roundCorner[0]);
|
||||||
|
view->ClipToInverseRect(roundCorner[1]);
|
||||||
|
|
||||||
uint32 bordersToDraw = 0;
|
uint32 bordersToDraw = 0;
|
||||||
switch (side) {
|
switch (side) {
|
||||||
@@ -1217,7 +1202,7 @@ FlatControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
const rgb_color& base, orientation orientation, uint32 flags,
|
const rgb_color& base, orientation orientation, uint32 flags,
|
||||||
uint32 borders)
|
uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rgb_color background;
|
rgb_color background;
|
||||||
@@ -1368,7 +1353,7 @@ FlatControlLook::DrawTextControlBorder(BView* view, BRect& rect,
|
|||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders)
|
uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rgb_color dark1BorderColor;
|
rgb_color dark1BorderColor;
|
||||||
@@ -1521,9 +1506,8 @@ FlatControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
// save the clipping constraints of the view
|
// save the clipping constraints of the view
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
// If the button is flat and neither activated nor otherwise highlighted
|
// If the button is flat and neither activated nor otherwise highlighted
|
||||||
// (mouse hovering or focussed), draw it flat.
|
// (mouse hovering or focussed), draw it flat.
|
||||||
@@ -1604,9 +1588,10 @@ FlatControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
|
BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
|
||||||
floorf(rect.left + leftTopRadius),
|
floorf(rect.left + leftTopRadius),
|
||||||
floorf(rect.top + leftTopRadius));
|
floorf(rect.top + leftTopRadius));
|
||||||
clipping.Exclude(leftTopCorner);
|
BRect cornerRect(leftTopCorner);
|
||||||
_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
|
_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
|
||||||
cornerBgColor, edgeShadowColor, frameLightColor);
|
cornerBgColor, edgeShadowColor, frameLightColor);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
||||||
@@ -1615,10 +1600,11 @@ FlatControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
BRect rightTopCorner(floorf(rect.right - rightTopRadius),
|
BRect rightTopCorner(floorf(rect.right - rightTopRadius),
|
||||||
floorf(rect.top), floorf(rect.right),
|
floorf(rect.top), floorf(rect.right),
|
||||||
floorf(rect.top + rightTopRadius));
|
floorf(rect.top + rightTopRadius));
|
||||||
clipping.Exclude(rightTopCorner);
|
BRect cornerRect(rightTopCorner);
|
||||||
_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
|
_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
|
||||||
cornerBgColor, edgeShadowColor, edgeLightColor,
|
cornerBgColor, edgeShadowColor, edgeLightColor,
|
||||||
frameLightColor, frameShadowColor);
|
frameLightColor, frameShadowColor);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -1627,10 +1613,11 @@ FlatControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
BRect leftBottomCorner(floorf(rect.left),
|
BRect leftBottomCorner(floorf(rect.left),
|
||||||
floorf(rect.bottom - leftBottomRadius),
|
floorf(rect.bottom - leftBottomRadius),
|
||||||
floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
|
floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
|
||||||
clipping.Exclude(leftBottomCorner);
|
BRect cornerRect(leftBottomCorner);
|
||||||
_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
|
_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
|
||||||
cornerBgColor, edgeShadowColor, edgeLightColor,
|
cornerBgColor, edgeShadowColor, edgeLightColor,
|
||||||
frameLightColor, frameShadowColor);
|
frameLightColor, frameShadowColor);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -1639,14 +1626,12 @@ FlatControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
BRect rightBottomCorner(floorf(rect.right - rightBottomRadius),
|
BRect rightBottomCorner(floorf(rect.right - rightBottomRadius),
|
||||||
floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
|
floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
|
||||||
floorf(rect.bottom));
|
floorf(rect.bottom));
|
||||||
clipping.Exclude(rightBottomCorner);
|
BRect cornerRect(rightBottomCorner);
|
||||||
_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
|
_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
|
||||||
updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
|
updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clip out the corners
|
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// draw outer edge only for default button!!! B_SUCCESS_COLOR
|
// draw outer edge only for default button!!! B_SUCCESS_COLOR
|
||||||
if ((flags & B_DEFAULT_BUTTON) != 0) {
|
if ((flags & B_DEFAULT_BUTTON) != 0) {
|
||||||
@@ -1715,9 +1700,8 @@ FlatControlLook::_DrawButtonBackground(BView* view, BRect& rect,
|
|||||||
// save the clipping constraints of the view
|
// save the clipping constraints of the view
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
// If is a default button, set backcolor to the tab color.
|
// If is a default button, set backcolor to the tab color.
|
||||||
if ((flags & B_DEFAULT_BUTTON) != 0)
|
if ((flags & B_DEFAULT_BUTTON) != 0)
|
||||||
@@ -1739,6 +1723,7 @@ FlatControlLook::_DrawButtonBackground(BView* view, BRect& rect,
|
|||||||
_DrawFlatButtonBackground(view, rect, updateRect, customColor, popupIndicator,
|
_DrawFlatButtonBackground(view, rect, updateRect, customColor, popupIndicator,
|
||||||
flags, borders, orientation);
|
flags, borders, orientation);
|
||||||
} else {
|
} else {
|
||||||
|
BRegion clipping(rect);
|
||||||
_DrawNonFlatButtonBackground(view, rect, updateRect, clipping,
|
_DrawNonFlatButtonBackground(view, rect, updateRect, clipping,
|
||||||
leftTopRadius, rightTopRadius, leftBottomRadius, rightBottomRadius,
|
leftTopRadius, rightTopRadius, leftBottomRadius, rightBottomRadius,
|
||||||
customColor, popupIndicator, flags, borders, orientation);
|
customColor, popupIndicator, flags, borders, orientation);
|
||||||
@@ -1778,8 +1763,10 @@ FlatControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect,
|
|||||||
floorf(rect.left + leftTopRadius - 2.0),
|
floorf(rect.left + leftTopRadius - 2.0),
|
||||||
floorf(rect.top + leftTopRadius - 2.0));
|
floorf(rect.top + leftTopRadius - 2.0));
|
||||||
clipping.Exclude(leftTopCorner);
|
clipping.Exclude(leftTopCorner);
|
||||||
|
BRect cornerRect(leftTopCorner);
|
||||||
_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
|
_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
|
||||||
bevelLightColor, fillGradient);
|
bevelLightColor, fillGradient);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
||||||
@@ -1789,8 +1776,10 @@ FlatControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect,
|
|||||||
floorf(rect.top), floorf(rect.right),
|
floorf(rect.top), floorf(rect.right),
|
||||||
floorf(rect.top + rightTopRadius - 2.0));
|
floorf(rect.top + rightTopRadius - 2.0));
|
||||||
clipping.Exclude(rightTopCorner);
|
clipping.Exclude(rightTopCorner);
|
||||||
|
BRect cornerRect(rightTopCorner);
|
||||||
_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
|
_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
|
||||||
updateRect, bevelLightColor, bevelShadowColor, fillGradient);
|
updateRect, bevelLightColor, bevelShadowColor, fillGradient);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -1801,8 +1790,10 @@ FlatControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect,
|
|||||||
floorf(rect.left + leftBottomRadius - 2.0),
|
floorf(rect.left + leftBottomRadius - 2.0),
|
||||||
floorf(rect.bottom));
|
floorf(rect.bottom));
|
||||||
clipping.Exclude(leftBottomCorner);
|
clipping.Exclude(leftBottomCorner);
|
||||||
|
BRect cornerRect(leftBottomCorner);
|
||||||
_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
|
_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
|
||||||
updateRect, bevelLightColor, bevelShadowColor, fillGradient);
|
updateRect, bevelLightColor, bevelShadowColor, fillGradient);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -1812,13 +1803,12 @@ FlatControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect,
|
|||||||
floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
|
floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
|
||||||
floorf(rect.bottom));
|
floorf(rect.bottom));
|
||||||
clipping.Exclude(rightBottomCorner);
|
clipping.Exclude(rightBottomCorner);
|
||||||
|
BRect cornerRect(rightBottomCorner);
|
||||||
_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
|
_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
|
||||||
updateRect, bevelShadowColor, fillGradient);
|
updateRect, bevelShadowColor, fillGradient);
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clip out the corners
|
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
// draw inner bevel
|
// draw inner bevel
|
||||||
|
|
||||||
if ((flags & B_ACTIVATED) != 0) {
|
if ((flags & B_ACTIVATED) != 0) {
|
||||||
@@ -1934,7 +1924,7 @@ FlatControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect,
|
|||||||
float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
|
float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
|
||||||
bool popupIndicator, uint32 flags)
|
bool popupIndicator, uint32 flags)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (popupIndicator) {
|
if (popupIndicator) {
|
||||||
@@ -1979,15 +1969,14 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
|
float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
|
||||||
uint32 flags, uint32 borders)
|
uint32 flags, uint32 borders)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!ShouldDraw(view, rect, updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// save the clipping constraints of the view
|
// save the clipping constraints of the view
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect
|
// set clipping constraints to rect
|
||||||
BRegion clipping(updateRect);
|
view->ClipToRect(rect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
// frame colors
|
// frame colors
|
||||||
rgb_color frameLightColor = _FrameLightColor(base, flags);
|
rgb_color frameLightColor = _FrameLightColor(base, flags);
|
||||||
@@ -2034,10 +2023,10 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
|
BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
|
||||||
floorf(rect.left + leftTopRadius - 2.0),
|
floorf(rect.left + leftTopRadius - 2.0),
|
||||||
floorf(rect.top + leftTopRadius - 2.0));
|
floorf(rect.top + leftTopRadius - 2.0));
|
||||||
clipping.Exclude(leftTopCorner);
|
BRect cornerRect(leftTopCorner);
|
||||||
|
|
||||||
BRegion cornerClipping(leftTopCorner);
|
view->PushState();
|
||||||
view->ConstrainClippingRegion(&cornerClipping);
|
view->ClipToRect(cornerRect);
|
||||||
|
|
||||||
BRect ellipseRect(leftTopCorner);
|
BRect ellipseRect(leftTopCorner);
|
||||||
ellipseRect.InsetBy(-1.0, -1.0);
|
ellipseRect.InsetBy(-1.0, -1.0);
|
||||||
@@ -2051,6 +2040,9 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
// draw the bevel and background
|
// draw the bevel and background
|
||||||
_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
|
_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
|
||||||
bevelColor1, fillGradient);
|
bevelColor1, fillGradient);
|
||||||
|
|
||||||
|
view->PopState();
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
|
||||||
@@ -2059,10 +2051,10 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
|
BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
|
||||||
floorf(rect.top), floorf(rect.right),
|
floorf(rect.top), floorf(rect.right),
|
||||||
floorf(rect.top + rightTopRadius - 2.0));
|
floorf(rect.top + rightTopRadius - 2.0));
|
||||||
clipping.Exclude(rightTopCorner);
|
BRect cornerRect(rightTopCorner);
|
||||||
|
|
||||||
BRegion cornerClipping(rightTopCorner);
|
view->PushState();
|
||||||
view->ConstrainClippingRegion(&cornerClipping);
|
view->ClipToRect(cornerRect);
|
||||||
|
|
||||||
BRect ellipseRect(rightTopCorner);
|
BRect ellipseRect(rightTopCorner);
|
||||||
ellipseRect.InsetBy(-1.0, -1.0);
|
ellipseRect.InsetBy(-1.0, -1.0);
|
||||||
@@ -2085,6 +2077,9 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
// draw the bevel and background
|
// draw the bevel and background
|
||||||
_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
|
_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
|
||||||
bevelColor1, bevelColor3, fillGradient);
|
bevelColor1, bevelColor3, fillGradient);
|
||||||
|
|
||||||
|
view->PopState();
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -2094,10 +2089,10 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
floorf(rect.bottom - leftBottomRadius + 2.0),
|
floorf(rect.bottom - leftBottomRadius + 2.0),
|
||||||
floorf(rect.left + leftBottomRadius - 2.0),
|
floorf(rect.left + leftBottomRadius - 2.0),
|
||||||
floorf(rect.bottom));
|
floorf(rect.bottom));
|
||||||
clipping.Exclude(leftBottomCorner);
|
BRect cornerRect(leftBottomCorner);
|
||||||
|
|
||||||
BRegion cornerClipping(leftBottomCorner);
|
view->PushState();
|
||||||
view->ConstrainClippingRegion(&cornerClipping);
|
view->ClipToRect(cornerRect);
|
||||||
|
|
||||||
BRect ellipseRect(leftBottomCorner);
|
BRect ellipseRect(leftBottomCorner);
|
||||||
ellipseRect.InsetBy(-1.0, -1.0);
|
ellipseRect.InsetBy(-1.0, -1.0);
|
||||||
@@ -2120,6 +2115,9 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
// draw the bevel and background
|
// draw the bevel and background
|
||||||
_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
|
_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
|
||||||
updateRect, bevelColor2, bevelColor3, fillGradient);
|
updateRect, bevelColor2, bevelColor3, fillGradient);
|
||||||
|
|
||||||
|
view->PopState();
|
||||||
|
view->ClipToInverseRect(cornerRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
|
||||||
@@ -2128,10 +2126,10 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
|
BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
|
||||||
floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
|
floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
|
||||||
floorf(rect.bottom));
|
floorf(rect.bottom));
|
||||||
clipping.Exclude(rightBottomCorner);
|
BRect cornerRect(rightBottomCorner);
|
||||||
|
|
||||||
BRegion cornerClipping(rightBottomCorner);
|
view->PushState();
|
||||||
view->ConstrainClippingRegion(&cornerClipping);
|
view->ClipToRect(cornerRect);
|
||||||
|
|
||||||
BRect ellipseRect(rightBottomCorner);
|
BRect ellipseRect(rightBottomCorner);
|
||||||
ellipseRect.InsetBy(-1.0, -1.0);
|
ellipseRect.InsetBy(-1.0, -1.0);
|
||||||
@@ -2145,10 +2143,10 @@ FlatControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
|
|||||||
// draw the bevel and background
|
// draw the bevel and background
|
||||||
_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
|
_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
|
||||||
updateRect, bevelColor3, fillGradient);
|
updateRect, bevelColor3, fillGradient);
|
||||||
}
|
|
||||||
|
|
||||||
// clip out the corners
|
view->PopState();
|
||||||
view->ConstrainClippingRegion(&clipping);
|
view->ClipToInverseRect(cornerRect);
|
||||||
|
}
|
||||||
|
|
||||||
// draw the bevel
|
// draw the bevel
|
||||||
_DrawFrame(view, rect,
|
_DrawFrame(view, rect,
|
||||||
|
|||||||
Reference in New Issue
Block a user