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

Side by Side Diff: ash/common/shelf/overflow_button.cc

Issue 2238903003: ash: Remove WmShelf::IsShowingOverflowBubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/common/shelf/overflow_button.h" 5 #include "ash/common/shelf/overflow_button.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/shelf/ink_drop_button_listener.h" 9 #include "ash/common/shelf/ink_drop_button_listener.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shelf/shelf_view.h"
11 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shelf/wm_shelf_util.h" 13 #include "ash/common/shelf/wm_shelf_util.h"
13 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
14 #include "grit/ash_strings.h" 15 #include "grit/ash_strings.h"
15 #include "third_party/skia/include/core/SkPaint.h" 16 #include "third_party/skia/include/core/SkPaint.h"
16 #include "third_party/skia/include/core/SkPath.h" 17 #include "third_party/skia/include/core/SkPath.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/image/image_skia_operations.h" 21 #include "ui/gfx/image/image_skia_operations.h"
21 #include "ui/gfx/paint_vector_icon.h" 22 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/gfx/skbitmap_operations.h" 23 #include "ui/gfx/skbitmap_operations.h"
23 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/transform.h" 25 #include "ui/gfx/transform.h"
25 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
26 27
27 namespace ash { 28 namespace ash {
28 29
29 OverflowButton::OverflowButton(InkDropButtonListener* listener, 30 OverflowButton::OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf)
30 WmShelf* wm_shelf)
31 : CustomButton(nullptr), 31 : CustomButton(nullptr),
32 bottom_image_(nullptr), 32 bottom_image_(nullptr),
33 listener_(listener), 33 shelf_view_(shelf_view),
34 wm_shelf_(wm_shelf), 34 wm_shelf_(wm_shelf),
35 background_alpha_(0) { 35 background_alpha_(0) {
36 DCHECK(shelf_view_);
36 if (MaterialDesignController::IsShelfMaterial()) { 37 if (MaterialDesignController::IsShelfMaterial()) {
37 bottom_image_md_ = 38 bottom_image_md_ =
38 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor); 39 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor);
39 bottom_image_ = &bottom_image_md_; 40 bottom_image_ = &bottom_image_md_;
40 } else { 41 } else {
41 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 42 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
42 IDR_ASH_SHELF_OVERFLOW); 43 IDR_ASH_SHELF_OVERFLOW);
43 } 44 }
44 45
45 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 46 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
(...skipping 12 matching lines...) Expand all
58 } 59 }
59 60
60 void OverflowButton::OnPaint(gfx::Canvas* canvas) { 61 void OverflowButton::OnPaint(gfx::Canvas* canvas) {
61 gfx::Rect bounds = CalculateButtonBounds(); 62 gfx::Rect bounds = CalculateButtonBounds();
62 PaintBackground(canvas, bounds); 63 PaintBackground(canvas, bounds);
63 PaintForeground(canvas, bounds); 64 PaintForeground(canvas, bounds);
64 } 65 }
65 66
66 void OverflowButton::NotifyClick(const ui::Event& event) { 67 void OverflowButton::NotifyClick(const ui::Event& event) {
67 CustomButton::NotifyClick(event); 68 CustomButton::NotifyClick(event);
68 if (listener_) 69 shelf_view_->ButtonPressed(this, event, ink_drop());
69 listener_->ButtonPressed(this, event, ink_drop());
70 } 70 }
71 71
72 void OverflowButton::PaintBackground(gfx::Canvas* canvas, 72 void OverflowButton::PaintBackground(gfx::Canvas* canvas,
73 const gfx::Rect& bounds) { 73 const gfx::Rect& bounds) {
74 if (MaterialDesignController::IsShelfMaterial()) { 74 if (MaterialDesignController::IsShelfMaterial()) {
75 SkPaint background_paint; 75 SkPaint background_paint;
76 background_paint.setFlags(SkPaint::kAntiAlias_Flag); 76 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
77 background_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); 77 background_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_));
78 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, 78 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
79 background_paint); 79 background_paint);
80 80
81 if (wm_shelf_->IsShowingOverflowBubble()) { 81 if (shelf_view_->IsShowingOverflowBubble()) {
82 SkPaint highlight_paint; 82 SkPaint highlight_paint;
83 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); 83 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag);
84 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); 84 highlight_paint.setColor(kShelfButtonActivatedHighlightColor);
85 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, 85 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
86 highlight_paint); 86 highlight_paint);
87 } 87 }
88 } else { 88 } else {
89 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 89 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
90 const gfx::ImageSkia* background = 90 const gfx::ImageSkia* background =
91 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); 91 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
(...skipping 24 matching lines...) Expand all
116 image = bottom_image_; 116 image = bottom_image_;
117 break; 117 break;
118 } 118 }
119 119
120 canvas->DrawImageInt(*image, 120 canvas->DrawImageInt(*image,
121 bounds.x() + ((bounds.width() - image->width()) / 2), 121 bounds.x() + ((bounds.width() - image->width()) / 2),
122 bounds.y() + ((bounds.height() - image->height()) / 2)); 122 bounds.y() + ((bounds.height() - image->height()) / 2));
123 } 123 }
124 124
125 int OverflowButton::NonMaterialBackgroundImageId() { 125 int OverflowButton::NonMaterialBackgroundImageId() {
126 if (wm_shelf_->IsShowingOverflowBubble()) 126 if (shelf_view_->IsShowingOverflowBubble())
127 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; 127 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
128 else if (wm_shelf_->IsDimmed()) 128 else if (wm_shelf_->IsDimmed())
129 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; 129 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
130 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; 130 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
131 } 131 }
132 132
133 gfx::Rect OverflowButton::CalculateButtonBounds() { 133 gfx::Rect OverflowButton::CalculateButtonBounds() {
134 ShelfAlignment alignment = wm_shelf_->GetAlignment(); 134 ShelfAlignment alignment = wm_shelf_->GetAlignment();
135 gfx::Rect bounds(GetContentsBounds()); 135 gfx::Rect bounds(GetContentsBounds());
136 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 136 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
(...skipping 24 matching lines...) Expand all
161 bounds = 161 bounds =
162 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, 162 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
163 bounds.y() + kShelfItemInset, background->width(), 163 bounds.y() + kShelfItemInset, background->width(),
164 background->height()); 164 background->height());
165 } 165 }
166 } 166 }
167 return bounds; 167 return bounds;
168 } 168 }
169 169
170 } // namespace ash 170 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698