Commit 7c0ce602 authored by mukai@chromium.org's avatar mukai@chromium.org

Redesign the color chooser view for HiDPI devices.

- DrawPoint makes gap with the next pixel, so FillRect instead
- FillRect to draw the border rather than DrawRect.  DrawRect makes thin gap
  with the contents.
- Fill the center point of the crosshair.  That is not necessary since
  we have selected color patch, and this lack of center point looks ugly
  on HiDPI devices.

BUG=139991


Review URL: https://chromiumcodereview.appspot.com/10854039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151222 0039d316-1c4b-4281-b951-d872f2087c98
parent 4f31f672
...@@ -158,7 +158,7 @@ void ColorChooserView::HueView::OnPaint(gfx::Canvas* canvas) { ...@@ -158,7 +158,7 @@ void ColorChooserView::HueView::OnPaint(gfx::Canvas* canvas) {
hsv[1] = SK_Scalar1; hsv[1] = SK_Scalar1;
hsv[2] = SK_Scalar1; hsv[2] = SK_Scalar1;
canvas->DrawRect(gfx::Rect(kHueIndicatorSize, 0, canvas->FillRect(gfx::Rect(kHueIndicatorSize, 0,
kHueBarWidth + kBorderWidth, height() - 1), kHueBarWidth + kBorderWidth, height() - 1),
SK_ColorGRAY); SK_ColorGRAY);
int base_left = kHueIndicatorSize + kBorderWidth; int base_left = kHueIndicatorSize + kBorderWidth;
...@@ -167,8 +167,7 @@ void ColorChooserView::HueView::OnPaint(gfx::Canvas* canvas) { ...@@ -167,8 +167,7 @@ void ColorChooserView::HueView::OnPaint(gfx::Canvas* canvas) {
SkIntToScalar( SkIntToScalar(
kSaturationValueSize - 1 - y)), kSaturationValueSize - 1 - y)),
SkIntToScalar(kSaturationValueSize - 1)); SkIntToScalar(kSaturationValueSize - 1));
canvas->DrawLine(gfx::Point(base_left, y + kBorderWidth), canvas->FillRect(gfx::Rect(base_left, y + kBorderWidth, kHueBarWidth, 1),
gfx::Point(base_left + kHueBarWidth, y + kBorderWidth),
SkHSVToColor(hsv)); SkHSVToColor(hsv));
} }
...@@ -288,9 +287,7 @@ void ColorChooserView::SaturationValueView::OnPaint(gfx::Canvas* canvas) { ...@@ -288,9 +287,7 @@ void ColorChooserView::SaturationValueView::OnPaint(gfx::Canvas* canvas) {
hsv[1] = SkScalarDiv(SkIntToScalar(x), scalar_size); hsv[1] = SkScalarDiv(SkIntToScalar(x), scalar_size);
for (int y = kBorderWidth; y < height() - kBorderWidth; ++y) { for (int y = kBorderWidth; y < height() - kBorderWidth; ++y) {
hsv[2] = SK_Scalar1 - SkScalarDiv(SkIntToScalar(y), scalar_size); hsv[2] = SK_Scalar1 - SkScalarDiv(SkIntToScalar(y), scalar_size);
SkPaint paint; canvas->FillRect(gfx::Rect(x, y, 1, 1), SkHSVToColor(255, hsv));
paint.setColor(SkHSVToColor(255, hsv));
canvas->DrawPoint(gfx::Point(x, y), paint);
} }
} }
...@@ -298,32 +295,15 @@ void ColorChooserView::SaturationValueView::OnPaint(gfx::Canvas* canvas) { ...@@ -298,32 +295,15 @@ void ColorChooserView::SaturationValueView::OnPaint(gfx::Canvas* canvas) {
// marker in that case. // marker in that case.
SkColor indicator_color = SkColor indicator_color =
(marker_position_.y() > width() * 3 / 4) ? SK_ColorWHITE : SK_ColorBLACK; (marker_position_.y() > width() * 3 / 4) ? SK_ColorWHITE : SK_ColorBLACK;
// Draw a crosshair indicator but do not draw its center to see the selected canvas->FillRect(
// saturation/value. Note that the DrawLine() doesn't draw the right-bottom gfx::Rect(marker_position_.x(),
// pixel. marker_position_.y() - kSaturationValueIndicatorSize,
canvas->DrawLine( 1, kSaturationValueIndicatorSize * 2 + 1),
gfx::Point(marker_position_.x(),
marker_position_.y() - kSaturationValueIndicatorSize),
gfx::Point(marker_position_.x(),
marker_position_.y()),
indicator_color); indicator_color);
canvas->DrawLine( canvas->FillRect(
gfx::Point(marker_position_.x(), gfx::Rect(marker_position_.x() - kSaturationValueIndicatorSize,
marker_position_.y() + kSaturationValueIndicatorSize + 1), marker_position_.y(),
gfx::Point(marker_position_.x(), kSaturationValueIndicatorSize * 2 + 1, 1),
marker_position_.y() + 1),
indicator_color);
canvas->DrawLine(
gfx::Point(marker_position_.x() - kSaturationValueIndicatorSize,
marker_position_.y()),
gfx::Point(marker_position_.x(),
marker_position_.y()),
indicator_color);
canvas->DrawLine(
gfx::Point(marker_position_.x() + kSaturationValueIndicatorSize + 1,
marker_position_.y()),
gfx::Point(marker_position_.x() + 1,
marker_position_.y()),
indicator_color); indicator_color);
OnPaintBorder(canvas); OnPaintBorder(canvas);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment