From a8c0ae81ab8219f08ec90881d39adcf9088822b2 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 18 Oct 2012 20:39:56 -0400 Subject: [PATCH] WIP: Rewrite code to draw the return key --- src/preferences/keymap/KeyboardLayoutView.cpp | 92 +++++++++---------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index 815fe723ac..55677451b3 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -610,69 +610,61 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key, base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); } else if (key->shape == kEnterKeyShape) { BRegion region(rect); - BRect originalRect = rect; - BRect missingRect = rect; + + BRect topLeft = rect; + BRect topRight = rect; + BRect bottomLeft = rect; + BRect bottomRight = rect; // TODO: for some reason, this does not always equal the bottom of // the other keys... - missingRect.top = floorf(rect.top + bottomLeft.top = floorf(rect.top + fLayout->DefaultKeySize().height * fFactor - fGap - 1); - missingRect.right = floorf(missingRect.left + bottomLeft.right = floorf(rect.left + (key->frame.Width() - key->second_row) * fFactor - fGap - 2); - region.Exclude(missingRect); + + topLeft.bottom = bottomLeft.top; + topLeft.right = bottomLeft.right; + + topRight.bottom = topLeft.bottom; + topRight.left = topLeft.right; + + bottomRight.top = bottomLeft.top; + bottomRight.left = bottomLeft.right; + + bottomLeft.OffsetBy(1, -2); + + be_control_look->DrawButtonFrame(view, topLeft, updateRect, + 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->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->DrawButtonFrame(view, bottomRight, updateRect, + 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->DrawButtonFrame(view, bottomLeft, updateRect, base, + background, pressed ? BControlLook::B_ACTIVATED : 0, + BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER); + + region.Exclude(bottomLeft); view->ConstrainClippingRegion(®ion); - - be_control_look->DrawButtonFrame(view, rect, updateRect, - 4.0f, 4.0f, 0.0f, 0.0f, base, background, - pressed ? BControlLook::B_ACTIVATED : 0); - be_control_look->DrawButtonBackground(view, rect, updateRect, - 4.0f, 4.0f, 0.0f, 0.0f, base, + BRect bgRect = rect.InsetByCopy(2, 2); + be_control_look->DrawButtonBackground(view, bgRect, updateRect, + 4.0f, 4.0f, 0.0f, 4.0f, base, pressed ? BControlLook::B_ACTIVATED : 0); - rect.left = missingRect.right; + rect.left = bottomLeft.right; _GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text)); be_control_look->DrawLabel(view, text, rect, updateRect, base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); - missingRect.right--; - missingRect.top -= 2; - region.Set(missingRect); - view->ConstrainClippingRegion(®ion); - - rect = originalRect; - rect.bottom = missingRect.top + 2; - - be_control_look->DrawButtonFrame(view, rect, updateRect, - 0.0f, 0.0f, 4.0f, 0.0f, base, background, - pressed ? BControlLook::B_ACTIVATED : 0, - BControlLook::B_LEFT_BORDER | BControlLook::B_BOTTOM_BORDER); - be_control_look->DrawButtonBackground(view, rect, updateRect, - 0.0f, 0.0f, 4.0f, 0.0f, base, - pressed ? BControlLook::B_ACTIVATED : 0, - BControlLook::B_LEFT_BORDER | BControlLook::B_BOTTOM_BORDER); - - missingRect.left = missingRect.right; - missingRect.right++; - missingRect.top += 2; - region.Set(missingRect); - view->ConstrainClippingRegion(®ion); - - rect = originalRect; - rect.left = missingRect.right - 2; - rect.top = missingRect.top - 2; - - be_control_look->DrawButtonFrame(view, rect, updateRect, - 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, rect, 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); - view->ConstrainClippingRegion(NULL); } }