WIP: Rewrite code to draw the return key

This commit is contained in:
John Scipione 2012-10-18 20:39:56 -04:00
parent a12bf7d47b
commit a8c0ae81ab

View File

@ -610,68 +610,60 @@ 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);
view->ConstrainClippingRegion(&region);
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,
pressed ? BControlLook::B_ACTIVATED : 0);
topLeft.bottom = bottomLeft.top;
topLeft.right = bottomLeft.right;
rect.left = missingRect.right;
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
topRight.bottom = topLeft.bottom;
topRight.left = topLeft.right;
be_control_look->DrawLabel(view, text, rect, updateRect,
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
bottomRight.top = bottomLeft.top;
bottomRight.left = bottomLeft.right;
missingRect.right--;
missingRect.top -= 2;
region.Set(missingRect);
view->ConstrainClippingRegion(&region);
bottomLeft.OffsetBy(1, -2);
rect = originalRect;
rect.bottom = missingRect.top + 2;
be_control_look->DrawButtonFrame(view, rect, updateRect,
0.0f, 0.0f, 4.0f, 0.0f, base, background,
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_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, rect, updateRect,
0.0f, 0.0f, 4.0f, 0.0f, base,
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_LEFT_BORDER | BControlLook::B_BOTTOM_BORDER);
missingRect.left = missingRect.right;
missingRect.right++;
missingRect.top += 2;
region.Set(missingRect);
view->ConstrainClippingRegion(&region);
rect = originalRect;
rect.left = missingRect.right - 2;
rect.top = missingRect.top - 2;
be_control_look->DrawButtonFrame(view, rect, updateRect,
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->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);
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(&region);
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 = 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));
view->ConstrainClippingRegion(NULL);
}