1 // Copyright 2014 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.
5 #ifndef UI_APP_LIST_VIEWS_TILE_ITEM_VIEW_H_
6 #define UI_APP_LIST_VIEWS_TILE_ITEM_VIEW_H_
8 #include "base/strings/string16.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/app_list/app_list_export.h"
11 #include "ui/app_list/views/image_shadow_animator.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/button/custom_button.h"
26 // The view for a tile in the app list on the start/search page.
27 class APP_LIST_EXPORT TileItemView
: public views::CustomButton
,
28 public views::ButtonListener
,
29 public ImageShadowAnimator::Delegate
{
32 HOVER_STYLE_ANIMATE_SHADOW
,
33 HOVER_STYLE_DARKEN_BACKGROUND
,
37 ~TileItemView() override
;
39 bool selected() { return selected_
; }
40 void SetSelected(bool selected
);
42 // Informs the TileItemView of its parent's background color. The controls
43 // within the TileItemView will adapt to suit the given color.
44 void SetParentBackgroundColor(SkColor color
);
45 SkColor
parent_background_color() { return parent_background_color_
; }
47 // Sets the behavior of the tile item on mouse hover.
48 void SetHoverStyle(HoverStyle hover_style
);
50 // Overridden from views::CustomButton:
51 void StateChanged() override
;
53 // Overridden from views::View:
54 void Layout() override
;
56 // Overridden from ImageShadowAnimator::Delegate:
57 void ImageShadowAnimationProgressed(ImageShadowAnimator
* animator
) override
;
60 void SetIcon(const gfx::ImageSkia
& icon
);
62 void SetTitle(const base::string16
& title
);
65 void UpdateBackgroundColor();
67 // Overridden from views::View:
68 gfx::Size
GetPreferredSize() const override
;
69 bool GetTooltipText(const gfx::Point
& p
,
70 base::string16
* tooltip
) const override
;
72 SkColor parent_background_color_
;
73 HoverStyle hover_style_
;
74 scoped_ptr
<ImageShadowAnimator
> image_shadow_animator_
;
76 views::ImageView
* icon_
; // Owned by views hierarchy.
77 views::Label
* title_
; // Owned by views hierarchy.
81 DISALLOW_COPY_AND_ASSIGN(TileItemView
);
84 } // namespace app_list
86 #endif // UI_APP_LIST_VIEWS_TILE_ITEM_VIEW_H_