Chromium Code Reviews| 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(); | 175 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
|
oshima
2016/12/14 21:28:41
unrelated, but you can move this to else block.
tdanderson
2016/12/14 21:45:07
Done.
| |
| 176 if (MaterialDesignController::IsShelfMaterial()) { | 176 if (MaterialDesignController::IsShelfMaterial()) { |
|
oshima
2016/12/14 21:28:41
just add quick comment saying "align to the top"
tdanderson
2016/12/14 21:45:07
Done.
| |
| 177 const int width_offset = (bounds.width() - kOverflowButtonSize) / 2; | 177 const int inset = (GetShelfConstant(SHELF_SIZE) - kOverflowButtonSize) / 2; |
| 178 const int height_offset = (bounds.height() - kOverflowButtonSize) / 2; | 178 const int x = alignment == SHELF_ALIGNMENT_LEFT |
| 179 if (IsHorizontalAlignment(alignment)) { | 179 ? bounds.right() - inset - kOverflowButtonSize |
| 180 bounds = gfx::Rect(bounds.x() + width_offset, bounds.y() + height_offset, | 180 : bounds.x() + inset; |
| 181 kOverflowButtonSize, kOverflowButtonSize); | 181 bounds = gfx::Rect(x, bounds.y() + inset, kOverflowButtonSize, |
| 182 } else { | 182 kOverflowButtonSize); |
| 183 bounds = gfx::Rect(bounds.x() + height_offset, bounds.y() + width_offset, | |
| 184 kOverflowButtonSize, kOverflowButtonSize); | |
| 185 } | |
| 186 } else { | 183 } else { |
| 187 const gfx::ImageSkia* background = | 184 const gfx::ImageSkia* background = |
| 188 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 185 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
| 189 if (alignment == SHELF_ALIGNMENT_LEFT) { | 186 if (alignment == SHELF_ALIGNMENT_LEFT) { |
| 190 bounds = | 187 bounds = |
| 191 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, | 188 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, |
| 192 bounds.y() + (bounds.height() - background->height()) / 2, | 189 bounds.y() + (bounds.height() - background->height()) / 2, |
| 193 background->width(), background->height()); | 190 background->width(), background->height()); |
| 194 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 191 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
| 195 bounds = | 192 bounds = |
| 196 gfx::Rect(bounds.x() + kShelfItemInset, | 193 gfx::Rect(bounds.x() + kShelfItemInset, |
| 197 bounds.y() + (bounds.height() - background->height()) / 2, | 194 bounds.y() + (bounds.height() - background->height()) / 2, |
| 198 background->width(), background->height()); | 195 background->width(), background->height()); |
| 199 } else { | 196 } else { |
| 200 bounds = | 197 bounds = |
| 201 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, | 198 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
| 202 bounds.y() + kShelfItemInset, background->width(), | 199 bounds.y() + kShelfItemInset, background->width(), |
| 203 background->height()); | 200 background->height()); |
| 204 } | 201 } |
| 205 } | 202 } |
| 206 return bounds; | 203 return bounds; |
| 207 } | 204 } |
| 208 | 205 |
| 209 } // namespace ash | 206 } // namespace ash |
| OLD | NEW |