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

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

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: rebase Created 3 years, 7 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/shelf/overflow_button.h ('k') | ash/shelf/shelf.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 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/resources/vector_icons/vector_icons.h" 7 #include "ash/resources/vector_icons/vector_icons.h"
8 #include "ash/shelf/shelf.h"
8 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
9 #include "ash/shelf/shelf_view.h" 10 #include "ash/shelf/shelf_view.h"
10 #include "ash/shelf/wm_shelf.h"
11 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/image/image_skia_operations.h" 15 #include "ui/gfx/image/image_skia_operations.h"
16 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/gfx/skbitmap_operations.h" 17 #include "ui/gfx/skbitmap_operations.h"
18 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 18 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
19 #include "ui/views/animation/ink_drop_impl.h" 19 #include "ui/views/animation/ink_drop_impl.h"
20 #include "ui/views/animation/ink_drop_mask.h" 20 #include "ui/views/animation/ink_drop_mask.h"
21 21
22 namespace ash { 22 namespace ash {
23 23
24 OverflowButton::OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf) 24 OverflowButton::OverflowButton(ShelfView* shelf_view, Shelf* shelf)
25 : CustomButton(nullptr), 25 : CustomButton(nullptr),
26 upward_image_(gfx::CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor)), 26 upward_image_(gfx::CreateVectorIcon(kShelfOverflowIcon, kShelfIconColor)),
27 chevron_image_(nullptr), 27 chevron_image_(nullptr),
28 shelf_view_(shelf_view), 28 shelf_view_(shelf_view),
29 wm_shelf_(wm_shelf), 29 shelf_(shelf),
30 background_color_(kShelfDefaultBaseColor) { 30 background_color_(kShelfDefaultBaseColor) {
31 DCHECK(shelf_view_); 31 DCHECK(shelf_view_);
32 32
33 SetInkDropMode(InkDropMode::ON); 33 SetInkDropMode(InkDropMode::ON);
34 set_ink_drop_base_color(kShelfInkDropBaseColor); 34 set_ink_drop_base_color(kShelfInkDropBaseColor);
35 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 35 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
36 set_hide_ink_drop_when_showing_context_menu(false); 36 set_hide_ink_drop_when_showing_context_menu(false);
37 37
38 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 38 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
39 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME)); 39 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME));
(...skipping 16 matching lines...) Expand all
56 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); 56 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
57 UpdateChevronImage(); 57 UpdateChevronImage();
58 } 58 }
59 59
60 void OverflowButton::UpdateShelfItemBackground(SkColor color) { 60 void OverflowButton::UpdateShelfItemBackground(SkColor color) {
61 background_color_ = color; 61 background_color_ = color;
62 SchedulePaint(); 62 SchedulePaint();
63 } 63 }
64 64
65 OverflowButton::ChevronDirection OverflowButton::GetChevronDirection() const { 65 OverflowButton::ChevronDirection OverflowButton::GetChevronDirection() const {
66 switch (wm_shelf_->GetAlignment()) { 66 switch (shelf_->alignment()) {
67 case SHELF_ALIGNMENT_LEFT: 67 case SHELF_ALIGNMENT_LEFT:
68 if (shelf_view_->IsShowingOverflowBubble()) 68 if (shelf_view_->IsShowingOverflowBubble())
69 return ChevronDirection::LEFT; 69 return ChevronDirection::LEFT;
70 return ChevronDirection::RIGHT; 70 return ChevronDirection::RIGHT;
71 case SHELF_ALIGNMENT_RIGHT: 71 case SHELF_ALIGNMENT_RIGHT:
72 if (shelf_view_->IsShowingOverflowBubble()) 72 if (shelf_view_->IsShowingOverflowBubble())
73 return ChevronDirection::RIGHT; 73 return ChevronDirection::RIGHT;
74 return ChevronDirection::LEFT; 74 return ChevronDirection::LEFT;
75 default: 75 default:
76 if (shelf_view_->IsShowingOverflowBubble()) 76 if (shelf_view_->IsShowingOverflowBubble())
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void OverflowButton::PaintForeground(gfx::Canvas* canvas, 160 void OverflowButton::PaintForeground(gfx::Canvas* canvas,
161 const gfx::Rect& bounds) { 161 const gfx::Rect& bounds) {
162 DCHECK(chevron_image_); 162 DCHECK(chevron_image_);
163 canvas->DrawImageInt( 163 canvas->DrawImageInt(
164 *chevron_image_, 164 *chevron_image_,
165 bounds.x() + ((bounds.width() - chevron_image_->width()) / 2), 165 bounds.x() + ((bounds.width() - chevron_image_->width()) / 2),
166 bounds.y() + ((bounds.height() - chevron_image_->height()) / 2)); 166 bounds.y() + ((bounds.height() - chevron_image_->height()) / 2));
167 } 167 }
168 168
169 gfx::Rect OverflowButton::CalculateButtonBounds() const { 169 gfx::Rect OverflowButton::CalculateButtonBounds() const {
170 ShelfAlignment alignment = wm_shelf_->GetAlignment(); 170 ShelfAlignment alignment = shelf_->alignment();
171 gfx::Rect content_bounds = GetContentsBounds(); 171 gfx::Rect content_bounds = GetContentsBounds();
172 // Align the button to the top of a bottom-aligned shelf, to the right edge 172 // Align the button to the top of a bottom-aligned shelf, to the right edge
173 // a left-aligned shelf, and to the left edge of a right-aligned shelf. 173 // a left-aligned shelf, and to the left edge of a right-aligned shelf.
174 const int inset = (kShelfSize - kOverflowButtonSize) / 2; 174 const int inset = (kShelfSize - kOverflowButtonSize) / 2;
175 const int x = alignment == SHELF_ALIGNMENT_LEFT 175 const int x = alignment == SHELF_ALIGNMENT_LEFT
176 ? content_bounds.right() - inset - kOverflowButtonSize 176 ? content_bounds.right() - inset - kOverflowButtonSize
177 : content_bounds.x() + inset; 177 : content_bounds.x() + inset;
178 return gfx::Rect(x, content_bounds.y() + inset, kOverflowButtonSize, 178 return gfx::Rect(x, content_bounds.y() + inset, kOverflowButtonSize,
179 kOverflowButtonSize); 179 kOverflowButtonSize);
180 } 180 }
181 181
182 } // namespace ash 182 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/overflow_button.h ('k') | ash/shelf/shelf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698