[haiku-commits] haiku: hrev44708 - in src: preferences/keymap kits/interface

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 20 Oct 2012 00:40:09 +0200 (CEST)

hrev44708 adds 4 changesets to branch 'master'
old head: fd720fd2da68ae0fa7a5bc4b2c66cafa1b8c29eb
new head: 9aaf8ee2032a116d615975aee444f70c64a5505b

----------------------------------------------------------------------------

4fa7671: Save and restore button clipping constraints.
  
  This fixes #8700

a12bf7d: Clipping region is preserved between Draw Button calls.
  
  Remove the code that resets the clipping region. However, the
  enter button still doesn't draw correctly, the trick it used before
  is not working with the change from the last commit.

a8c0ae8: WIP: Rewrite code to draw the return key

9aaf8ee: Draw the inner corner of the enter key with square edges.
  
  This completes the rework of the return key drawing code and fixes
  bug #8700. (+alpha4)

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 49 insertions(+), 77 deletions(-)
src/kits/interface/ControlLook.cpp            |   31 +++----
src/preferences/keymap/KeyboardLayoutView.cpp |   95 ++++++++-------------

############################################################################

Commit:      4fa767198c09b0fb3922b25ecf490b8c61fc0f93
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4fa7671
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Oct 18 00:17:07 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8700

Save and restore button clipping constraints.

This fixes #8700

----------------------------------------------------------------------------

diff --git a/src/kits/interface/ControlLook.cpp 
b/src/kits/interface/ControlLook.cpp
index 00c945e..e48c3a6 100644
--- a/src/kits/interface/ControlLook.cpp
+++ b/src/kits/interface/ControlLook.cpp
@@ -1898,15 +1898,11 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
        if (!rect.IsValid() || !rect.Intersects(updateRect))
                return;
 
-       // clipping constraints for the view
-       BRegion clipping;
-       view->GetClippingRegion(&clipping);
-
-       // intersect constraints with updateRect
-       BRegion updateClipping(updateRect);
-       clipping.IntersectWith(&updateClipping);
+       // save the clipping constraints of the view
+       view->PushState();
 
-       // clip to the intersection
+       // set cliping constraints to updateRect
+       BRegion clipping(updateRect);
        view->ConstrainClippingRegion(&clipping);
 
        // outer edge colors
@@ -2046,7 +2042,8 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
                        frameShadowColor, frameShadowColor, borders);
        }
 
-       view->ConstrainClippingRegion(NULL);
+       // restore the clipping constraints of the view
+       view->PopState();
 }
 
 
@@ -2172,15 +2169,11 @@ BControlLook::_DrawButtonBackground(BView* view, BRect& 
rect,
        if (!rect.IsValid() || !rect.Intersects(updateRect))
                return;
 
-       // clipping constraints for the view
-       BRegion clipping;
-       view->GetClippingRegion(&clipping);
-
-       // intersect constraints with updateRect
-       BRegion updateClipping(updateRect);
-       clipping.IntersectWith(&updateClipping);
+       // save the clipping constraints of the view
+       view->PushState();
 
-       // clip to the intersection
+       // set cliping constraints to updateRect
+       BRegion clipping(updateRect);
        view->ConstrainClippingRegion(&clipping);
 
        // inner bevel colors
@@ -2288,8 +2281,8 @@ BControlLook::_DrawButtonBackground(BView* view, BRect& 
rect,
        // fill in the background
        view->FillRect(rect, fillGradient);
 
-       // reset clipping constraints
-       view->ConstrainClippingRegion(NULL);
+       // restore the clipping constraints of the view
+       view->PopState();
 }
 
 

############################################################################

Commit:      a12bf7d47b99eba1319ce8092e3f5599996dd441
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a12bf7d
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Oct 18 01:11:24 2012 UTC

Clipping region is preserved between Draw Button calls.

Remove the code that resets the clipping region. However, the
enter button still doesn't draw correctly, the trick it used before
is not working with the change from the last commit.

----------------------------------------------------------------------------

diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp 
b/src/preferences/keymap/KeyboardLayoutView.cpp
index a65b7c5..815fe72 100644
--- a/src/preferences/keymap/KeyboardLayoutView.cpp
+++ b/src/preferences/keymap/KeyboardLayoutView.cpp
@@ -625,9 +625,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, 
const Key* key,
                be_control_look->DrawButtonFrame(view, rect, updateRect,
                        4.0f, 4.0f, 0.0f, 0.0f, base, background,
                        pressed ? BControlLook::B_ACTIVATED : 0);
-
-               view->ConstrainClippingRegion(&region);
-
                be_control_look->DrawButtonBackground(view, rect, updateRect,
                        4.0f, 4.0f, 0.0f, 0.0f, base,
                        pressed ? BControlLook::B_ACTIVATED : 0);
@@ -635,8 +632,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, 
const Key* key,
                rect.left = missingRect.right;
                _GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, 
sizeof(text));
 
-               view->ConstrainClippingRegion(&region);
-
                be_control_look->DrawLabel(view, text, rect, updateRect,
                        base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
 
@@ -652,9 +647,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, 
const Key* key,
                        0.0f, 0.0f, 4.0f, 0.0f, base, background,
                        pressed ? BControlLook::B_ACTIVATED : 0,
                        BControlLook::B_LEFT_BORDER | 
BControlLook::B_BOTTOM_BORDER);
-
-               view->ConstrainClippingRegion(&region);
-
                be_control_look->DrawButtonBackground(view, rect, updateRect,
                        0.0f, 0.0f, 4.0f, 0.0f, base,
                        pressed ? BControlLook::B_ACTIVATED : 0,
@@ -675,9 +667,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, 
const Key* key,
                        pressed ? BControlLook::B_ACTIVATED : 0,
                        BControlLook::B_LEFT_BORDER | 
BControlLook::B_RIGHT_BORDER
                                | BControlLook::B_BOTTOM_BORDER);
-
-               view->ConstrainClippingRegion(&region);
-
                be_control_look->DrawButtonBackground(view, rect, updateRect,
                        0.0f, 0.0f, 4.0f, 4.0f, base,
                        pressed ? BControlLook::B_ACTIVATED : 0,

############################################################################

Commit:      a8c0ae81ab8219f08ec90881d39adcf9088822b2
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a8c0ae8
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 19 00:39:56 2012 UTC

WIP: Rewrite code to draw the return key

----------------------------------------------------------------------------

diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp 
b/src/preferences/keymap/KeyboardLayoutView.cpp
index 815fe72..5567745 100644
--- a/src/preferences/keymap/KeyboardLayoutView.cpp
+++ b/src/preferences/keymap/KeyboardLayoutView.cpp
@@ -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);
 
-               rect.left = missingRect.right;
-               _GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, 
sizeof(text));
+               topLeft.bottom = bottomLeft.top;
+               topLeft.right = bottomLeft.right;
 
-               be_control_look->DrawLabel(view, text, rect, updateRect,
-                       base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
+               topRight.bottom = topLeft.bottom;
+               topRight.left = topLeft.right;
 
-               missingRect.right--;
-               missingRect.top -= 2;
-               region.Set(missingRect);
-               view->ConstrainClippingRegion(&region);
+               bottomRight.top = bottomLeft.top;
+               bottomRight.left = bottomLeft.right;
 
-               rect = originalRect;
-               rect.bottom = missingRect.top + 2;
+               bottomLeft.OffsetBy(1, -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_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_BOTTOM_BORDER);
+                       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);
 
-               missingRect.left = missingRect.right;
-               missingRect.right++;
-               missingRect.top += 2;
-               region.Set(missingRect);
+               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 = originalRect;
-               rect.left = missingRect.right - 2;
-               rect.top = missingRect.top - 2;
+               rect.left = bottomLeft.right;
+               _GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, 
sizeof(text));
 
-               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);
+               be_control_look->DrawLabel(view, text, rect, updateRect,
+                       base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
 
                view->ConstrainClippingRegion(NULL);
        }

############################################################################

Revision:    hrev44708
Commit:      9aaf8ee2032a116d615975aee444f70c64a5505b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9aaf8ee
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 19 22:36:19 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8700

Draw the inner corner of the enter key with square edges.

This completes the rework of the return key drawing code and fixes
bug #8700. (+alpha4)

----------------------------------------------------------------------------

diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp 
b/src/preferences/keymap/KeyboardLayoutView.cpp
index 5567745..bbe8506 100644
--- a/src/preferences/keymap/KeyboardLayoutView.cpp
+++ b/src/preferences/keymap/KeyboardLayoutView.cpp
@@ -609,8 +609,6 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, 
const Key* key,
                be_control_look->DrawLabel(view, text, rect, updateRect,
                        base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
        } else if (key->shape == kEnterKeyShape) {
-               BRegion region(rect);
-
                BRect topLeft = rect;
                BRect topRight = rect;
                BRect bottomLeft = rect;
@@ -632,10 +630,8 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect 
updateRect, const Key* key,
                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,
+                       4.0f, 0.0f, 0.0f, 0.0f, base, background,
                        pressed ? BControlLook::B_ACTIVATED : 0,
                        BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
                                | BControlLook::B_BOTTOM_BORDER);
@@ -644,16 +640,18 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect 
updateRect, const Key* key,
                        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,
+                       0.0f, 0.0f, 0.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);
 
+               // Clip out the bottom left corner
+               bottomLeft.right += 1;
+               bottomLeft.top -= 2;
+               BRegion region(rect);
                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,


Other related posts:

  • » [haiku-commits] haiku: hrev44708 - in src: preferences/keymap kits/interface - jscipione