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

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

Issue 2033553003: Add MD ink drop ripple to shelf app items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed DLL export issue Created 4 years, 6 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/shelf/overflow_button.h" 5 #include "ash/shelf/overflow_button.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/shelf/ink_drop_button_listener.h"
11 #include "ash/shelf/shelf.h" 12 #include "ash/shelf/shelf.h"
12 #include "ash/shelf/shelf_layout_manager.h" 13 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_widget.h" 14 #include "ash/shelf/shelf_widget.h"
14 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
15 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
16 #include "third_party/skia/include/core/SkPaint.h" 17 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkPath.h" 18 #include "third_party/skia/include/core/SkPath.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/animation/throb_animation.h" 21 #include "ui/gfx/animation/throb_animation.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/image/image_skia_operations.h" 23 #include "ui/gfx/image/image_skia_operations.h"
23 #include "ui/gfx/paint_vector_icon.h" 24 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/gfx/skbitmap_operations.h" 25 #include "ui/gfx/skbitmap_operations.h"
25 #include "ui/gfx/skia_util.h" 26 #include "ui/gfx/skia_util.h"
26 #include "ui/gfx/transform.h" 27 #include "ui/gfx/transform.h"
27 #include "ui/gfx/vector_icons_public.h" 28 #include "ui/gfx/vector_icons_public.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 30
30 namespace ash { 31 namespace ash {
31 32
32 OverflowButton::OverflowButton(views::ButtonListener* listener, Shelf* shelf) 33 OverflowButton::OverflowButton(InkDropButtonListener* listener, Shelf* shelf)
33 : CustomButton(listener), bottom_image_(nullptr), shelf_(shelf) { 34 : CustomButton(nullptr),
35 bottom_image_(nullptr),
36 listener_(listener),
37 shelf_(shelf) {
34 if (MaterialDesignController::IsShelfMaterial()) { 38 if (MaterialDesignController::IsShelfMaterial()) {
35 bottom_image_md_ = 39 bottom_image_md_ =
36 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor); 40 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor);
37 bottom_image_ = &bottom_image_md_; 41 bottom_image_ = &bottom_image_md_;
38 } else { 42 } else {
39 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 43 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
40 IDR_ASH_SHELF_OVERFLOW); 44 IDR_ASH_SHELF_OVERFLOW);
41 } 45 }
42 46
43 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 47 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
44 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME)); 48 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME));
45 } 49 }
46 50
47 OverflowButton::~OverflowButton() {} 51 OverflowButton::~OverflowButton() {}
48 52
49 void OverflowButton::OnShelfAlignmentChanged() { 53 void OverflowButton::OnShelfAlignmentChanged() {
50 SchedulePaint(); 54 SchedulePaint();
51 } 55 }
52 56
53 void OverflowButton::OnPaint(gfx::Canvas* canvas) { 57 void OverflowButton::OnPaint(gfx::Canvas* canvas) {
54 gfx::Rect bounds = CalculateButtonBounds(); 58 gfx::Rect bounds = CalculateButtonBounds();
55 PaintBackground(canvas, bounds); 59 PaintBackground(canvas, bounds);
56 PaintForeground(canvas, bounds); 60 PaintForeground(canvas, bounds);
57 } 61 }
58 62
63 void OverflowButton::NotifyClick(const ui::Event& event) {
64 CustomButton::NotifyClick(event);
65 if (listener_)
66 listener_->ButtonPressed(this, event, ink_drop());
67 }
68
59 void OverflowButton::PaintBackground(gfx::Canvas* canvas, 69 void OverflowButton::PaintBackground(gfx::Canvas* canvas,
60 const gfx::Rect& bounds) { 70 const gfx::Rect& bounds) {
61 if (MaterialDesignController::IsShelfMaterial()) { 71 if (MaterialDesignController::IsShelfMaterial()) {
62 SkColor color = SK_ColorTRANSPARENT; 72 SkColor color = SK_ColorTRANSPARENT;
63 ShelfWidget* shelf_widget = shelf_->shelf_widget(); 73 ShelfWidget* shelf_widget = shelf_->shelf_widget();
64 if (shelf_->IsShowingOverflowBubble()) { 74 if (shelf_->IsShowingOverflowBubble()) {
65 // TODO(bruthig|mohsen): Use of this color is temporary. Draw the active 75 // TODO(bruthig|mohsen): Use of this color is temporary. Draw the active
66 // state using the material design ripple animation. 76 // state using the material design ripple animation.
67 color = SK_ColorBLUE; 77 color = SK_ColorBLUE;
68 } else if (shelf_widget && 78 } else if (shelf_widget &&
(...skipping 15 matching lines...) Expand all
84 const gfx::ImageSkia* background = 94 const gfx::ImageSkia* background =
85 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); 95 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
86 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); 96 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
87 } 97 }
88 } 98 }
89 99
90 void OverflowButton::PaintForeground(gfx::Canvas* canvas, 100 void OverflowButton::PaintForeground(gfx::Canvas* canvas,
91 const gfx::Rect& bounds) { 101 const gfx::Rect& bounds) {
92 const gfx::ImageSkia* image = nullptr; 102 const gfx::ImageSkia* image = nullptr;
93 103
94 switch(shelf_->alignment()) { 104 switch (shelf_->alignment()) {
95 case SHELF_ALIGNMENT_LEFT: 105 case SHELF_ALIGNMENT_LEFT:
96 if (left_image_.isNull()) { 106 if (left_image_.isNull()) {
97 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage( 107 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage(
98 *bottom_image_, SkBitmapOperations::ROTATION_90_CW); 108 *bottom_image_, SkBitmapOperations::ROTATION_90_CW);
99 } 109 }
100 image = &left_image_; 110 image = &left_image_;
101 break; 111 break;
102 case SHELF_ALIGNMENT_RIGHT: 112 case SHELF_ALIGNMENT_RIGHT:
103 if (right_image_.isNull()) { 113 if (right_image_.isNull()) {
104 right_image_ = gfx::ImageSkiaOperations::CreateRotatedImage( 114 right_image_ = gfx::ImageSkiaOperations::CreateRotatedImage(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bounds.x() + (bounds.width() - background->width()) / 2, 157 bounds.x() + (bounds.width() - background->width()) / 2,
148 bounds.y() + ShelfLayoutManager::kShelfItemInset, 158 bounds.y() + ShelfLayoutManager::kShelfItemInset,
149 background->width(), background->height()); 159 background->width(), background->height());
150 } 160 }
151 } 161 }
152 162
153 return bounds; 163 return bounds;
154 } 164 }
155 165
156 } // namespace ash 166 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698