OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 5 #ifndef ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
6 #define ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 6 #define ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/app_list/app_list_item_model_observer.h" | 9 #include "ash/app_list/app_list_item_model_observer.h" |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/controls/button/custom_button.h" |
12 | 12 |
13 class SkBitmap; | 13 class SkBitmap; |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 class ImageView; | 16 class ImageView; |
17 class Label; | 17 class Label; |
18 } | 18 } |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 | 21 |
22 class AppListItemModel; | 22 class AppListItemModel; |
23 class AppListItemViewListener; | |
24 | 23 |
25 class ASH_EXPORT AppListItemView : public views::View, | 24 class ASH_EXPORT AppListItemView : public views::CustomButton, |
26 public AppListItemModelObserver { | 25 public AppListItemModelObserver { |
27 public: | 26 public: |
28 AppListItemView(AppListItemModel* model, | 27 AppListItemView(AppListItemModel* model, |
29 AppListItemViewListener* listener); | 28 views::ButtonListener* listener); |
30 virtual ~AppListItemView(); | 29 virtual ~AppListItemView(); |
31 | 30 |
32 AppListItemModel* model() const { | 31 AppListItemModel* model() const { |
33 return model_; | 32 return model_; |
34 } | 33 } |
35 | 34 |
36 // Tile size | 35 // Icon padding |
37 static const int kTileSize = 180; | 36 static const int kPadding = 5; |
38 | |
39 // Preferred icon size. | |
40 static const int kIconSize = 128; | |
41 | 37 |
42 protected: | 38 protected: |
43 // Notifies listener when activated. | |
44 void NotifyActivated(int event_flags); | |
45 | |
46 // AppListItemModelObserver overrides: | 39 // AppListItemModelObserver overrides: |
47 virtual void ItemIconChanged() OVERRIDE; | 40 virtual void ItemIconChanged() OVERRIDE; |
48 virtual void ItemTitleChanged() OVERRIDE; | 41 virtual void ItemTitleChanged() OVERRIDE; |
49 | 42 |
50 // views::View overrides: | 43 // views::View overrides: |
51 virtual gfx::Size GetPreferredSize() OVERRIDE; | 44 virtual gfx::Size GetPreferredSize() OVERRIDE; |
52 virtual void Layout() OVERRIDE; | 45 virtual void Layout() OVERRIDE; |
53 virtual void OnFocus() OVERRIDE; | 46 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
54 virtual void OnBlur() OVERRIDE; | |
55 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; | |
56 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | |
57 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | |
58 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
59 | 47 |
60 private: | 48 private: |
61 AppListItemModel* model_; | 49 AppListItemModel* model_; |
62 AppListItemViewListener* listener_; | |
63 | 50 |
64 views::ImageView* icon_; | 51 views::ImageView* icon_; |
65 views::Label* title_; | 52 views::Label* title_; |
66 | 53 |
67 DISALLOW_COPY_AND_ASSIGN(AppListItemView); | 54 DISALLOW_COPY_AND_ASSIGN(AppListItemView); |
68 }; | 55 }; |
69 | 56 |
70 } // namespace ash | 57 } // namespace ash |
71 | 58 |
72 #endif // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 59 #endif // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
OLD | NEW |