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

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

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/material_design/material_design_controller.h"
8 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
11 #include "grit/ash_resources.h" 12 #include "grit/ash_resources.h"
12 #include "grit/ash_strings.h" 13 #include "grit/ash_strings.h"
13 #include "third_party/skia/include/core/SkPaint.h" 14 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPath.h" 15 #include "third_party/skia/include/core/SkPath.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/animation/throb_animation.h" 18 #include "ui/gfx/animation/throb_animation.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (shelf_->IsShowingOverflowBubble()) 87 if (shelf_->IsShowingOverflowBubble())
87 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; 88 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
88 else if (shelf_->shelf_widget()->GetDimsShelf()) 89 else if (shelf_->shelf_widget()->GetDimsShelf())
89 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; 90 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
90 else 91 else
91 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; 92 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
92 93
93 const gfx::ImageSkia* background = 94 const gfx::ImageSkia* background =
94 rb.GetImageNamed(background_image_id).ToImageSkia(); 95 rb.GetImageNamed(background_image_id).ToImageSkia();
95 wm::ShelfAlignment alignment = shelf_->alignment(); 96 wm::ShelfAlignment alignment = shelf_->alignment();
96 if (alignment == wm::SHELF_ALIGNMENT_LEFT) { 97
97 bounds = gfx::Rect( 98 // If Material Design for Chrome OS shelf is enabled.
tdanderson 2016/05/26 22:55:56 nit: remove comment. (similarly in app_list_button
yiyix 2016/06/02 03:54:53 Done.
98 bounds.right() - background->width() - 99 if (MaterialDesignController::IsShelfMaterial()) {
99 ShelfLayoutManager::kShelfItemInset, 100 if (alignment == wm::SHELF_ALIGNMENT_LEFT ||
100 bounds.y() + (bounds.height() - background->height()) / 2, 101 alignment == wm::SHELF_ALIGNMENT_RIGHT) {
tdanderson 2016/05/26 22:55:56 nit: can you instead use !wm::IsHorizontalAlignmen
yiyix 2016/06/02 03:54:53 On 2016/05/26 22:55:56, tdanderson wrote: > nit: c
101 background->width(), background->height()); 102 bounds =
102 } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) { 103 gfx::Rect(bounds.x() + ((bounds.width() - background->width()) / 2),
103 bounds = gfx::Rect( 104 bounds.y() + ShelfLayoutManager::GetShelfItemInset(
104 bounds.x() + ShelfLayoutManager::kShelfItemInset, 105 ShelfLayoutManager::SHELF_ITEM_INSET) +
105 bounds.y() + (bounds.height() - background->height()) / 2, 106 (bounds.height() - background->height()) / 2,
106 background->width(), background->height()); 107 background->width(), background->height());
108 } else { // SHELF_ALIGNMENT_BOTTOM
109 bounds =
110 gfx::Rect((bounds.x() + ShelfLayoutManager::GetShelfItemInset(
111 ShelfLayoutManager::SHELF_ITEM_INSET) +
112 (bounds.width() - background->width()) / 2),
113 bounds.y() + (bounds.height() - background->height()) / 2,
114 background->width(), background->height());
115 }
107 } else { 116 } else {
108 bounds = gfx::Rect( 117 if (alignment == wm::SHELF_ALIGNMENT_LEFT) {
109 bounds.x() + (bounds.width() - background->width()) / 2, 118 bounds =
110 bounds.y() + ShelfLayoutManager::kShelfItemInset, 119 gfx::Rect(bounds.right() - background->width() -
111 background->width(), background->height()); 120 ShelfLayoutManager::GetShelfItemInset(
121 ShelfLayoutManager::SHELF_ITEM_INSET),
122 bounds.y() + (bounds.height() - background->height()) / 2,
123 background->width(), background->height());
124 } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) {
125 bounds =
126 gfx::Rect(bounds.x() + ShelfLayoutManager::GetShelfItemInset(
127 ShelfLayoutManager::SHELF_ITEM_INSET),
128 bounds.y() + (bounds.height() - background->height()) / 2,
129 background->width(), background->height());
130 } else {
131 bounds =
132 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
133 bounds.y() + ShelfLayoutManager::GetShelfItemInset(
134 ShelfLayoutManager::SHELF_ITEM_INSET),
135 background->width(), background->height());
136 }
112 } 137 }
113 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); 138 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
114 139
115 if (height() < kButtonHoverSize) 140 if (height() < kButtonHoverSize)
116 return; 141 return;
117 142
118 const gfx::ImageSkia* image = NULL; 143 const gfx::ImageSkia* image = NULL;
119 144
120 switch(alignment) { 145 switch(alignment) {
121 case wm::SHELF_ALIGNMENT_LEFT: 146 case wm::SHELF_ALIGNMENT_LEFT:
(...skipping 14 matching lines...) Expand all
136 image = bottom_image_; 161 image = bottom_image_;
137 break; 162 break;
138 } 163 }
139 164
140 canvas->DrawImageInt(*image, 165 canvas->DrawImageInt(*image,
141 bounds.x() + ((bounds.width() - image->width()) / 2), 166 bounds.x() + ((bounds.width() - image->width()) / 2),
142 bounds.y() + ((bounds.height() - image->height()) / 2)); 167 bounds.y() + ((bounds.height() - image->height()) / 2));
143 } 168 }
144 169
145 } // namespace ash 170 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698