Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: ui/views/color_chooser/color_chooser_view.h

Issue 10442020: Initial implementation of ColorChooser for Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
27 class VIEWS_EXPORT ColorChooserView : public WidgetDelegateView,
28 public TextfieldController {
29 public:
30 ColorChooserView(ColorChooserListener* listener, SkColor initial_color);
31 virtual ~ColorChooserView();
32
33 // Called when its color value is changed in the web contents.
34 void OnColorChanged(SkColor color);
35
36 // Called when the user chooses a hue from the UI.
37 void OnHueChosen(SkScalar hue);
38
39 // Called when the user chooses saturation/value from the UI.
40 void OnSaturationValueChosen(SkScalar saturation, SkScalar value);
41
42 float hue() const { return hsv_[0]; }
43 float saturation() const { return hsv_[1]; }
44 float value() const { return hsv_[2]; }
45
46 private:
47 class HueView;
48 class SaturationValueView;
49
50 // WidgetDelegate overrides:
51 virtual View* GetInitiallyFocusedView() OVERRIDE;
52 virtual ui::ModalType GetModalType() const OVERRIDE;
53 virtual void WindowClosing() OVERRIDE;
54 virtual View* GetContentsView() OVERRIDE;
55
56 // TextfieldController overrides:
57 virtual void ContentsChanged(Textfield* sender,
58 const string16& new_contents) OVERRIDE;
59 virtual bool HandleKeyEvent(Textfield* sender,
60 const KeyEvent& key_event) OVERRIDE;
61
62 // The current color in HSV coordinate.
63 SkScalar hsv_[3];
64
65 // The pointer to the current color chooser for callbacks. It doesn't take
66 // ownership on |listener_| so the user of this class should take care of
67 // its lifetime. See chrome/browser/ui/browser.cc for example.
68 ColorChooserListener* listener_;
69
70 // Child views. These are owned as part of the normal views hierarchy.
71 // The view of hue chooser.
72 HueView* hue_;
73
74 // The view of saturation/value choosing area.
75 SaturationValueView* saturation_value_;
76
77 // The textfield to write the color explicitly.
78 Textfield* textfield_;
79
80 DISALLOW_COPY_AND_ASSIGN(ColorChooserView);
81 };
82
83 } // namespace views
84
85 #endif // UI_VIEWS_COLOR_CHOOSER_COLOR_CHOOSER_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/color_chooser/color_chooser_listener.h ('k') | ui/views/color_chooser/color_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698