OLD | NEW |
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" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 int OverflowButton::NonMaterialBackgroundImageId() const { | 166 int OverflowButton::NonMaterialBackgroundImageId() const { |
167 if (shelf_view_->IsShowingOverflowBubble()) | 167 if (shelf_view_->IsShowingOverflowBubble()) |
168 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; | 168 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; |
169 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; | 169 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; |
170 } | 170 } |
171 | 171 |
172 gfx::Rect OverflowButton::CalculateButtonBounds() const { | 172 gfx::Rect OverflowButton::CalculateButtonBounds() const { |
173 ShelfAlignment alignment = wm_shelf_->GetAlignment(); | 173 ShelfAlignment alignment = wm_shelf_->GetAlignment(); |
174 gfx::Rect bounds(GetContentsBounds()); | 174 gfx::Rect bounds(GetContentsBounds()); |
175 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
176 if (MaterialDesignController::IsShelfMaterial()) { | 175 if (MaterialDesignController::IsShelfMaterial()) { |
177 const int width_offset = (bounds.width() - kOverflowButtonSize) / 2; | 176 // Align the button to the top of a bottom-aligned shelf, to the right edge |
178 const int height_offset = (bounds.height() - kOverflowButtonSize) / 2; | 177 // a left-aligned shelf, and to the left edge of a right-aligned shelf. |
179 if (IsHorizontalAlignment(alignment)) { | 178 const int inset = (GetShelfConstant(SHELF_SIZE) - kOverflowButtonSize) / 2; |
180 bounds = gfx::Rect(bounds.x() + width_offset, bounds.y() + height_offset, | 179 const int x = alignment == SHELF_ALIGNMENT_LEFT |
181 kOverflowButtonSize, kOverflowButtonSize); | 180 ? bounds.right() - inset - kOverflowButtonSize |
182 } else { | 181 : bounds.x() + inset; |
183 bounds = gfx::Rect(bounds.x() + height_offset, bounds.y() + width_offset, | 182 bounds = gfx::Rect(x, bounds.y() + inset, kOverflowButtonSize, |
184 kOverflowButtonSize, kOverflowButtonSize); | 183 kOverflowButtonSize); |
185 } | |
186 } else { | 184 } else { |
| 185 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
187 const gfx::ImageSkia* background = | 186 const gfx::ImageSkia* background = |
188 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 187 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
189 if (alignment == SHELF_ALIGNMENT_LEFT) { | 188 if (alignment == SHELF_ALIGNMENT_LEFT) { |
190 bounds = | 189 bounds = |
191 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, | 190 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, |
192 bounds.y() + (bounds.height() - background->height()) / 2, | 191 bounds.y() + (bounds.height() - background->height()) / 2, |
193 background->width(), background->height()); | 192 background->width(), background->height()); |
194 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 193 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
195 bounds = | 194 bounds = |
196 gfx::Rect(bounds.x() + kShelfItemInset, | 195 gfx::Rect(bounds.x() + kShelfItemInset, |
197 bounds.y() + (bounds.height() - background->height()) / 2, | 196 bounds.y() + (bounds.height() - background->height()) / 2, |
198 background->width(), background->height()); | 197 background->width(), background->height()); |
199 } else { | 198 } else { |
200 bounds = | 199 bounds = |
201 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, | 200 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
202 bounds.y() + kShelfItemInset, background->width(), | 201 bounds.y() + kShelfItemInset, background->width(), |
203 background->height()); | 202 background->height()); |
204 } | 203 } |
205 } | 204 } |
206 return bounds; | 205 return bounds; |
207 } | 206 } |
208 | 207 |
209 } // namespace ash | 208 } // namespace ash |
OLD | NEW |