Draw rounded inner corners for return key in Keymap.

Draw the return key with rounded inner corners instead of square, this
builds on top of the changes made in hrev44709. The secret to rounding
the corners was to draw both the edge and background of the individual
sections before drawing the button's background on top minus the
clipped out bottom left section.

+alpha4 (optionally, purely cosmetic but shouldn't hurt)
This commit is contained in:
John Scipione 2012-10-22 20:18:21 -04:00
parent c0c445f1f4
commit 184ecaf4c5
1 changed files with 27 additions and 4 deletions

View File

@ -622,7 +622,8 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
+ (key->frame.Width() - key->second_row) * fFactor - fGap - 2);
topLeft.bottom = bottomLeft.top;
topLeft.right = bottomLeft.right;
topLeft.right = bottomLeft.right + 1;
// add one to make the borders meet
topRight.bottom = topLeft.bottom;
topRight.left = topLeft.right;
@ -630,28 +631,48 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
bottomRight.top = bottomLeft.top;
bottomRight.left = bottomLeft.right;
// draw top left corner
be_control_look->DrawButtonFrame(view, topLeft, updateRect,
4.0f, 0.0f, 0.0f, 0.0f, base, background,
4.0f, 0.0f, 4.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, topLeft, updateRect,
4.0f, 0.0f, 4.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
// draw top right corner
be_control_look->DrawButtonFrame(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
be_control_look->DrawButtonBackground(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
// draw bottom right corner
be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
0.0f, 0.0f, 0.0f, 4.0f, base, background,
0.0f, 0.0f, 4.0f, 4.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
0.0f, 0.0f, 4.0f, 4.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
// Clip out the bottom left corner
// clip out the bottom left corner
bottomLeft.right += 1;
bottomLeft.top -= 2;
BRegion region(rect);
region.Exclude(bottomLeft);
view->ConstrainClippingRegion(&region);
// draw the button background
BRect bgRect = rect.InsetByCopy(2, 2);
be_control_look->DrawButtonBackground(view, bgRect, updateRect,
4.0f, 4.0f, 0.0f, 4.0f, base,
@ -660,9 +681,11 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
rect.left = bottomLeft.right;
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
// draw the button label
be_control_look->DrawLabel(view, text, rect, updateRect,
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
// reset the clipping region
view->ConstrainClippingRegion(NULL);
}
}