diff options
author | paulnavin@google.com <paulnavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 18:10:00 +0000 |
---|---|---|
committer | paulnavin@google.com <paulnavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 18:10:00 +0000 |
commit | 59ef357e90b88c3acdbe9e4f6507d60ca879fec8 (patch) | |
tree | b9172a052be957d9c5bc9a9b03667d5411d79633 /ui/android | |
parent | eb73d15094cca4c24757f80b24940b3059a79210 (diff) | |
download | chromium_src-59ef357e90b88c3acdbe9e4f6507d60ca879fec8.zip chromium_src-59ef357e90b88c3acdbe9e4f6507d60ca879fec8.tar.gz chromium_src-59ef357e90b88c3acdbe9e4f6507d60ca879fec8.tar.bz2 |
ColorPicker - Adding grid border lines.
I've added border lines in between the colored rectangles in the ColorPicker's
simple view. These border lines match the external borders from the "More"
button update (https://codereview.chromium.org/20084004).
BUG=263808
Review URL: https://chromiumcodereview.appspot.com/19690009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/android')
5 files changed, 54 insertions, 10 deletions
diff --git a/ui/android/java/res/drawable/color_picker_border.xml b/ui/android/java/res/drawable/color_picker_border.xml index 4318c43..b48be9b 100644 --- a/ui/android/java/res/drawable/color_picker_border.xml +++ b/ui/android/java/res/drawable/color_picker_border.xml @@ -6,5 +6,5 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00000000"/> - <stroke android:width="1px" android:color="#B0B0B0" /> + <stroke android:width="1px" android:color="@color/color_picker_border_color" /> </shape>
\ No newline at end of file diff --git a/ui/android/java/res/layout/color_picker_dialog_content.xml b/ui/android/java/res/layout/color_picker_dialog_content.xml index fb7bd94..8aa4dba 100644 --- a/ui/android/java/res/layout/color_picker_dialog_content.xml +++ b/ui/android/java/res/layout/color_picker_dialog_content.xml @@ -24,7 +24,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/color_picker_border" - android:padding="2px"> + android:paddingStart="1px" + android:paddingEnd="1px" + android:paddingTop="1px"> <org.chromium.ui.ColorPickerSimple android:id="@+id/color_picker_simple" @@ -38,9 +40,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/color_picker_simple_border" android:background="@drawable/color_picker_border" - android:paddingStart="1px" - android:paddingEnd="1px" - android:paddingBottom="1px"> + android:padding="1px"> <org.chromium.ui.ColorPickerMoreButton android:id="@+id/more_colors_button" diff --git a/ui/android/java/res/values/colors.xml b/ui/android/java/res/values/colors.xml new file mode 100644 index 0000000..be5896d --- /dev/null +++ b/ui/android/java/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2013 The Chromium Authors. All rights reserved. + + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. +--> +<resources> + <color name="color_picker_border_color">#B0B0B0</color> +</resources> + diff --git a/ui/android/java/resource_map/org/chromium/ui/R.java b/ui/android/java/resource_map/org/chromium/ui/R.java index d170420..c722c14 100644 --- a/ui/android/java/resource_map/org/chromium/ui/R.java +++ b/ui/android/java/resource_map/org/chromium/ui/R.java @@ -53,4 +53,7 @@ public final class R { public static final class style { public static int AutofillPopupWindow; } + public static final class color { + public static int color_picker_border_color; + } } diff --git a/ui/android/java/src/org/chromium/ui/ColorPickerSimple.java b/ui/android/java/src/org/chromium/ui/ColorPickerSimple.java index 976471b..979405a 100644 --- a/ui/android/java/src/org/chromium/ui/ColorPickerSimple.java +++ b/ui/android/java/src/org/chromium/ui/ColorPickerSimple.java @@ -34,6 +34,8 @@ public class ColorPickerSimple extends View { Color.WHITE }; + private Paint mBorderPaint; + private Rect[] mBounds; private Paint[] mPaints; @@ -75,6 +77,10 @@ public class ColorPickerSimple extends View { mPaints[i] = newPaint; } + mBorderPaint = new Paint(); + int borderColor = getContext().getResources().getColor(R.color.color_picker_border_color); + mBorderPaint.setColor(borderColor); + // Responds to the user touching the grid and works out which color has been chosen as // a result, depending on the X,Y coordinate. Note that we respond to the click event // here, but the onClick() method doesn't provide us with the X,Y coordinates, so we @@ -99,6 +105,7 @@ public class ColorPickerSimple extends View { /** * Draws the grid of colors, based on the rectangles calculated in onSizeChanged(). + * Also draws borders in between the colored rectangles. * * @param canvas The canvas the colors are drawn onto. */ @@ -107,9 +114,31 @@ public class ColorPickerSimple extends View { if (mBounds == null || mPaints == null) { return; } + + canvas.drawColor(Color.WHITE); + + // Draw the actual colored rectangles. for (int i = 0; i < GRID_CELL_COUNT; ++i) { canvas.drawRect(mBounds[i], mPaints[i]); } + + // Draw 1px borders between the rows. + for (int i = 0; i < ROW_COUNT - 1; ++i) { + canvas.drawLine(0, + mBounds[i * COLUMN_COUNT].bottom + 1, + getWidth(), + mBounds[i * COLUMN_COUNT].bottom + 1, + mBorderPaint); + } + + // Draw 1px borders between the columns. + for (int j = 0; j < COLUMN_COUNT - 1; ++j) { + canvas.drawLine(mBounds[j].right + 1, + 0, + mBounds[j].right + 1, + getHeight(), + mBorderPaint); + } } /** @@ -137,18 +166,20 @@ public class ColorPickerSimple extends View { /** * Calculates the sizes and positions of the cells in the grid, splitting - * them up as evenly as possible. + * them up as evenly as possible. Leaves 3 pixels between each cell so that + * we can draw a border between them as well, and leaves a pixel around the + * edge. */ private void calculateGrid(final int width, final int height) { mBounds = new Rect[GRID_CELL_COUNT]; for (int i = 0; i < ROW_COUNT; ++i) { for (int j = 0; j < COLUMN_COUNT; ++j) { - int left = j * width / COLUMN_COUNT; - int right = (j + 1) * width / COLUMN_COUNT; + int left = j * (width + 1) / COLUMN_COUNT + 1; + int right = (j + 1) * (width + 1) / COLUMN_COUNT - 2; - int top = i * height / ROW_COUNT; - int bottom = (i + 1) * height / ROW_COUNT; + int top = i * (height + 1) / ROW_COUNT + 1; + int bottom = (i + 1) * (height + 1) / ROW_COUNT - 2; Rect rect = new Rect(left, top, right, bottom); mBounds[(i * COLUMN_COUNT) + j] = rect; |