WIP: Rewrite code to draw the return key
This commit is contained in:
parent
a12bf7d47b
commit
a8c0ae81ab
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user