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
ash / system / phonehub / phone_hub_recent_app_button.cc [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/phonehub/phone_hub_recent_app_button.h"
#include <utility>
#include "ash/style/ash_color_provider.h"
#include "ash/style/style_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h"
namespace ash {
namespace {
// Appearance in DIPs.
constexpr int kRecentAppButtonSize = 42;
} // namespace
PhoneHubRecentAppButton::PhoneHubRecentAppButton(
const gfx::Image& icon,
const std::u16string& visible_app_name,
PressedCallback callback)
: views::ImageButton(std::move(callback)) {
SetImageModel(
views::Button::STATE_NORMAL,
ui::ImageModel::FromImageSkia(
gfx::ImageSkiaOperations::CreateResizedImage(
icon.AsImageSkia(), skia::ImageOperations::RESIZE_BEST,
gfx::Size(kRecentAppButtonSize, kRecentAppButtonSize))));
SetImageHorizontalAlignment(ALIGN_CENTER);
SetImageVerticalAlignment(ALIGN_MIDDLE);
StyleUtil::SetUpInkDropForButton(this);
views::InstallCircleHighlightPathGenerator(this);
GetViewAccessibility().SetName(visible_app_name);
SetTooltipText(visible_app_name);
views::FocusRing::Get(this)->SetColorId(ui::kColorAshFocusRing);
}
PhoneHubRecentAppButton::~PhoneHubRecentAppButton() = default;
gfx::Size PhoneHubRecentAppButton::CalculatePreferredSize(
const views::SizeBounds& available_size) const {
return gfx::Size(kRecentAppButtonSize, kRecentAppButtonSize);
}
void PhoneHubRecentAppButton::PaintButtonContents(gfx::Canvas* canvas) {
cc::PaintFlags flags;
flags.setAntiAlias(true);
views::ImageButton::PaintButtonContents(canvas);
}
BEGIN_METADATA(PhoneHubRecentAppButton)
END_METADATA
} // namespace ash