OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_COLOR_CHOOSER_COLOR_CHOOSER_VIEW_H_ | |
6 #define UI_VIEWS_COLOR_CHOOSER_COLOR_CHOOSER_VIEW_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "third_party/skia/include/core/SkColor.h" | |
12 #include "third_party/skia/include/core/SkScalar.h" | |
13 #include "ui/views/controls/textfield/textfield_controller.h" | |
14 #include "ui/views/views_export.h" | |
15 #include "ui/views/widget/widget_delegate.h" | |
16 | |
17 namespace views { | |
18 | |
19 class ColorChooserListener; | |
20 class KeyEvent; | |
21 class Textfield; | |
22 | |
23 // ColorChooserView provides the UI to choose a color by mouse and/or keyboard. | |
24 // It is typically used for <input type="color">. Currently the user can | |
25 // choose a color by dragging over the bar for hue and the area for saturation | |
26 // and value. See also: | |
27 // http://dev.chromium.org/developers/design-documents/aura/ash-color-chooser | |
Peter Kasting
2012/06/19 21:10:31
Nit: It's easy for external documentation to be mo
Jun Mukai
2012/06/20 09:29:08
Then removed the link itself. I think the existin
| |
28 class VIEWS_EXPORT ColorChooserView : public WidgetDelegateView, | |
29 public TextfieldController { | |
30 public: | |
31 ColorChooserView(ColorChooserListener* listener, SkColor initial_color); | |
32 virtual ~ColorChooserView(); | |
33 | |
34 // Called when its owning window will be closed. | |
35 void OnOwningWindowClosed(); | |
36 | |
37 // Called when its color value is changed in the web contents. | |
38 void OnColorChanged(SkColor color); | |
39 | |
40 // Called when the user chooses a hue from the UI. | |
41 void OnHueChosen(float hue); | |
42 | |
43 // Called when the user chooses saturation/value from the UI. | |
44 void OnSaturationValueChosen(float saturation, float value); | |
45 | |
46 float hue() const { return hsv_[0]; } | |
47 float saturation() const { return hsv_[1]; } | |
48 float value() const { return hsv_[2]; } | |
49 | |
50 private: | |
51 class HueView; | |
52 class SaturationValueView; | |
53 | |
54 // WidgetDelegate overrides: | |
55 virtual ui::ModalType GetModalType() const OVERRIDE; | |
56 virtual void WindowClosing() OVERRIDE; | |
57 virtual View* GetContentsView() OVERRIDE; | |
58 | |
59 // TextfieldController overrides: | |
60 virtual void ContentsChanged(Textfield* sender, | |
61 const string16& new_contents) OVERRIDE; | |
62 virtual bool HandleKeyEvent(Textfield* sender, | |
63 const KeyEvent& key_event) OVERRIDE; | |
64 | |
65 SkScalar hsv_[3]; | |
66 ColorChooserListener* listener_; | |
67 HueView* hue_; | |
68 SaturationValueView* saturation_value_; | |
69 Textfield* textfield_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ColorChooserView); | |
72 }; | |
73 | |
74 } // namespace views | |
75 | |
76 #endif // UI_VIEWS_COLOR_CHOOSER_COLOR_CHOOSER_VIEW_H_ | |
OLD | NEW |