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

Side by Side Diff: ash/common/system/user/button_from_view.cc

Issue 2678353005: Remove pre-MD code related to tray/menu user profiles. (Closed)
Patch Set: back out a11y changes and rebase Created 3 years, 10 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 | « ash/common/system/user/button_from_view.h ('k') | ash/common/system/user/rounded_image_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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 6
7 #include "ash/common/system/user/button_from_view.h" 7 #include "ash/common/system/user/button_from_view.h"
8 8
9 #include "ash/common/ash_constants.h" 9 #include "ash/common/ash_constants.h"
10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/system/tray/tray_popup_utils.h" 11 #include "ash/common/system/tray/tray_popup_utils.h"
13 #include "ash/common/system/tray/tray_utils.h" 12 #include "ash/common/system/tray/tray_utils.h"
14 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
16 #include "ui/accessibility/ax_node_data.h" 15 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
18 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 17 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
19 #include "ui/views/animation/ink_drop.h" 18 #include "ui/views/animation/ink_drop.h"
20 #include "ui/views/animation/ink_drop_highlight.h" 19 #include "ui/views/animation/ink_drop_highlight.h"
21 #include "ui/views/animation/ink_drop_impl.h" 20 #include "ui/views/animation/ink_drop_impl.h"
22 #include "ui/views/animation/ink_drop_mask.h" 21 #include "ui/views/animation/ink_drop_mask.h"
23 #include "ui/views/background.h"
24 #include "ui/views/border.h"
25 #include "ui/views/layout/box_layout.h"
26 #include "ui/views/layout/fill_layout.h" 22 #include "ui/views/layout/fill_layout.h"
27 23
28 namespace ash { 24 namespace ash {
29 namespace tray { 25 namespace tray {
30 26
31 namespace {
32
33 // The border color of the user button.
34 const SkColor kBorderColor = 0xffdcdcdc;
35
36 } // namespace
37
38 ButtonFromView::ButtonFromView(views::View* content, 27 ButtonFromView::ButtonFromView(views::View* content,
39 views::ButtonListener* listener, 28 views::ButtonListener* listener,
40 TrayPopupInkDropStyle ink_drop_style, 29 TrayPopupInkDropStyle ink_drop_style)
41 bool highlight_on_hover,
42 const gfx::Insets& tab_frame_inset)
43 : CustomButton(listener), 30 : CustomButton(listener),
44 content_(content), 31 content_(content),
45 ink_drop_style_(ink_drop_style), 32 ink_drop_style_(ink_drop_style),
46 highlight_on_hover_(highlight_on_hover),
47 button_hovered_(false), 33 button_hovered_(false),
48 show_border_(false),
49 tab_frame_inset_(tab_frame_inset),
50 ink_drop_container_(nullptr) { 34 ink_drop_container_(nullptr) {
51 set_has_ink_drop_action_on_click(true); 35 set_has_ink_drop_action_on_click(true);
52 set_notify_enter_exit_on_child(true); 36 set_notify_enter_exit_on_child(true);
53 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 37 ink_drop_container_ = new views::InkDropContainerView();
54 ink_drop_container_ = new views::InkDropContainerView(); 38 AddChildView(ink_drop_container_);
55 AddChildView(ink_drop_container_); 39 SetLayoutManager(new views::FillLayout());
56 SetLayoutManager(new views::FillLayout()); 40 SetInkDropMode(InkDropHostView::InkDropMode::ON);
57 SetInkDropMode(InkDropHostView::InkDropMode::ON);
58 } else {
59 SetLayoutManager(
60 new views::BoxLayout(views::BoxLayout::kHorizontal, 1, 1, 0));
61 }
62 AddChildView(content_); 41 AddChildView(content_);
63 ShowActive();
64 // Only make it focusable when we are active/interested in clicks. 42 // Only make it focusable when we are active/interested in clicks.
65 if (listener) 43 if (listener)
66 SetFocusForPlatform(); 44 SetFocusForPlatform();
67 } 45 }
68 46
69 ButtonFromView::~ButtonFromView() {} 47 ButtonFromView::~ButtonFromView() {}
70 48
71 void ButtonFromView::ForceBorderVisible(bool show) {
72 if (MaterialDesignController::IsSystemTrayMenuMaterial())
73 return;
74 show_border_ = show;
75 ShowActive();
76 }
77
78 void ButtonFromView::OnMouseEntered(const ui::MouseEvent& event) { 49 void ButtonFromView::OnMouseEntered(const ui::MouseEvent& event) {
79 button_hovered_ = true; 50 button_hovered_ = true;
80 ShowActive();
81 } 51 }
82 52
83 void ButtonFromView::OnMouseExited(const ui::MouseEvent& event) { 53 void ButtonFromView::OnMouseExited(const ui::MouseEvent& event) {
84 button_hovered_ = false; 54 button_hovered_ = false;
85 ShowActive();
86 } 55 }
87 56
88 void ButtonFromView::OnPaint(gfx::Canvas* canvas) { 57 void ButtonFromView::OnPaint(gfx::Canvas* canvas) {
89 View::OnPaint(canvas); 58 View::OnPaint(canvas);
90 if (HasFocus()) { 59 if (HasFocus()) {
91 gfx::RectF rect(GetLocalBounds()); 60 gfx::RectF rect(GetLocalBounds());
92 bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial(); 61 canvas->DrawSolidFocusRect(rect, kFocusBorderColor, kFocusBorderThickness);
93 if (!use_md)
94 rect.Inset(gfx::InsetsF(tab_frame_inset_));
95 canvas->DrawSolidFocusRect(rect, kFocusBorderColor,
96 use_md ? kFocusBorderThickness : 1);
97 } 62 }
98 } 63 }
99 64
100 void ButtonFromView::OnFocus() { 65 void ButtonFromView::OnFocus() {
101 View::OnFocus(); 66 View::OnFocus();
102 // Adding focus frame. 67 // Adding focus frame.
103 SchedulePaint(); 68 SchedulePaint();
104 } 69 }
105 70
106 void ButtonFromView::OnBlur() { 71 void ButtonFromView::OnBlur() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 120
156 std::unique_ptr<views::InkDropHighlight> 121 std::unique_ptr<views::InkDropHighlight>
157 ButtonFromView::CreateInkDropHighlight() const { 122 ButtonFromView::CreateInkDropHighlight() const {
158 return TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this); 123 return TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this);
159 } 124 }
160 125
161 std::unique_ptr<views::InkDropMask> ButtonFromView::CreateInkDropMask() const { 126 std::unique_ptr<views::InkDropMask> ButtonFromView::CreateInkDropMask() const {
162 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); 127 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this);
163 } 128 }
164 129
165 void ButtonFromView::ShowActive() {
166 if (MaterialDesignController::IsSystemTrayMenuMaterial())
167 return;
168 bool border_visible =
169 (button_hovered_ && highlight_on_hover_) || show_border_;
170 SkColor border_color = border_visible ? kBorderColor : SK_ColorTRANSPARENT;
171 SetBorder(views::CreateSolidBorder(1, border_color));
172 if (highlight_on_hover_) {
173 SkColor background_color =
174 button_hovered_ ? kHoverBackgroundColor : kBackgroundColor;
175 content_->set_background(
176 views::Background::CreateSolidBackground(background_color));
177 set_background(views::Background::CreateSolidBackground(background_color));
178 }
179 SchedulePaint();
180 }
181
182 } // namespace tray 130 } // namespace tray
183 } // namespace ash 131 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/button_from_view.h ('k') | ash/common/system/user/rounded_image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698