summaryrefslogtreecommitdiffstats
path: root/ash/app_list/app_list_item_view.h
blob: 39ef59d8ff5b490ea5ed1d34824374728266f41d (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
// 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 "ash/ash_export.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 ASH_EXPORT AppListItemView : public views::CustomButton,
                                   public views::ContextMenuController,
                                   public AppListItemModelObserver {
 public:
  AppListItemView(AppListItemModel* model,
                  views::ButtonListener* listener);
  virtual ~AppListItemView();

  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[];

 protected:
  // 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;

 private:
  // views::ContextMenuController overrides:
  virtual void ShowContextMenuForView(views::View* source,
                                      const gfx::Point& point) OVERRIDE;

  AppListItemModel* model_;

  views::ImageView* icon_;
  views::Label* title_;

  scoped_ptr<views::MenuRunner> context_menu_runner_;

  gfx::Size icon_size_;

  DISALLOW_COPY_AND_ASSIGN(AppListItemView);
};

}  // namespace ash

#endif  // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_