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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2269143004: arc: Update notification close button image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment padding consts are in DIPs and move floating close button test into EventForwarder Created 4 years, 3 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 | ui/resources/default_100_percent/common/arc_notification_close.png » ('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 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 "ui/arc/notification/arc_custom_notification_view.h" 5 #include "ui/arc/notification/arc_custom_notification_view.h"
6 6
7 #include "components/exo/notification_surface.h" 7 #include "components/exo/notification_surface.h"
8 #include "components/exo/surface.h" 8 #include "components/exo/surface.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace arc { 25 namespace arc {
26 26
27 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler { 27 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler {
28 public: 28 public:
29 explicit EventForwarder(ArcCustomNotificationView* owner) : owner_(owner) {} 29 explicit EventForwarder(ArcCustomNotificationView* owner) : owner_(owner) {}
30 ~EventForwarder() override = default; 30 ~EventForwarder() override = default;
31 31
32 private: 32 private:
33 // ui::EventHandler 33 // ui::EventHandler
34 void OnEvent(ui::Event* event) override { owner_->OnEvent(event); } 34 void OnEvent(ui::Event* event) override {
35 // Do not forward event targeted to the floating close button so that
36 // keyboard press and tap are handled properly.
37 if (owner_->floating_close_button_widget_ && event->target() &&
38 owner_->floating_close_button_widget_->GetNativeWindow() ==
39 event->target()) {
40 return;
41 }
42
43 owner_->OnEvent(event);
44 }
35 45
36 ArcCustomNotificationView* const owner_; 46 ArcCustomNotificationView* const owner_;
37 47
38 DISALLOW_COPY_AND_ASSIGN(EventForwarder); 48 DISALLOW_COPY_AND_ASSIGN(EventForwarder);
39 }; 49 };
40 50
41 class ArcCustomNotificationView::SlideHelper 51 class ArcCustomNotificationView::SlideHelper
42 : public ui::LayerAnimationObserver { 52 : public ui::LayerAnimationObserver {
43 public: 53 public:
44 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) { 54 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ArcCustomNotificationView::~ArcCustomNotificationView() { 128 ArcCustomNotificationView::~ArcCustomNotificationView() {
119 SetSurface(nullptr); 129 SetSurface(nullptr);
120 if (item_) 130 if (item_)
121 item_->RemoveObserver(this); 131 item_->RemoveObserver(this);
122 } 132 }
123 133
124 void ArcCustomNotificationView::CreateFloatingCloseButton() { 134 void ArcCustomNotificationView::CreateFloatingCloseButton() {
125 floating_close_button_ = new views::ImageButton(this); 135 floating_close_button_ = new views::ImageButton(this);
126 floating_close_button_->set_background( 136 floating_close_button_->set_background(
127 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT)); 137 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT));
128 floating_close_button_->SetBorder( 138
129 views::Border::CreateEmptyBorder(5, 5, 5, 5)); 139 // The sizes below are in DIPs.
140 constexpr int kPaddingFromBorder = 4;
141 constexpr int kImageSize = 16;
142 constexpr int kTouchExtendedPadding =
143 message_center::kControlButtonSize - kImageSize - kPaddingFromBorder;
144 floating_close_button_->SetBorder(views::Border::CreateEmptyBorder(
145 kPaddingFromBorder, kTouchExtendedPadding, kTouchExtendedPadding,
146 kPaddingFromBorder));
130 147
131 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 148 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
132 floating_close_button_->SetImage( 149 floating_close_button_->SetImage(
133 views::CustomButton::STATE_NORMAL, 150 views::CustomButton::STATE_NORMAL,
134 rb.GetImageSkiaNamed(IDR_NOTIFICATION_CLOSE)); 151 rb.GetImageSkiaNamed(IDR_ARC_NOTIFICATION_CLOSE));
135 floating_close_button_->SetImage(
136 views::CustomButton::STATE_HOVERED,
137 rb.GetImageSkiaNamed(IDR_NOTIFICATION_CLOSE_HOVER));
138 floating_close_button_->SetImage(
139 views::CustomButton::STATE_PRESSED,
140 rb.GetImageSkiaNamed(IDR_NOTIFICATION_CLOSE_PRESSED));
141 floating_close_button_->set_animate_on_state_change(false); 152 floating_close_button_->set_animate_on_state_change(false);
142 floating_close_button_->SetAccessibleName(l10n_util::GetStringUTF16( 153 floating_close_button_->SetAccessibleName(l10n_util::GetStringUTF16(
143 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); 154 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
144 155
145 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); 156 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
146 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 157 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
147 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 158 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
148 params.parent = surface_->window(); 159 params.parent = surface_->window();
149 160
150 floating_close_button_widget_.reset(new views::Widget); 161 floating_close_button_widget_.reset(new views::Widget);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } else if (!item_->pinned() && !floating_close_button_widget_) { 319 } else if (!item_->pinned() && !floating_close_button_widget_) {
309 CreateFloatingCloseButton(); 320 CreateFloatingCloseButton();
310 } 321 }
311 } 322 }
312 323
313 void ArcCustomNotificationView::OnItemNotificationSurfaceRemoved() { 324 void ArcCustomNotificationView::OnItemNotificationSurfaceRemoved() {
314 SetSurface(nullptr); 325 SetSurface(nullptr);
315 } 326 }
316 327
317 } // namespace arc 328 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | ui/resources/default_100_percent/common/arc_notification_close.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698