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 ASH_SYSTEM_TRAY_TRAY_UTILS_H_ | |
Ben Goodger (Google)
2012/03/21 15:52:14
tray_views.h
sadrul
2012/03/21 16:16:42
Done.
| |
6 #define ASH_SYSTEM_TRAY_TRAY_UTILS_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/gfx/font.h" | |
10 #include "ui/gfx/size.h" | |
11 #include "ui/views/controls/image_view.h" | |
12 #include "ui/views/view.h" | |
13 | |
14 class SkBitmap; | |
15 | |
16 namespace ash { | |
17 namespace internal { | |
18 | |
19 // An image view with that always has a fixed width (kTrayPopupDetailsIconWidth) | |
20 class FixedWidthImageView : public views::ImageView { | |
21 public: | |
22 FixedWidthImageView(); | |
23 virtual ~FixedWidthImageView(); | |
24 | |
25 private: | |
26 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
27 | |
28 DISALLOW_COPY_AND_ASSIGN(FixedWidthImageView); | |
29 }; | |
30 | |
31 class ViewClickListener { | |
32 public: | |
33 virtual ~ViewClickListener() {} | |
34 virtual void ClickedOn(views::View* sender) = 0; | |
35 }; | |
36 | |
37 // A view that changes background color on hover, and triggers a callback in the | |
38 // associated ViewClickListener on click. | |
39 class HoverHighlightView : public views::View { | |
40 public: | |
41 explicit HoverHighlightView(ViewClickListener* listener); | |
42 virtual ~HoverHighlightView(); | |
43 | |
44 // Convenience function for adding an icon and a label. | |
45 void AddIconAndLabel(const SkBitmap& image, | |
46 const string16& text, | |
47 gfx::Font::FontStyle style); | |
48 | |
49 // Convenience function for adding a label with padding on the left for a | |
50 // blank icon. | |
51 void AddLabel(const string16& text); | |
52 | |
53 private: | |
54 // Overridden from views::View. | |
55 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | |
56 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | |
57 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | |
58 | |
59 ViewClickListener* listener_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); | |
62 }; | |
63 | |
64 } // namespace internal | |
65 } // namespace ash | |
66 | |
67 #endif // ASH_SYSTEM_TRAY_TRAY_UTILS_H_ | |
OLD | NEW |