blob: 3f2123d6d297fb64d3b7f8c48ab019553dbbea16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (c) 2012 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_APP_LIST_APP_LIST_ITEM_VIEW_H_
#define ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
#pragma once
#include "ash/app_list/app_list_item_model_observer.h"
#include "base/memory/scoped_ptr.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/custom_button.h"
class SkBitmap;
namespace views {
class ImageView;
class Label;
class MenuRunner;
}
namespace ash {
class AppListItemModel;
class AppListModelView;
class AppListItemView : public views::CustomButton,
public views::ContextMenuController,
public AppListItemModelObserver {
public:
AppListItemView(AppListModelView* list_model_view,
AppListItemModel* model,
views::ButtonListener* listener);
virtual ~AppListItemView();
void SetSelected(bool selected);
bool selected() const {
return selected_;
}
AppListItemModel* model() const {
return model_;
}
void set_icon_size(const gfx::Size& size) {
icon_size_ = size;
}
// Icon padding
static const int kPadding = 5;
// Internal class name.
static const char kViewClassName[];
private:
// AppListItemModelObserver overrides:
virtual void ItemIconChanged() OVERRIDE;
virtual void ItemTitleChanged() OVERRIDE;
// views::View overrides:
virtual std::string GetClassName() const OVERRIDE;
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
// views::ContextMenuController overrides:
virtual void ShowContextMenuForView(views::View* source,
const gfx::Point& point) OVERRIDE;
// views::CustomButton overrides:
virtual void StateChanged() OVERRIDE;
AppListItemModel* model_;
AppListModelView* list_model_view_;
views::ImageView* icon_;
views::Label* title_;
scoped_ptr<views::MenuRunner> context_menu_runner_;
gfx::Size icon_size_;
bool selected_;
DISALLOW_COPY_AND_ASSIGN(AppListItemView);
};
} // namespace ash
#endif // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
|