Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: ui/app_list/views/expand_arrow_view.cc

Issue 2959943003: Replace AllAppsTileItemView with ArrowExpandView (Closed)
Patch Set: Find possible reason for memory leak Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/views/expand_arrow_view.h ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #include "ui/app_list/views/expand_arrow_view.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "ui/app_list/app_list_constants.h"
9 #include "ui/app_list/vector_icons/vector_icons.h"
10 #include "ui/app_list/views/app_list_view.h"
11 #include "ui/app_list/views/contents_view.h"
12 #include "ui/gfx/paint_vector_icon.h"
13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
14 #include "ui/views/animation/ink_drop_highlight.h"
15 #include "ui/views/animation/ink_drop_impl.h"
16 #include "ui/views/animation/ink_drop_mask.h"
17 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
18 #include "ui/views/controls/image_view.h"
19
20 namespace app_list {
21
22 namespace {
23
24 constexpr int kExpandArrowTileSize = 36;
25 constexpr int kExpandArrowIconSize = 12;
26 constexpr int kInkDropRadius = 18;
27
28 constexpr SkColor kExpandArrowColor = SK_ColorWHITE;
29 constexpr SkColor kInkDropRippleColor =
30 SkColorSetARGBMacro(0x14, 0xFF, 0xFF, 0xFF);
31 constexpr SkColor kInkDropHighlightColor =
32 SkColorSetARGBMacro(0xF, 0xFF, 0xFF, 0xFF);
33
34 } // namespace
35
36 ExpandArrowView::ExpandArrowView(ContentsView* contents_view,
37 AppListView* app_list_view)
38 : views::CustomButton(this),
39 contents_view_(contents_view),
40 app_list_view_(app_list_view) {
41 icon_ = new views::ImageView;
42 icon_->SetVerticalAlignment(views::ImageView::CENTER);
43 icon_->SetImage(gfx::CreateVectorIcon(kIcArrowUpIcon, kExpandArrowIconSize,
44 kExpandArrowColor));
45 AddChildView(icon_);
46
47 SetInkDropMode(InkDropHostView::InkDropMode::ON);
48 }
49
50 ExpandArrowView::~ExpandArrowView() {}
51
52 void ExpandArrowView::ButtonPressed(views::Button* sender,
53 const ui::Event& event) {
54 UMA_HISTOGRAM_ENUMERATION(kPageOpenedHistogram, AppListModel::STATE_APPS,
55 AppListModel::STATE_LAST);
56
57 contents_view_->SetActiveState(AppListModel::STATE_APPS);
58 app_list_view_->SetState(AppListView::FULLSCREEN_ALL_APPS);
59 GetInkDrop()->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
60 }
61
62 gfx::Size ExpandArrowView::CalculatePreferredSize() const {
63 return gfx::Size(kExpandArrowTileSize, kExpandArrowTileSize);
64 }
65
66 void ExpandArrowView::Layout() {
67 gfx::Rect rect(GetContentsBounds());
68 gfx::Point center = rect.CenterPoint();
69 rect.SetRect(center.x() - kExpandArrowIconSize / 2,
70 center.y() - kExpandArrowIconSize / 2, kExpandArrowIconSize,
71 kExpandArrowIconSize);
72 icon_->SetBoundsRect(rect);
73 }
74
75 std::unique_ptr<views::InkDrop> ExpandArrowView::CreateInkDrop() {
76 std::unique_ptr<views::InkDropImpl> ink_drop =
77 CustomButton::CreateDefaultInkDropImpl();
78 ink_drop->SetShowHighlightOnHover(false);
79 ink_drop->SetShowHighlightOnFocus(true);
80 ink_drop->SetAutoHighlightMode(
81 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
82 return std::move(ink_drop);
83 }
84
85 std::unique_ptr<views::InkDropMask> ExpandArrowView::CreateInkDropMask() const {
86 return base::MakeUnique<views::CircleInkDropMask>(
87 size(), GetLocalBounds().CenterPoint(), kInkDropRadius);
88 }
89
90 std::unique_ptr<views::InkDropRipple> ExpandArrowView::CreateInkDropRipple()
91 const {
92 gfx::Point center = GetLocalBounds().CenterPoint();
93 gfx::Rect bounds(center.x() - kInkDropRadius, center.y() - kInkDropRadius,
94 2 * kInkDropRadius, 2 * kInkDropRadius);
95 return base::MakeUnique<views::FloodFillInkDropRipple>(
96 size(), GetLocalBounds().InsetsFrom(bounds),
97 GetInkDropCenterBasedOnLastEvent(), kInkDropRippleColor, 1.0f);
98 }
99
100 std::unique_ptr<views::InkDropHighlight>
101 ExpandArrowView::CreateInkDropHighlight() const {
102 return base::MakeUnique<views::InkDropHighlight>(
103 gfx::PointF(GetLocalBounds().CenterPoint()),
104 base::MakeUnique<views::CircleLayerDelegate>(kInkDropHighlightColor,
105 kInkDropRadius));
106 }
107
108 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/expand_arrow_view.h ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698