| 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/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/common/ash_constants.h" | 8 #include "ash/common/ash_constants.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" |
| 11 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 13 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
| 14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 16 #include "third_party/skia/include/core/SkPaint.h" | 17 #include "third_party/skia/include/core/SkPaint.h" |
| 17 #include "third_party/skia/include/core/SkPath.h" | 18 #include "third_party/skia/include/core/SkPath.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/animation/throb_animation.h" | 21 #include "ui/gfx/animation/throb_animation.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (shelf_->IsShowingOverflowBubble()) | 121 if (shelf_->IsShowingOverflowBubble()) |
| 121 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; | 122 return IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; |
| 122 else if (shelf_->shelf_widget()->GetDimsShelf()) | 123 else if (shelf_->shelf_widget()->GetDimsShelf()) |
| 123 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; | 124 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; |
| 124 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; | 125 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; |
| 125 } | 126 } |
| 126 | 127 |
| 127 gfx::Rect OverflowButton::CalculateButtonBounds() { | 128 gfx::Rect OverflowButton::CalculateButtonBounds() { |
| 128 ShelfAlignment alignment = shelf_->alignment(); | 129 ShelfAlignment alignment = shelf_->alignment(); |
| 129 gfx::Rect bounds(GetContentsBounds()); | 130 gfx::Rect bounds(GetContentsBounds()); |
| 130 if (!MaterialDesignController::IsShelfMaterial()) { | 131 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 131 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 132 if (MaterialDesignController::IsShelfMaterial()) { |
| 133 if (shelf_->IsHorizontalAlignment()) { |
| 134 bounds = gfx::Rect((bounds.x() + (bounds.width() - kShelfItemSizeMD) / 2), |
| 135 bounds.y() + (bounds.height() - kShelfItemSizeMD) / 2, |
| 136 kShelfItemSizeMD, kShelfItemSizeMD); |
| 137 } else { |
| 138 bounds = |
| 139 gfx::Rect(bounds.x() + ((bounds.height() - kShelfItemSizeMD) / 2), |
| 140 bounds.y() + (bounds.width() - kShelfItemSizeMD) / 2, |
| 141 kShelfItemSizeMD, kShelfItemSizeMD); |
| 142 } |
| 143 } else { |
| 132 const gfx::ImageSkia* background = | 144 const gfx::ImageSkia* background = |
| 133 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 145 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
| 134 if (alignment == SHELF_ALIGNMENT_LEFT) { | 146 if (alignment == SHELF_ALIGNMENT_LEFT) { |
| 135 bounds = gfx::Rect( | 147 bounds = |
| 136 bounds.right() - background->width() - | 148 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, |
| 137 ShelfLayoutManager::kShelfItemInset, | 149 bounds.y() + (bounds.height() - background->height()) / 2, |
| 138 bounds.y() + (bounds.height() - background->height()) / 2, | 150 background->width(), background->height()); |
| 139 background->width(), background->height()); | |
| 140 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 151 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
| 141 bounds = gfx::Rect( | 152 bounds = |
| 142 bounds.x() + ShelfLayoutManager::kShelfItemInset, | 153 gfx::Rect(bounds.x() + kShelfItemInset, |
| 143 bounds.y() + (bounds.height() - background->height()) / 2, | 154 bounds.y() + (bounds.height() - background->height()) / 2, |
| 144 background->width(), background->height()); | 155 background->width(), background->height()); |
| 145 } else { | 156 } else { |
| 146 bounds = gfx::Rect( | 157 bounds = |
| 147 bounds.x() + (bounds.width() - background->width()) / 2, | 158 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
| 148 bounds.y() + ShelfLayoutManager::kShelfItemInset, | 159 bounds.y() + kShelfItemInset, background->width(), |
| 149 background->width(), background->height()); | 160 background->height()); |
| 150 } | 161 } |
| 151 } | 162 } |
| 152 | |
| 153 return bounds; | 163 return bounds; |
| 154 } | 164 } |
| 155 | 165 |
| 156 } // namespace ash | 166 } // namespace ash |
| OLD | NEW |