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/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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 ShelfWidget* shelf_widget = shelf_->shelf_widget(); | 74 ShelfWidget* shelf_widget = shelf_->shelf_widget(); |
75 if (shelf_widget && | 75 if (shelf_widget && |
76 shelf_widget->GetBackgroundType() == | 76 shelf_widget->GetBackgroundType() == |
77 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | 77 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
78 background_color = SkColorSetA(kShelfBaseColor, | 78 background_color = SkColorSetA(kShelfBaseColor, |
79 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); | 79 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); |
80 } | 80 } |
81 | 81 |
82 // TODO(bruthig|tdanderson): The background should be changed using a | 82 // TODO(bruthig|tdanderson): The background should be changed using a |
83 // fade in/out animation. | 83 // fade in/out animation. |
84 const int kCornerRadius = 2; | |
85 | |
86 SkPaint background_paint; | 84 SkPaint background_paint; |
87 background_paint.setFlags(SkPaint::kAntiAlias_Flag); | 85 background_paint.setFlags(SkPaint::kAntiAlias_Flag); |
88 background_paint.setColor(background_color); | 86 background_paint.setColor(background_color); |
89 canvas->DrawRoundRect(bounds, kCornerRadius, background_paint); | 87 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, 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, kTrayRoundedBorderRadius, highlight_paint); |
96 } | 94 } |
97 } else { | 95 } else { |
98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 96 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
99 const gfx::ImageSkia* background = | 97 const gfx::ImageSkia* background = |
100 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 98 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
101 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); | 99 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); |
102 } | 100 } |
103 } | 101 } |
104 | 102 |
105 void OverflowButton::PaintForeground(gfx::Canvas* canvas, | 103 void OverflowButton::PaintForeground(gfx::Canvas* canvas, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; | 136 return IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; |
139 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; | 137 return IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; |
140 } | 138 } |
141 | 139 |
142 gfx::Rect OverflowButton::CalculateButtonBounds() { | 140 gfx::Rect OverflowButton::CalculateButtonBounds() { |
143 ShelfAlignment alignment = shelf_->alignment(); | 141 ShelfAlignment alignment = shelf_->alignment(); |
144 gfx::Rect bounds(GetContentsBounds()); | 142 gfx::Rect bounds(GetContentsBounds()); |
145 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 143 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
146 if (MaterialDesignController::IsShelfMaterial()) { | 144 if (MaterialDesignController::IsShelfMaterial()) { |
147 if (shelf_->IsHorizontalAlignment()) { | 145 if (shelf_->IsHorizontalAlignment()) { |
148 bounds = gfx::Rect((bounds.x() + (bounds.width() - kShelfItemSizeMD) / 2), | 146 bounds = gfx::Rect((bounds.x() + (bounds.width() - kTrayItemSize) / 2), |
James Cook
2016/06/27 18:04:12
It's odd that you're using a constant named "tray"
tdanderson
2016/06/27 21:29:42
This has been in the back of my mind for a while n
James Cook
2016/06/27 22:53:21
Yeah, I can't think of a good shared name either.
tdanderson
2016/06/28 16:32:44
As discussed, in this CL I will un-blur the lines
| |
149 bounds.y() + (bounds.height() - kShelfItemSizeMD) / 2, | 147 bounds.y() + (bounds.height() - kTrayItemSize) / 2, |
150 kShelfItemSizeMD, kShelfItemSizeMD); | 148 kTrayItemSize, kTrayItemSize); |
151 } else { | 149 } else { |
152 bounds = | 150 bounds = gfx::Rect(bounds.x() + ((bounds.height() - kTrayItemSize) / 2), |
yiyix
2016/06/27 18:39:43
May create a constant for (bounds.height() - kTray
tdanderson
2016/06/27 21:29:42
Done.
| |
153 gfx::Rect(bounds.x() + ((bounds.height() - kShelfItemSizeMD) / 2), | 151 bounds.y() + (bounds.width() - kTrayItemSize) / 2, |
154 bounds.y() + (bounds.width() - kShelfItemSizeMD) / 2, | 152 kTrayItemSize, kTrayItemSize); |
155 kShelfItemSizeMD, kShelfItemSizeMD); | |
156 } | 153 } |
157 } else { | 154 } else { |
158 const gfx::ImageSkia* background = | 155 const gfx::ImageSkia* background = |
159 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); | 156 rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia(); |
160 if (alignment == SHELF_ALIGNMENT_LEFT) { | 157 if (alignment == SHELF_ALIGNMENT_LEFT) { |
161 bounds = | 158 bounds = |
162 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, | 159 gfx::Rect(bounds.right() - background->width() - kShelfItemInset, |
163 bounds.y() + (bounds.height() - background->height()) / 2, | 160 bounds.y() + (bounds.height() - background->height()) / 2, |
164 background->width(), background->height()); | 161 background->width(), background->height()); |
165 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 162 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
166 bounds = | 163 bounds = |
167 gfx::Rect(bounds.x() + kShelfItemInset, | 164 gfx::Rect(bounds.x() + kShelfItemInset, |
168 bounds.y() + (bounds.height() - background->height()) / 2, | 165 bounds.y() + (bounds.height() - background->height()) / 2, |
169 background->width(), background->height()); | 166 background->width(), background->height()); |
170 } else { | 167 } else { |
171 bounds = | 168 bounds = |
172 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, | 169 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
173 bounds.y() + kShelfItemInset, background->width(), | 170 bounds.y() + kShelfItemInset, background->width(), |
174 background->height()); | 171 background->height()); |
175 } | 172 } |
176 } | 173 } |
177 return bounds; | 174 return bounds; |
178 } | 175 } |
179 | 176 |
180 } // namespace ash | 177 } // namespace ash |
OLD | NEW |