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

Side by Side Diff: chrome/browser/ui/views/intent_picker_bubble_view.cc

Issue 2779113002: Use ink drop highlight for focus on arc intent picker buttons.
Patch Set: fix Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/ui/views/intent_picker_bubble_view.h" 5 #include "chrome/browser/ui/views/intent_picker_bubble_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/browser_finder.h" 12 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 14 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "content/public/browser/navigation_handle.h" 16 #include "content/public/browser/navigation_handle.h"
17 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/views/animation/ink_drop_host_view.h" 20 #include "ui/views/animation/ink_drop_host_view.h"
21 #include "ui/views/animation/ink_drop_impl.h"
21 #include "ui/views/border.h" 22 #include "ui/views/border.h"
22 #include "ui/views/controls/button/image_button.h" 23 #include "ui/views/controls/button/image_button.h"
23 #include "ui/views/controls/scroll_view.h" 24 #include "ui/views/controls/scroll_view.h"
24 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" 25 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
25 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
26 #include "ui/views/layout/grid_layout.h" 27 #include "ui/views/layout/grid_layout.h"
28 #include "ui/views/painter.h"
27 #include "ui/views/window/dialog_client_view.h" 29 #include "ui/views/window/dialog_client_view.h"
28 30
29 namespace { 31 namespace {
30 32
31 // Using |kMaxAppResults| as a measure of how many apps we want to show. 33 // Using |kMaxAppResults| as a measure of how many apps we want to show.
32 constexpr size_t kMaxAppResults = arc::ArcNavigationThrottle::kMaxAppResults; 34 constexpr size_t kMaxAppResults = arc::ArcNavigationThrottle::kMaxAppResults;
33 // Main components sizes 35 // Main components sizes
34 constexpr int kTitlePadding = 16; 36 constexpr int kTitlePadding = 16;
35 constexpr int kDialogDelegateInsets = 16; 37 constexpr int kDialogDelegateInsets = 16;
36 constexpr int kRowHeight = 40; 38 constexpr int kRowHeight = 40;
(...skipping 19 matching lines...) Expand all
56 IntentPickerLabelButton(views::ButtonListener* listener, 58 IntentPickerLabelButton(views::ButtonListener* listener,
57 gfx::Image* icon, 59 gfx::Image* icon,
58 const std::string& package_name, 60 const std::string& package_name,
59 const std::string& activity_name) 61 const std::string& activity_name)
60 : LabelButton(listener, 62 : LabelButton(listener,
61 base::UTF8ToUTF16(base::StringPiece(activity_name))), 63 base::UTF8ToUTF16(base::StringPiece(activity_name))),
62 package_name_(package_name) { 64 package_name_(package_name) {
63 SetHorizontalAlignment(gfx::ALIGN_LEFT); 65 SetHorizontalAlignment(gfx::ALIGN_LEFT);
64 SetMinSize(gfx::Size(kMaxWidth, kRowHeight)); 66 SetMinSize(gfx::Size(kMaxWidth, kRowHeight));
65 SetInkDropMode(InkDropMode::ON); 67 SetInkDropMode(InkDropMode::ON);
68 SetFocusPainter(nullptr);
66 if (!icon->IsEmpty()) 69 if (!icon->IsEmpty())
67 SetImage(views::ImageButton::STATE_NORMAL, *icon->ToImageSkia()); 70 SetImage(views::ImageButton::STATE_NORMAL, *icon->ToImageSkia());
68 SetBorder(views::CreateEmptyBorder(10, 16, 10, 0)); 71 SetBorder(views::CreateEmptyBorder(10, 16, 10, 0));
69 } 72 }
70 73
71 SkColor GetInkDropBaseColor() const override { return SK_ColorBLACK; } 74 SkColor GetInkDropBaseColor() const override { return SK_ColorBLACK; }
72 75
73 void MarkAsUnselected(const ui::Event* event) { 76 void MarkAsUnselected(const ui::Event* event) {
74 AnimateInkDrop(views::InkDropState::HIDDEN, 77 AnimateInkDrop(views::InkDropState::HIDDEN,
75 ui::LocatedEvent::FromIfValid(event)); 78 ui::LocatedEvent::FromIfValid(event));
76 } 79 }
77 80
78 void MarkAsSelected(const ui::Event* event) { 81 void MarkAsSelected(const ui::Event* event) {
79 AnimateInkDrop(views::InkDropState::ACTIVATED, 82 AnimateInkDrop(views::InkDropState::ACTIVATED,
80 ui::LocatedEvent::FromIfValid(event)); 83 ui::LocatedEvent::FromIfValid(event));
81 } 84 }
82 85
83 views::InkDropState GetTargetInkDropState() { 86 views::InkDropState GetTargetInkDropState() {
84 return GetInkDrop()->GetTargetInkDropState(); 87 return GetInkDrop()->GetTargetInkDropState();
85 } 88 }
86 89
90 // LabelButton:
91 std::unique_ptr<views::InkDrop> CreateInkDrop() override {
92 std::unique_ptr<views::InkDropImpl> ink_drop =
93 CreateDefaultFloodFillInkDropImpl();
94 ink_drop->SetShowHighlightOnFocus(true);
95 return std::move(ink_drop);
96 }
97
87 private: 98 private:
88 std::string package_name_; 99 std::string package_name_;
89 100
90 DISALLOW_COPY_AND_ASSIGN(IntentPickerLabelButton); 101 DISALLOW_COPY_AND_ASSIGN(IntentPickerLabelButton);
91 }; 102 };
92 103
93 // static 104 // static
94 void IntentPickerBubbleView::ShowBubble( 105 void IntentPickerBubbleView::ShowBubble(
95 content::WebContents* web_contents, 106 content::WebContents* web_contents,
96 const std::vector<AppInfo>& app_info, 107 const std::vector<AppInfo>& app_info,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 size_t index) { 349 size_t index) {
339 return GetIntentPickerLabelButtonAt(index)->GetTargetInkDropState(); 350 return GetIntentPickerLabelButtonAt(index)->GetTargetInkDropState();
340 } 351 }
341 352
342 void IntentPickerBubbleView::PressButtonForTesting(size_t index, 353 void IntentPickerBubbleView::PressButtonForTesting(size_t index,
343 const ui::Event& event) { 354 const ui::Event& event) {
344 views::Button* button = 355 views::Button* button =
345 static_cast<views::Button*>(GetIntentPickerLabelButtonAt(index)); 356 static_cast<views::Button*>(GetIntentPickerLabelButtonAt(index));
346 ButtonPressed(button, event); 357 ButtonPressed(button, event);
347 } 358 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698