OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/system/tray/tray_background_view.h" | 5 #include "ash/common/system/tray/tray_background_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
10 #include "ash/common/material_design/material_design_controller.h" | |
11 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
12 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
13 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
14 #include "ash/common/system/tray/system_tray.h" | |
15 #include "ash/common/system/tray/tray_constants.h" | 13 #include "ash/common/system/tray/tray_constants.h" |
16 #include "ash/common/system/tray/tray_event_filter.h" | 14 #include "ash/common/system/tray/tray_event_filter.h" |
17 #include "ash/common/wm_shell.h" | |
18 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
19 #include "ash/public/cpp/shell_window_ids.h" | |
20 #include "ash/resources/grit/ash_resources.h" | |
21 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
22 #include "ui/accessibility/ax_node_data.h" | 17 #include "ui/accessibility/ax_node_data.h" |
23 #include "ui/base/nine_image_painter_factory.h" | |
24 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
25 #include "ui/compositor/layer_animation_element.h" | 19 #include "ui/compositor/layer_animation_element.h" |
26 #include "ui/compositor/scoped_layer_animation_settings.h" | 20 #include "ui/compositor/scoped_layer_animation_settings.h" |
27 #include "ui/events/event_constants.h" | 21 #include "ui/events/event_constants.h" |
28 #include "ui/gfx/animation/tween.h" | 22 #include "ui/gfx/animation/tween.h" |
29 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
30 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
32 #include "ui/gfx/image/image_skia.h" | |
33 #include "ui/gfx/image/image_skia_operations.h" | |
34 #include "ui/gfx/nine_image_painter.h" | |
35 #include "ui/gfx/scoped_canvas.h" | 26 #include "ui/gfx/scoped_canvas.h" |
36 #include "ui/gfx/skia_util.h" | |
37 #include "ui/gfx/transform.h" | 27 #include "ui/gfx/transform.h" |
38 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 28 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
39 #include "ui/views/animation/ink_drop_highlight.h" | 29 #include "ui/views/animation/ink_drop_highlight.h" |
40 #include "ui/views/animation/ink_drop_mask.h" | 30 #include "ui/views/animation/ink_drop_mask.h" |
41 #include "ui/views/background.h" | 31 #include "ui/views/background.h" |
42 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
43 #include "ui/wm/core/window_animations.h" | |
44 | 33 |
45 namespace { | 34 namespace { |
46 | 35 |
47 const int kAnimationDurationForPopupMs = 200; | 36 const int kAnimationDurationForPopupMs = 200; |
48 | 37 |
49 // Duration of opacity animation for visibility changes. | 38 // Duration of opacity animation for visibility changes. |
50 const int kAnimationDurationForVisibilityMs = 250; | 39 const int kAnimationDurationForVisibilityMs = 250; |
51 | 40 |
52 // When becoming visible delay the animation so that StatusAreaWidgetDelegate | 41 // When becoming visible delay the animation so that StatusAreaWidgetDelegate |
53 // can animate sibling views out of the position to be occuped by the | 42 // can animate sibling views out of the position to be occuped by the |
54 // TrayBackgroundView. | 43 // TrayBackgroundView. |
55 const int kShowAnimationDelayMs = 100; | 44 const int kShowAnimationDelayMs = 100; |
56 | 45 |
57 // Additional padding used to adjust the user-visible size of status tray | |
58 // and overview button dark background. | |
59 const int kBackgroundAdjustPadding = 3; | |
60 | |
61 // Switches left and right insets if RTL mode is active. | 46 // Switches left and right insets if RTL mode is active. |
62 void MirrorInsetsIfNecessary(gfx::Insets* insets) { | 47 void MirrorInsetsIfNecessary(gfx::Insets* insets) { |
63 if (base::i18n::IsRTL()) { | 48 if (base::i18n::IsRTL()) { |
64 insets->Set(insets->top(), insets->right(), insets->bottom(), | 49 insets->Set(insets->top(), insets->right(), insets->bottom(), |
65 insets->left()); | 50 insets->left()); |
66 } | 51 } |
67 } | 52 } |
68 | 53 |
69 // Returns background insets relative to the contents bounds of the view and | 54 // Returns background insets relative to the contents bounds of the view and |
70 // mirrored if RTL mode is active. | 55 // mirrored if RTL mode is active. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 91 } |
107 | 92 |
108 private: | 93 private: |
109 TrayBackgroundView* host_; | 94 TrayBackgroundView* host_; |
110 | 95 |
111 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); | 96 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); |
112 }; | 97 }; |
113 | 98 |
114 class TrayBackground : public views::Background { | 99 class TrayBackground : public views::Background { |
115 public: | 100 public: |
116 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) | 101 explicit TrayBackground(TrayBackgroundView* tray_background_view) |
117 : tray_background_view_(tray_background_view), | 102 : tray_background_view_(tray_background_view), |
118 draws_active_(draws_active), | |
119 color_(SK_ColorTRANSPARENT) {} | 103 color_(SK_ColorTRANSPARENT) {} |
120 | 104 |
121 ~TrayBackground() override {} | 105 ~TrayBackground() override {} |
122 | 106 |
123 void set_color(SkColor color) { color_ = color; } | 107 void set_color(SkColor color) { color_ = color; } |
124 | 108 |
125 private: | 109 private: |
126 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } | 110 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } |
127 | 111 |
128 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 112 // Overridden from views::Background. |
| 113 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
129 cc::PaintFlags background_flags; | 114 cc::PaintFlags background_flags; |
130 background_flags.setAntiAlias(true); | 115 background_flags.setAntiAlias(true); |
131 background_flags.setColor(color_); | 116 background_flags.setColor(color_); |
132 gfx::Insets insets = | 117 gfx::Insets insets = |
133 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); | 118 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); |
134 gfx::Rect bounds = view->GetLocalBounds(); | 119 gfx::Rect bounds = view->GetLocalBounds(); |
135 bounds.Inset(insets); | 120 bounds.Inset(insets); |
136 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); | 121 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); |
137 | |
138 if (draws_active_ && tray_background_view_->is_active()) { | |
139 cc::PaintFlags highlight_flags; | |
140 highlight_flags.setAntiAlias(true); | |
141 highlight_flags.setColor(kShelfButtonActivatedHighlightColor); | |
142 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_flags); | |
143 } | |
144 } | |
145 | |
146 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | |
147 const static int kImageTypeDefault = 0; | |
148 // TODO(estade): leftover type which should be removed along with the rest | |
149 // of pre-MD code. | |
150 // const static int kImageTypeOnBlack = 1; | |
151 const static int kImageTypePressed = 2; | |
152 const static int kNumStates = 3; | |
153 | |
154 const static int kImageHorizontal = 0; | |
155 const static int kImageVertical = 1; | |
156 const static int kNumOrientations = 2; | |
157 | |
158 const int kGridSizeForPainter = 9; | |
159 | |
160 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { | |
161 { | |
162 // Horizontal | |
163 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), | |
164 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), | |
165 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), | |
166 }, | |
167 { | |
168 // Vertical | |
169 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), | |
170 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), | |
171 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), | |
172 }}; | |
173 | |
174 WmShelf* shelf = GetShelf(); | |
175 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) | |
176 ? kImageHorizontal | |
177 : kImageVertical; | |
178 | |
179 int state = kImageTypeDefault; | |
180 if (draws_active_ && tray_background_view_->is_active()) | |
181 state = kImageTypePressed; | |
182 else | |
183 state = kImageTypeDefault; | |
184 | |
185 ui::CreateNineImagePainter(kImages[orientation][state]) | |
186 ->Paint(canvas, view->GetLocalBounds()); | |
187 } | |
188 | |
189 // Overridden from views::Background. | |
190 void Paint(gfx::Canvas* canvas, views::View* view) const override { | |
191 if (MaterialDesignController::IsShelfMaterial()) | |
192 PaintMaterial(canvas, view); | |
193 else | |
194 PaintNonMaterial(canvas, view); | |
195 } | 122 } |
196 | 123 |
197 // Reference to the TrayBackgroundView for which this is a background. | 124 // Reference to the TrayBackgroundView for which this is a background. |
198 TrayBackgroundView* tray_background_view_; | 125 TrayBackgroundView* tray_background_view_; |
199 | 126 |
200 // Determines whether we should draw an active background for the view when it | |
201 // is active. This is used in non-MD mode. In material design mode, an active | |
202 // ink drop ripple would indicate if the view is active or not. | |
203 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code | |
204 // is removed (see https://crbug.com/614453). | |
205 bool draws_active_; | |
206 | |
207 SkColor color_; | 127 SkColor color_; |
208 | 128 |
209 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 129 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
210 }; | 130 }; |
211 | 131 |
212 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | 132 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) |
213 : alignment_(alignment) { | 133 : alignment_(alignment) { |
214 UpdateLayout(); | 134 UpdateLayout(); |
215 } | 135 } |
216 | 136 |
(...skipping 28 matching lines...) Expand all Loading... |
245 | 165 |
246 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 166 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
247 bool is_horizontal = IsHorizontalAlignment(alignment_); | 167 bool is_horizontal = IsHorizontalAlignment(alignment_); |
248 | 168 |
249 // Adjust the size of status tray dark background by adding additional | 169 // Adjust the size of status tray dark background by adding additional |
250 // empty border. | 170 // empty border. |
251 views::BoxLayout::Orientation orientation = | 171 views::BoxLayout::Orientation orientation = |
252 is_horizontal ? views::BoxLayout::kHorizontal | 172 is_horizontal ? views::BoxLayout::kHorizontal |
253 : views::BoxLayout::kVertical; | 173 : views::BoxLayout::kVertical; |
254 | 174 |
255 if (ash::MaterialDesignController::IsShelfMaterial()) { | 175 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth; |
256 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth; | 176 gfx::Insets insets( |
257 gfx::Insets insets( | 177 is_horizontal |
258 is_horizontal | 178 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator) |
259 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator) | 179 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0)); |
260 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0)); | 180 MirrorInsetsIfNecessary(&insets); |
261 MirrorInsetsIfNecessary(&insets); | 181 SetBorder(views::CreateEmptyBorder(insets)); |
262 SetBorder(views::CreateEmptyBorder(insets)); | |
263 } else { | |
264 SetBorder(views::CreateEmptyBorder(gfx::Insets(kBackgroundAdjustPadding))); | |
265 } | |
266 | 182 |
267 int horizontal_margin = main_axis_margin_; | 183 int horizontal_margin = main_axis_margin_; |
268 int vertical_margin = cross_axis_margin_; | 184 int vertical_margin = cross_axis_margin_; |
269 if (!is_horizontal) | 185 if (!is_horizontal) |
270 std::swap(horizontal_margin, vertical_margin); | 186 std::swap(horizontal_margin, vertical_margin); |
271 views::BoxLayout* layout = | 187 views::BoxLayout* layout = |
272 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0); | 188 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0); |
273 | 189 |
274 if (!ash::MaterialDesignController::IsShelfMaterial()) | |
275 layout->SetDefaultFlex(1); | |
276 layout->set_minimum_cross_axis_size(kTrayItemSize); | 190 layout->set_minimum_cross_axis_size(kTrayItemSize); |
277 views::View::SetLayoutManager(layout); | 191 views::View::SetLayoutManager(layout); |
278 | 192 |
279 PreferredSizeChanged(); | 193 PreferredSizeChanged(); |
280 } | 194 } |
281 | 195 |
282 //////////////////////////////////////////////////////////////////////////////// | 196 //////////////////////////////////////////////////////////////////////////////// |
283 // TrayBackgroundView | 197 // TrayBackgroundView |
284 | 198 |
285 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) | 199 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf, bool draws_background) |
286 // Note the ink drop style is ignored. | 200 // Note the ink drop style is ignored. |
287 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), | 201 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
288 wm_shelf_(wm_shelf), | 202 wm_shelf_(wm_shelf), |
289 tray_container_(NULL), | 203 tray_container_(nullptr), |
290 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 204 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
291 background_(NULL), | 205 background_(nullptr), |
292 is_active_(false), | 206 is_active_(false), |
293 separator_visible_(true), | 207 separator_visible_(true), |
294 widget_observer_(new TrayWidgetObserver(this)) { | 208 widget_observer_(new TrayWidgetObserver(this)) { |
295 DCHECK(wm_shelf_); | 209 DCHECK(wm_shelf_); |
296 set_notify_enter_exit_on_child(true); | 210 set_notify_enter_exit_on_child(true); |
297 set_ink_drop_base_color(kShelfInkDropBaseColor); | 211 set_ink_drop_base_color(kShelfInkDropBaseColor); |
298 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 212 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
299 | 213 |
| 214 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 215 |
300 tray_container_ = new TrayContainer(shelf_alignment_); | 216 tray_container_ = new TrayContainer(shelf_alignment_); |
301 SetContents(tray_container_); | 217 if (draws_background) { |
| 218 background_ = new TrayBackground(this); |
| 219 tray_container_->set_background(background_); |
| 220 } |
| 221 AddChildView(tray_container_); |
| 222 |
302 tray_event_filter_.reset(new TrayEventFilter); | 223 tray_event_filter_.reset(new TrayEventFilter); |
303 | 224 |
304 SetPaintToLayer(); | 225 SetPaintToLayer(); |
305 layer()->SetFillsBoundsOpaquely(false); | 226 layer()->SetFillsBoundsOpaquely(false); |
306 // Start the tray items not visible, because visibility changes are animated. | 227 // Start the tray items not visible, because visibility changes are animated. |
307 views::View::SetVisible(false); | 228 views::View::SetVisible(false); |
308 } | 229 } |
309 | 230 |
310 TrayBackgroundView::~TrayBackgroundView() { | 231 TrayBackgroundView::~TrayBackgroundView() { |
311 if (GetWidget()) | 232 if (GetWidget()) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 bounds.set_width(bounds.width() + 2 * icon_size); | 339 bounds.set_width(bounds.width() + 2 * icon_size); |
419 bounds.set_height(bounds.height() + 2 * icon_size); | 340 bounds.set_height(bounds.height() + 2 * icon_size); |
420 std::unique_ptr<views::InkDropHighlight> highlight( | 341 std::unique_ptr<views::InkDropHighlight> highlight( |
421 new views::InkDropHighlight(bounds.size(), 0, | 342 new views::InkDropHighlight(bounds.size(), 0, |
422 gfx::RectF(bounds).CenterPoint(), | 343 gfx::RectF(bounds).CenterPoint(), |
423 GetInkDropBaseColor())); | 344 GetInkDropBaseColor())); |
424 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 345 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
425 return highlight; | 346 return highlight; |
426 } | 347 } |
427 | 348 |
428 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { | |
429 // If there is no ink drop, show "touch feedback". | |
430 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code | |
431 // is removed (see https://crbug.com/614453). | |
432 if (ink_drop_mode() == InkDropMode::OFF) { | |
433 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | |
434 SetIsActive(true); | |
435 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | |
436 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | |
437 SetIsActive(false); | |
438 } | |
439 } | |
440 ActionableView::OnGestureEvent(event); | |
441 } | |
442 | |
443 void TrayBackgroundView::SetContents(views::View* contents) { | |
444 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | |
445 AddChildView(contents); | |
446 } | |
447 | |
448 void TrayBackgroundView::SetContentsBackground(bool draws_active) { | |
449 background_ = new TrayBackground(this, draws_active); | |
450 tray_container_->set_background(background_); | |
451 } | |
452 | |
453 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 349 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
454 shelf_alignment_ = alignment; | 350 shelf_alignment_ = alignment; |
455 tray_container_->SetAlignment(alignment); | 351 tray_container_->SetAlignment(alignment); |
456 } | 352 } |
457 | 353 |
458 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 354 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
459 // If there is another animation in the queue, the reverse animation was | 355 // If there is another animation in the queue, the reverse animation was |
460 // triggered before the completion of animating to invisible. Do not turn off | 356 // triggered before the completion of animating to invisible. Do not turn off |
461 // the visibility so that the next animation may render. The value of | 357 // the visibility so that the next animation may render. The value of |
462 // layer()->GetTargetVisibility() can be incorrect if the hide animation was | 358 // layer()->GetTargetVisibility() can be incorrect if the hide animation was |
(...skipping 30 matching lines...) Expand all Loading... |
493 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 389 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
494 } | 390 } |
495 | 391 |
496 void TrayBackgroundView::SetIsActive(bool is_active) { | 392 void TrayBackgroundView::SetIsActive(bool is_active) { |
497 if (is_active_ == is_active) | 393 if (is_active_ == is_active) |
498 return; | 394 return; |
499 is_active_ = is_active; | 395 is_active_ = is_active; |
500 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED | 396 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED |
501 : views::InkDropState::DEACTIVATED, | 397 : views::InkDropState::DEACTIVATED, |
502 nullptr); | 398 nullptr); |
503 if (!background_) | |
504 return; | |
505 // TODO(mohsen): This is needed for non-MD version. Remove when non-MD code is | |
506 // removed (see https://crbug.com/614453). | |
507 SchedulePaint(); | |
508 } | 399 } |
509 | 400 |
510 void TrayBackgroundView::UpdateBubbleViewArrow( | 401 void TrayBackgroundView::UpdateBubbleViewArrow( |
511 views::TrayBubbleView* bubble_view) { | 402 views::TrayBubbleView* bubble_view) { |
512 // Nothing to do here. | 403 // Nothing to do here. |
513 } | 404 } |
514 | 405 |
515 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { | 406 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { |
516 if (background_) { | 407 if (background_) { |
517 background_->set_color(color); | 408 background_->set_color(color); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // When an action is performed, ink drop ripple is handled in SetIsActive(). | 448 // When an action is performed, ink drop ripple is handled in SetIsActive(). |
558 if (action_performed) | 449 if (action_performed) |
559 return; | 450 return; |
560 ActionableView::HandlePerformActionResult(action_performed, event); | 451 ActionableView::HandlePerformActionResult(action_performed, event); |
561 } | 452 } |
562 | 453 |
563 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { | 454 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { |
564 // The tray itself expands to the right and bottom edge of the screen to make | 455 // The tray itself expands to the right and bottom edge of the screen to make |
565 // sure clicking on the edges brings up the popup. However, the focus border | 456 // sure clicking on the edges brings up the popup. However, the focus border |
566 // should be only around the container. | 457 // should be only around the container. |
567 gfx::RectF paint_bounds; | 458 gfx::RectF paint_bounds(GetBackgroundBounds()); |
568 paint_bounds = gfx::RectF(GetBackgroundBounds()); | |
569 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); | 459 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); |
570 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, | 460 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, |
571 kFocusBorderThickness); | 461 kFocusBorderThickness); |
572 } | 462 } |
573 | 463 |
574 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 464 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
575 ActionableView::OnPaint(canvas); | 465 ActionableView::OnPaint(canvas); |
576 if (shelf()->GetBackgroundType() == | 466 if (shelf()->GetBackgroundType() == |
577 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 467 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || |
578 !separator_visible_) { | 468 !separator_visible_) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } | 503 } |
614 | 504 |
615 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 505 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
616 gfx::Insets insets = GetBackgroundInsets(); | 506 gfx::Insets insets = GetBackgroundInsets(); |
617 gfx::Rect bounds = GetLocalBounds(); | 507 gfx::Rect bounds = GetLocalBounds(); |
618 bounds.Inset(insets); | 508 bounds.Inset(insets); |
619 return bounds; | 509 return bounds; |
620 } | 510 } |
621 | 511 |
622 } // namespace ash | 512 } // namespace ash |
OLD | NEW |