| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 public: | 59 public: |
| 60 virtual ~LocatedEventHandlerView() {} | 60 virtual ~LocatedEventHandlerView() {} |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 LocatedEventHandlerView() {} | 63 LocatedEventHandlerView() {} |
| 64 | 64 |
| 65 // Handles an event (mouse or gesture) at the specified location. | 65 // Handles an event (mouse or gesture) at the specified location. |
| 66 virtual void ProcessEventAtLocation(const gfx::Point& location) = 0; | 66 virtual void ProcessEventAtLocation(const gfx::Point& location) = 0; |
| 67 | 67 |
| 68 // views::View overrides: | 68 // views::View overrides: |
| 69 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 69 virtual bool OnMousePressed(const ui::MouseEvent& event) override { |
| 70 ProcessEventAtLocation(event.location()); | 70 ProcessEventAtLocation(event.location()); |
| 71 return true; | 71 return true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE { | 74 virtual bool OnMouseDragged(const ui::MouseEvent& event) override { |
| 75 ProcessEventAtLocation(event.location()); | 75 ProcessEventAtLocation(event.location()); |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 79 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 80 if (event->type() == ui::ET_GESTURE_TAP || | 80 if (event->type() == ui::ET_GESTURE_TAP || |
| 81 event->type() == ui::ET_GESTURE_TAP_DOWN || | 81 event->type() == ui::ET_GESTURE_TAP_DOWN || |
| 82 event->IsScrollGestureEvent()) { | 82 event->IsScrollGestureEvent()) { |
| 83 ProcessEventAtLocation(event->location()); | 83 ProcessEventAtLocation(event->location()); |
| 84 event->SetHandled(); | 84 event->SetHandled(); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(LocatedEventHandlerView); | 88 DISALLOW_COPY_AND_ASSIGN(LocatedEventHandlerView); |
| 89 }; | 89 }; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 116 // The class to choose the hue of the color. It draws a vertical bar and | 116 // The class to choose the hue of the color. It draws a vertical bar and |
| 117 // the indicator for the currently selected hue. | 117 // the indicator for the currently selected hue. |
| 118 class ColorChooserView::HueView : public LocatedEventHandlerView { | 118 class ColorChooserView::HueView : public LocatedEventHandlerView { |
| 119 public: | 119 public: |
| 120 explicit HueView(ColorChooserView* chooser_view); | 120 explicit HueView(ColorChooserView* chooser_view); |
| 121 | 121 |
| 122 void OnHueChanged(SkScalar hue); | 122 void OnHueChanged(SkScalar hue); |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 // LocatedEventHandlerView overrides: | 125 // LocatedEventHandlerView overrides: |
| 126 virtual void ProcessEventAtLocation(const gfx::Point& point) OVERRIDE; | 126 virtual void ProcessEventAtLocation(const gfx::Point& point) override; |
| 127 | 127 |
| 128 // View overrides: | 128 // View overrides: |
| 129 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 129 virtual gfx::Size GetPreferredSize() const override; |
| 130 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 130 virtual void OnPaint(gfx::Canvas* canvas) override; |
| 131 | 131 |
| 132 ColorChooserView* chooser_view_; | 132 ColorChooserView* chooser_view_; |
| 133 int level_; | 133 int level_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(HueView); | 135 DISALLOW_COPY_AND_ASSIGN(HueView); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 ColorChooserView::HueView::HueView(ColorChooserView* chooser_view) | 138 ColorChooserView::HueView::HueView(ColorChooserView* chooser_view) |
| 139 : chooser_view_(chooser_view), | 139 : chooser_view_(chooser_view), |
| 140 level_(0) { | 140 level_(0) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // value. | 228 // value. |
| 229 class ColorChooserView::SaturationValueView : public LocatedEventHandlerView { | 229 class ColorChooserView::SaturationValueView : public LocatedEventHandlerView { |
| 230 public: | 230 public: |
| 231 explicit SaturationValueView(ColorChooserView* chooser_view); | 231 explicit SaturationValueView(ColorChooserView* chooser_view); |
| 232 | 232 |
| 233 void OnHueChanged(SkScalar hue); | 233 void OnHueChanged(SkScalar hue); |
| 234 void OnSaturationValueChanged(SkScalar saturation, SkScalar value); | 234 void OnSaturationValueChanged(SkScalar saturation, SkScalar value); |
| 235 | 235 |
| 236 private: | 236 private: |
| 237 // LocatedEventHandlerView overrides: | 237 // LocatedEventHandlerView overrides: |
| 238 virtual void ProcessEventAtLocation(const gfx::Point& point) OVERRIDE; | 238 virtual void ProcessEventAtLocation(const gfx::Point& point) override; |
| 239 | 239 |
| 240 // View overrides: | 240 // View overrides: |
| 241 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 241 virtual gfx::Size GetPreferredSize() const override; |
| 242 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 242 virtual void OnPaint(gfx::Canvas* canvas) override; |
| 243 | 243 |
| 244 ColorChooserView* chooser_view_; | 244 ColorChooserView* chooser_view_; |
| 245 SkScalar hue_; | 245 SkScalar hue_; |
| 246 gfx::Point marker_position_; | 246 gfx::Point marker_position_; |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(SaturationValueView); | 248 DISALLOW_COPY_AND_ASSIGN(SaturationValueView); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 ColorChooserView::SaturationValueView::SaturationValueView( | 251 ColorChooserView::SaturationValueView::SaturationValueView( |
| 252 ColorChooserView* chooser_view) | 252 ColorChooserView* chooser_view) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 const ui::KeyEvent& key_event) { | 476 const ui::KeyEvent& key_event) { |
| 477 if (key_event.key_code() != ui::VKEY_RETURN && | 477 if (key_event.key_code() != ui::VKEY_RETURN && |
| 478 key_event.key_code() != ui::VKEY_ESCAPE) | 478 key_event.key_code() != ui::VKEY_ESCAPE) |
| 479 return false; | 479 return false; |
| 480 | 480 |
| 481 GetWidget()->Close(); | 481 GetWidget()->Close(); |
| 482 return true; | 482 return true; |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace views | 485 } // namespace views |
| OLD | NEW |