OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/color_chooser/color_chooser_view.h" | 5 #include "ui/views/color_chooser/color_chooser_view.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (hue_ != hue) { | 257 if (hue_ != hue) { |
258 hue_ = hue; | 258 hue_ = hue; |
259 SchedulePaint(); | 259 SchedulePaint(); |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 void ColorChooserView::SaturationValueView::OnSaturationValueChanged( | 263 void ColorChooserView::SaturationValueView::OnSaturationValueChanged( |
264 SkScalar saturation, | 264 SkScalar saturation, |
265 SkScalar value) { | 265 SkScalar value) { |
266 SkScalar scalar_size = SkIntToScalar(kSaturationValueSize - 1); | 266 SkScalar scalar_size = SkIntToScalar(kSaturationValueSize - 1); |
267 int x = SkScalarFloorToInt(SkScalarMul(saturation, scalar_size)) + | 267 int x = SkScalarFloorToInt(saturation * scalar_size) + kBorderWidth; |
268 kBorderWidth; | 268 int y = SkScalarFloorToInt((SK_Scalar1 - value) * scalar_size) + kBorderWidth; |
269 int y = SkScalarFloorToInt(SkScalarMul(SK_Scalar1 - value, scalar_size)) + | |
270 kBorderWidth; | |
271 if (gfx::Point(x, y) == marker_position_) | 269 if (gfx::Point(x, y) == marker_position_) |
272 return; | 270 return; |
273 | 271 |
274 marker_position_.set_x(x); | 272 marker_position_.set_x(x); |
275 marker_position_.set_y(y); | 273 marker_position_.set_y(y); |
276 SchedulePaint(); | 274 SchedulePaint(); |
277 } | 275 } |
278 | 276 |
279 void ColorChooserView::SaturationValueView::ProcessEventAtLocation( | 277 void ColorChooserView::SaturationValueView::ProcessEventAtLocation( |
280 const gfx::Point& point) { | 278 const gfx::Point& point) { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (key_event.type() != ui::ET_KEY_PRESSED || | 464 if (key_event.type() != ui::ET_KEY_PRESSED || |
467 (key_event.key_code() != ui::VKEY_RETURN && | 465 (key_event.key_code() != ui::VKEY_RETURN && |
468 key_event.key_code() != ui::VKEY_ESCAPE)) | 466 key_event.key_code() != ui::VKEY_ESCAPE)) |
469 return false; | 467 return false; |
470 | 468 |
471 GetWidget()->Close(); | 469 GetWidget()->Close(); |
472 return true; | 470 return true; |
473 } | 471 } |
474 | 472 |
475 } // namespace views | 473 } // namespace views |
OLD | NEW |