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

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

Issue 2099103002: Give Ash material design tray items the correct size and layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split shelf and tray constants Created 4 years, 5 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/system/chromeos/session/logout_button_tray.cc » ('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/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/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/common/system/tray/tray_constants.h"
12 #include "ash/shelf/ink_drop_button_listener.h" 11 #include "ash/shelf/ink_drop_button_listener.h"
13 #include "ash/shelf/shelf.h" 12 #include "ash/shelf/shelf.h"
14 #include "ash/shelf/shelf_layout_manager.h" 13 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_widget.h" 14 #include "ash/shelf/shelf_widget.h"
16 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
18 #include "third_party/skia/include/core/SkPaint.h" 17 #include "third_party/skia/include/core/SkPaint.h"
19 #include "third_party/skia/include/core/SkPath.h" 18 #include "third_party/skia/include/core/SkPath.h"
20 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ShelfWidget* shelf_widget = shelf_->shelf_widget(); 73 ShelfWidget* shelf_widget = shelf_->shelf_widget();
75 if (shelf_widget && 74 if (shelf_widget &&
76 shelf_widget->GetBackgroundType() == 75 shelf_widget->GetBackgroundType() ==
77 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { 76 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
78 background_color = SkColorSetA(kShelfBaseColor, 77 background_color = SkColorSetA(kShelfBaseColor,
79 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); 78 GetShelfConstant(SHELF_BACKGROUND_ALPHA));
80 } 79 }
81 80
82 // TODO(bruthig|tdanderson): The background should be changed using a 81 // TODO(bruthig|tdanderson): The background should be changed using a
83 // fade in/out animation. 82 // fade in/out animation.
84 const int kCornerRadius = 2;
85
86 SkPaint background_paint; 83 SkPaint background_paint;
87 background_paint.setFlags(SkPaint::kAntiAlias_Flag); 84 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
88 background_paint.setColor(background_color); 85 background_paint.setColor(background_color);
89 canvas->DrawRoundRect(bounds, kCornerRadius, background_paint); 86 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
87 background_paint);
90 88
91 if (shelf_->IsShowingOverflowBubble()) { 89 if (shelf_->IsShowingOverflowBubble()) {
92 SkPaint highlight_paint; 90 SkPaint highlight_paint;
93 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); 91 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag);
94 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); 92 highlight_paint.setColor(kShelfButtonActivatedHighlightColor);
95 canvas->DrawRoundRect(bounds, kCornerRadius, highlight_paint); 93 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
94 highlight_paint);
96 } 95 }
97 } else { 96 } else {
98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 97 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
99 const gfx::ImageSkia* background = 98 const gfx::ImageSkia* background =
100 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); 99 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
101 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); 100 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
102 } 101 }
103 } 102 }
104 103
105 void OverflowButton::PaintForeground(gfx::Canvas* canvas, 104 void OverflowButton::PaintForeground(gfx::Canvas* canvas,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 else if (shelf_->shelf_widget()->GetDimsShelf()) 136 else if (shelf_->shelf_widget()->GetDimsShelf())
138 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; 137 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
139 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; 138 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
140 } 139 }
141 140
142 gfx::Rect OverflowButton::CalculateButtonBounds() { 141 gfx::Rect OverflowButton::CalculateButtonBounds() {
143 ShelfAlignment alignment = shelf_->alignment(); 142 ShelfAlignment alignment = shelf_->alignment();
144 gfx::Rect bounds(GetContentsBounds()); 143 gfx::Rect bounds(GetContentsBounds());
145 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 144 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
146 if (MaterialDesignController::IsShelfMaterial()) { 145 if (MaterialDesignController::IsShelfMaterial()) {
146 const int width_offset = (bounds.width() - kOverflowButtonSize) / 2;
147 const int height_offset = (bounds.height() - kOverflowButtonSize) / 2;
147 if (shelf_->IsHorizontalAlignment()) { 148 if (shelf_->IsHorizontalAlignment()) {
148 bounds = gfx::Rect((bounds.x() + (bounds.width() - kShelfItemSizeMD) / 2), 149 bounds = gfx::Rect(bounds.x() + width_offset, bounds.y() + height_offset,
149 bounds.y() + (bounds.height() - kShelfItemSizeMD) / 2, 150 kOverflowButtonSize, kOverflowButtonSize);
150 kShelfItemSizeMD, kShelfItemSizeMD);
151 } else { 151 } else {
152 bounds = 152 bounds = gfx::Rect(bounds.x() + height_offset, bounds.y() + width_offset,
153 gfx::Rect(bounds.x() + ((bounds.height() - kShelfItemSizeMD) / 2), 153 kOverflowButtonSize, kOverflowButtonSize);
154 bounds.y() + (bounds.width() - kShelfItemSizeMD) / 2,
155 kShelfItemSizeMD, kShelfItemSizeMD);
156 } 154 }
157 } else { 155 } else {
158 const gfx::ImageSkia* background = 156 const gfx::ImageSkia* background =
159 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); 157 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
160 if (alignment == SHELF_ALIGNMENT_LEFT) { 158 if (alignment == SHELF_ALIGNMENT_LEFT) {
161 bounds = 159 bounds =
162 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, 160 gfx::Rect(bounds.right() - background->width() - kShelfItemInset,
163 bounds.y() + (bounds.height() - background->height()) / 2, 161 bounds.y() + (bounds.height() - background->height()) / 2,
164 background->width(), background->height()); 162 background->width(), background->height());
165 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { 163 } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
166 bounds = 164 bounds =
167 gfx::Rect(bounds.x() + kShelfItemInset, 165 gfx::Rect(bounds.x() + kShelfItemInset,
168 bounds.y() + (bounds.height() - background->height()) / 2, 166 bounds.y() + (bounds.height() - background->height()) / 2,
169 background->width(), background->height()); 167 background->width(), background->height());
170 } else { 168 } else {
171 bounds = 169 bounds =
172 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, 170 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
173 bounds.y() + kShelfItemInset, background->width(), 171 bounds.y() + kShelfItemInset, background->width(),
174 background->height()); 172 background->height());
175 } 173 }
176 } 174 }
177 return bounds; 175 return bounds;
178 } 176 }
179 177
180 } // namespace ash 178 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/overflow_button.h ('k') | ash/system/chromeos/session/logout_button_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698