From 184ecaf4c509dd651770aafe3dd2b2c27aad0990 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 22 Oct 2012 20:18:21 -0400 Subject: [PATCH] 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) --- src/preferences/keymap/KeyboardLayoutView.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index bbe8506c47..574e1b0672 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -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(®ion); + // 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); } }