ControlLook: Add side parameter to tab drawing functions.
* This allows drawing tabs on any side of the view. Signed-off-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
88510bc040
commit
2332ebfd52
@@ -288,12 +288,14 @@ public:
|
|||||||
virtual void DrawActiveTab(BView* view, BRect& rect,
|
virtual void DrawActiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS,
|
||||||
|
uint32 side = B_TOP_BORDER);
|
||||||
|
|
||||||
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS,
|
||||||
|
uint32 side = B_TOP_BORDER);
|
||||||
|
|
||||||
/*virtual*/ void DrawSplitter(BView* view, BRect& rect,
|
/*virtual*/ void DrawSplitter(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
|
|||||||
@@ -1355,7 +1355,7 @@ BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
|
|||||||
|
|
||||||
void
|
void
|
||||||
BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders)
|
const rgb_color& base, uint32 flags, uint32 borders, uint32 side)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
@@ -1409,40 +1409,118 @@ BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
BRect leftTopCorner(rect);
|
BRect leftTopCorner(rect);
|
||||||
leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
|
leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
|
||||||
leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
|
leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
|
||||||
clipping.Exclude(leftTopCorner);
|
|
||||||
|
|
||||||
// draw the left top corner
|
|
||||||
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
|
||||||
edgeShadowColor, frameLightColor, bevelLightColor,
|
|
||||||
fillGradient);
|
|
||||||
|
|
||||||
// right top corner dimensions
|
// right top corner dimensions
|
||||||
BRect rightTopCorner(rect);
|
BRect rightTopCorner(rect);
|
||||||
rightTopCorner.right = floorf(rect.right);
|
|
||||||
rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
|
rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
|
||||||
rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
|
rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
|
||||||
clipping.Exclude(rightTopCorner);
|
|
||||||
|
|
||||||
// draw the right top corner
|
// left bottom corner dimensions
|
||||||
_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
|
BRect leftBottomCorner(rect);
|
||||||
edgeShadowColor, edgeLightColor, frameLightColor,
|
leftBottomCorner.right = floorf(leftBottomCorner.left + kRoundCornerRadius);
|
||||||
frameShadowColor, bevelLightColor, bevelShadowColor,
|
leftBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
|
||||||
fillGradient);
|
|
||||||
|
// right bottom corner dimensions
|
||||||
|
BRect rightBottomCorner(rect);
|
||||||
|
rightBottomCorner.left = floorf(rightBottomCorner.right
|
||||||
|
- kRoundCornerRadius);
|
||||||
|
rightBottomCorner.top = floorf(rect.bottom - kRoundCornerRadius);
|
||||||
|
|
||||||
|
switch (side) {
|
||||||
|
case B_TOP_BORDER:
|
||||||
|
clipping.Exclude(leftTopCorner);
|
||||||
|
clipping.Exclude(rightTopCorner);
|
||||||
|
|
||||||
|
// draw the left top corner
|
||||||
|
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
||||||
|
edgeShadowColor, frameLightColor, bevelLightColor,
|
||||||
|
fillGradient);
|
||||||
|
// draw the right top corner
|
||||||
|
_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
|
||||||
|
edgeShadowColor, edgeLightColor, frameLightColor,
|
||||||
|
frameShadowColor, bevelLightColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
break;
|
||||||
|
case B_BOTTOM_BORDER:
|
||||||
|
clipping.Exclude(leftBottomCorner);
|
||||||
|
clipping.Exclude(rightBottomCorner);
|
||||||
|
|
||||||
|
// draw the left top corner
|
||||||
|
_DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
|
||||||
|
edgeShadowColor, edgeLightColor, frameLightColor,
|
||||||
|
frameShadowColor, bevelLightColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
// draw the right top corner
|
||||||
|
_DrawRoundCornerRightBottom(view, rightBottomCorner, updateRect,
|
||||||
|
base, edgeLightColor, frameShadowColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
break;
|
||||||
|
case B_LEFT_BORDER:
|
||||||
|
clipping.Exclude(leftTopCorner);
|
||||||
|
clipping.Exclude(leftBottomCorner);
|
||||||
|
|
||||||
|
// draw the left top corner
|
||||||
|
_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
|
||||||
|
edgeShadowColor, frameLightColor, bevelLightColor,
|
||||||
|
fillGradient);
|
||||||
|
// draw the left top corner
|
||||||
|
_DrawRoundCornerLeftBottom(view, leftBottomCorner, updateRect, base,
|
||||||
|
edgeShadowColor, edgeLightColor, frameLightColor,
|
||||||
|
frameShadowColor, bevelLightColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
break;
|
||||||
|
case B_RIGHT_BORDER:
|
||||||
|
clipping.Exclude(rightTopCorner);
|
||||||
|
clipping.Exclude(rightBottomCorner);
|
||||||
|
|
||||||
|
// draw the right top corner
|
||||||
|
_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
|
||||||
|
edgeShadowColor, edgeLightColor, frameLightColor,
|
||||||
|
frameShadowColor, bevelLightColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
// draw the right top corner
|
||||||
|
_DrawRoundCornerRightBottom(view, rightBottomCorner, updateRect,
|
||||||
|
base, edgeLightColor, frameShadowColor, bevelShadowColor,
|
||||||
|
fillGradient);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// clip out the corners
|
// clip out the corners
|
||||||
view->ConstrainClippingRegion(&clipping);
|
view->ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
|
uint32 bordersToDraw = 0;
|
||||||
|
switch (side) {
|
||||||
|
case B_TOP_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
|
||||||
|
break;
|
||||||
|
case B_BOTTOM_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
|
||||||
|
break;
|
||||||
|
case B_LEFT_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
|
||||||
|
break;
|
||||||
|
case B_RIGHT_BORDER:
|
||||||
|
bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// draw the rest of frame and fill
|
// draw the rest of frame and fill
|
||||||
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
|
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
|
||||||
edgeLightColor,
|
edgeLightColor, borders & bordersToDraw);
|
||||||
borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
|
if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
|
||||||
if ((borders & B_LEFT_BORDER) == 0)
|
if ((borders & B_LEFT_BORDER) == 0)
|
||||||
rect.left++;
|
rect.left++;
|
||||||
if ((borders & B_RIGHT_BORDER) == 0)
|
if ((borders & B_RIGHT_BORDER) == 0)
|
||||||
rect.right--;
|
rect.right--;
|
||||||
|
} else if (side == B_LEFT_BORDER || side == B_RIGHT_BORDER) {
|
||||||
|
if ((borders & B_TOP_BORDER) == 0)
|
||||||
|
rect.top++;
|
||||||
|
if ((borders & B_BOTTOM_BORDER) == 0)
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
|
||||||
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
||||||
frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
|
frameShadowColor, bordersToDraw);
|
||||||
|
|
||||||
_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
|
_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
|
||||||
bevelShadowColor);
|
bevelShadowColor);
|
||||||
@@ -1456,7 +1534,7 @@ BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
|
|
||||||
void
|
void
|
||||||
BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders)
|
const rgb_color& base, uint32 flags, uint32 borders, uint32 side)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
@@ -1491,26 +1569,53 @@ BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
fillGradient.AddColor(tint_color(base, 1.08), 255);
|
fillGradient.AddColor(tint_color(base, 1.08), 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 bordersToDraw = 0;
|
||||||
|
switch (side) {
|
||||||
|
case B_TOP_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
|
||||||
|
rect.top += 4;
|
||||||
|
break;
|
||||||
|
case B_BOTTOM_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
|
||||||
|
rect.bottom -= 4;
|
||||||
|
break;
|
||||||
|
case B_LEFT_BORDER:
|
||||||
|
bordersToDraw = (B_LEFT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
|
||||||
|
rect.left += 4;
|
||||||
|
break;
|
||||||
|
case B_RIGHT_BORDER:
|
||||||
|
bordersToDraw = (B_RIGHT_BORDER | B_BOTTOM_BORDER | B_TOP_BORDER);
|
||||||
|
rect.right -= 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// active tabs stand out at the top, but this is an inactive tab
|
// active tabs stand out at the top, but this is an inactive tab
|
||||||
view->SetHighColor(base);
|
view->SetHighColor(base);
|
||||||
view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
|
view->FillRect(rect);
|
||||||
rect.top += 4;
|
|
||||||
|
|
||||||
// frame and fill
|
// frame and fill
|
||||||
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
|
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
|
||||||
edgeLightColor,
|
edgeLightColor, borders & bordersToDraw);
|
||||||
borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
|
|
||||||
|
|
||||||
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
||||||
frameShadowColor,
|
frameShadowColor, borders & bordersToDraw);
|
||||||
borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
|
|
||||||
|
|
||||||
if (rect.IsValid()) {
|
if (rect.IsValid()) {
|
||||||
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
|
||||||
bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
|
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
||||||
|
bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
|
||||||
|
} else if (side == B_LEFT_BORDER || side == B_RIGHT_BORDER) {
|
||||||
|
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
||||||
|
bevelLightColor, bevelLightColor, B_TOP_BORDER & ~borders);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((B_LEFT_BORDER & ~borders) != 0)
|
if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
|
||||||
rect.left++;
|
if ((B_LEFT_BORDER & ~borders) != 0)
|
||||||
|
rect.left++;
|
||||||
|
} else if (side == B_LEFT_BORDER || side == B_RIGHT_BORDER) {
|
||||||
|
if ((B_TOP_BORDER & ~borders) != 0)
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view->FillRect(rect, fillGradient);
|
view->FillRect(rect, fillGradient);
|
||||||
|
|||||||
Reference in New Issue
Block a user