diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-11-27 11:05:57 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-11-27 14:04:21 +0100 |
commit | d134615570bd7afb045f983cdd008c5662265504 (patch) | |
tree | 75da75de8c750dd79d1d845ac83cf7ec13666a39 /android | |
parent | 7c7e044f3cd6adc8ce639d01dc083827cdd87266 (diff) |
tdf#158398 android: Draw light gray background for Calc headers
Similar to the desktop version, use a light gray background
color for the Calc header cells.
There was already code in place to draw darker gray background
to highlight the header cell when a cell in that row/column is
selected.
(The actually highlighted header cell didn't wasn't always the
correct one in a quick test, but that's independent of this change.)
Adapt that to always fill the rectangle, but use a lighter gray
(lower alpha value) when not selected.
Use a separate `Paint` object for the frame (stroke).
Set the frame color and text color to black instead of gray, for
better contrast to the light gray fill/background.
Change-Id: I0490811e928ebd1b3840242fc1aa4682b2786b00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159989
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/canvas/CalcHeaderCell.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/android/source/src/java/org/libreoffice/canvas/CalcHeaderCell.java b/android/source/src/java/org/libreoffice/canvas/CalcHeaderCell.java index eec0b5e4a88d..a285234bc8b0 100644 --- a/android/source/src/java/org/libreoffice/canvas/CalcHeaderCell.java +++ b/android/source/src/java/org/libreoffice/canvas/CalcHeaderCell.java @@ -10,6 +10,8 @@ import android.text.TextPaint; public class CalcHeaderCell extends CommonCanvasElement { private final TextPaint mTextPaint = new TextPaint(); + + private final Paint mFramePaint = new Paint(); private final Paint mBgPaint = new Paint(); private final RectF mBounds; private final Rect mTextBounds = new Rect(); @@ -17,16 +19,20 @@ public class CalcHeaderCell extends CommonCanvasElement { public CalcHeaderCell(float left, float top, float width, float height, String text, boolean selected) { mBounds = new RectF(left, top, left + width, top + height); + + mFramePaint.setStyle(Style.STROKE); + mFramePaint.setColor(Color.BLACK); + + mBgPaint.setStyle(Style.FILL); + mBgPaint.setColor(Color.GRAY); + // draw background more intensely when cell is selected if (selected) { - // if the cell is selected, display filled - mBgPaint.setStyle(Style.FILL_AND_STROKE); + mBgPaint.setAlpha(100); } else { - // if not, display only the frame - mBgPaint.setStyle(Style.STROKE); + mBgPaint.setAlpha(25); } - mBgPaint.setColor(Color.GRAY); - mBgPaint.setAlpha(100); // hard coded for now - mTextPaint.setColor(Color.GRAY); + + mTextPaint.setColor(Color.BLACK); mTextPaint.setTextSize(24f); // hard coded for now mTextPaint.setTextAlign(Paint.Align.CENTER); mText = text; @@ -54,6 +60,7 @@ public class CalcHeaderCell extends CommonCanvasElement { @Override public void onDraw(Canvas canvas) { canvas.drawRect(mBounds, mBgPaint); + canvas.drawRect(mBounds, mFramePaint); canvas.drawText(mText, mBounds.centerX(), mBounds.centerY() - mTextBounds.centerY(), mTextPaint); } } |