Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4b8e7d9 authored by Aga Madurska's avatar Aga Madurska Committed by android-build-merger
Browse files

Use correct bounds for scroll bar rendering.

am: 8cc883de

Change-Id: Ie82427a678241e7237144bbe76493c055a17bc2d
parents 03e641e6 8cc883de
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Rect;

/**
 * Helper class for drawing round scroll bars on round Wear devices.
@@ -53,7 +54,7 @@ class RoundScrollbarRenderer {
        mParent = parent;
    }

    public void drawRoundScrollbars(Canvas canvas, float alpha) {
    public void drawRoundScrollbars(Canvas canvas, float alpha, Rect bounds) {
        if (alpha == 0) {
            return;
        }
@@ -83,10 +84,11 @@ class RoundScrollbarRenderer {

        // Draw the track and the scroll bar.
        mRect.set(
                0 + thumbWidth / 2,
                0 + thumbWidth / 2,
                mParent.getWidth() - thumbWidth / 2,
                mParent.getHeight() - thumbWidth / 2);
                bounds.left - thumbWidth / 2,
                bounds.top,
                bounds.right - thumbWidth / 2,
                bounds.bottom);

        canvas.drawArc(mRect, -SCROLLBAR_ANGLE_RANGE / 2, SCROLLBAR_ANGLE_RANGE, false,
                mTrackPaint);
        canvas.drawArc(mRect, startAngle, sweepAngle, false, mThumbPaint);
+34 −1
Original line number Diff line number Diff line
@@ -14770,6 +14770,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    private void getVerticalScrollBarBounds(Rect bounds) {
        if (mRoundScrollbarRenderer == null) {
            getStraightVerticalScrollBarBounds(bounds);
        } else {
            getRoundVerticalScrollBarBounds(bounds);
        }
    }
    private void getRoundVerticalScrollBarBounds(Rect bounds) {
        final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0;
        int verticalScrollbarPosition = mVerticalScrollbarPosition;
        if (verticalScrollbarPosition == SCROLLBAR_POSITION_DEFAULT) {
            verticalScrollbarPosition = isLayoutRtl() ?
                    SCROLLBAR_POSITION_LEFT : SCROLLBAR_POSITION_RIGHT;
        }
        final int width = mRight - mLeft;
        final int height = mBottom - mTop;
        switch (verticalScrollbarPosition) {
            default:
            case SCROLLBAR_POSITION_RIGHT:
                bounds.left = mScrollX - (mUserPaddingRight & inside);
                break;
            case SCROLLBAR_POSITION_LEFT:
                bounds.left = mScrollX + (mUserPaddingLeft & inside);
                break;
        }
        bounds.top = mScrollY + (mPaddingTop & inside);
        bounds.right = bounds.left + width;
        bounds.bottom = mScrollY + height - (mUserPaddingBottom & inside);
    }
    private void getStraightVerticalScrollBarBounds(Rect bounds) {
        final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0;
        final int size = getVerticalScrollbarWidth();
        int verticalScrollbarPosition = mVerticalScrollbarPosition;
@@ -14848,8 +14879,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // Fork out the scroll bar drawing for round wearable devices.
            if (mRoundScrollbarRenderer != null) {
                if (drawVerticalScrollBar) {
                    final Rect bounds = cache.mScrollBarBounds;
                    getVerticalScrollBarBounds(bounds);
                    mRoundScrollbarRenderer.drawRoundScrollbars(
                            canvas, (float) cache.scrollBar.getAlpha() / 255f);
                            canvas, (float) cache.scrollBar.getAlpha() / 255f, bounds);
                    if (invalidate) {
                        invalidate();
                    }