diff options
Diffstat (limited to 'chromium/ash/system/tray/hover_highlight_view.h')
-rw-r--r-- | chromium/ash/system/tray/hover_highlight_view.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/chromium/ash/system/tray/hover_highlight_view.h b/chromium/ash/system/tray/hover_highlight_view.h new file mode 100644 index 00000000000..e19c3ef77f1 --- /dev/null +++ b/chromium/ash/system/tray/hover_highlight_view.h @@ -0,0 +1,93 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ +#define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ + +#include "ash/system/tray/actionable_view.h" +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/gfx/font.h" + +namespace views { +class Label; +} + +namespace ash { +namespace internal { + +class ViewClickListener; + +// A view that changes background color on hover, and triggers a callback in the +// associated ViewClickListener on click. The view can also be forced to +// maintain a fixed height. +class HoverHighlightView : public ActionableView { + public: + explicit HoverHighlightView(ViewClickListener* listener); + virtual ~HoverHighlightView(); + + // Convenience function for adding an icon and a label. This also sets the + // accessible name. + void AddIconAndLabel(const gfx::ImageSkia& image, + const base::string16& text, + gfx::Font::FontStyle style); + + // Convenience function for adding a label with padding on the left for a + // blank icon. This also sets the accessible name. + // Returns label after parenting it. + views::Label* AddLabel(const base::string16& text, + gfx::Font::FontStyle style); + + // Convenience function for adding an optional check and a label. In the + // absence of a check, padding is added to align with checked items. + // Returns label after parenting it. + views::Label* AddCheckableLabel(const base::string16& text, + gfx::Font::FontStyle style, + bool checked); + + // Allows view to expand its height. + // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. + void SetExpandable(bool expandable); + + void set_highlight_color(SkColor color) { highlight_color_ = color; } + void set_default_color(SkColor color) { default_color_ = color; } + void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } + void set_text_default_color(SkColor color) { text_default_color_ = color; } + + views::Label* text_label() { return text_label_; } + + bool hover() const { return hover_; } + + private: + // Overridden from ActionableView: + virtual bool PerformAction(const ui::Event& event) OVERRIDE; + + // Overridden from views::View. + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual int GetHeightForWidth(int width) OVERRIDE; + virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; + virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; + virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; + virtual void OnFocus() OVERRIDE; + + ViewClickListener* listener_; + views::Label* text_label_; + SkColor highlight_color_; + SkColor default_color_; + SkColor text_highlight_color_; + SkColor text_default_color_; + bool hover_; + bool expandable_; + bool checkable_; + bool checked_; + + DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); +}; + +} // namespace internal +} // namespace ash + +#endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |