Chromium Code Reviews| 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_lookup.h" | 15 #include "ash/common/wm_lookup.h" |
| 18 #include "ash/common/wm_shell.h" | |
| 19 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
| 20 #include "ash/public/cpp/shell_window_ids.h" | |
| 21 #include "ash/resources/grit/ash_resources.h" | |
| 22 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 23 #include "ui/accessibility/ax_node_data.h" | 18 #include "ui/accessibility/ax_node_data.h" |
| 24 #include "ui/base/nine_image_painter_factory.h" | |
| 25 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
| 26 #include "ui/compositor/layer_animation_element.h" | 20 #include "ui/compositor/layer_animation_element.h" |
| 27 #include "ui/compositor/scoped_layer_animation_settings.h" | 21 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 28 #include "ui/events/event_constants.h" | 22 #include "ui/events/event_constants.h" |
| 29 #include "ui/gfx/animation/tween.h" | 23 #include "ui/gfx/animation/tween.h" |
| 30 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 32 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 33 #include "ui/gfx/image/image_skia.h" | |
| 34 #include "ui/gfx/image/image_skia_operations.h" | |
| 35 #include "ui/gfx/nine_image_painter.h" | |
| 36 #include "ui/gfx/scoped_canvas.h" | 27 #include "ui/gfx/scoped_canvas.h" |
| 37 #include "ui/gfx/skia_util.h" | |
| 38 #include "ui/gfx/transform.h" | 28 #include "ui/gfx/transform.h" |
| 39 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 29 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 40 #include "ui/views/animation/ink_drop_highlight.h" | 30 #include "ui/views/animation/ink_drop_highlight.h" |
| 41 #include "ui/views/animation/ink_drop_mask.h" | 31 #include "ui/views/animation/ink_drop_mask.h" |
| 42 #include "ui/views/background.h" | 32 #include "ui/views/background.h" |
| 43 #include "ui/views/layout/box_layout.h" | 33 #include "ui/views/layout/box_layout.h" |
| 44 #include "ui/wm/core/window_animations.h" | |
| 45 | 34 |
| 46 namespace { | 35 namespace { |
| 47 | 36 |
| 48 const int kAnimationDurationForPopupMs = 200; | 37 const int kAnimationDurationForPopupMs = 200; |
| 49 | 38 |
| 50 // Duration of opacity animation for visibility changes. | 39 // Duration of opacity animation for visibility changes. |
| 51 const int kAnimationDurationForVisibilityMs = 250; | 40 const int kAnimationDurationForVisibilityMs = 250; |
| 52 | 41 |
| 53 // When becoming visible delay the animation so that StatusAreaWidgetDelegate | 42 // When becoming visible delay the animation so that StatusAreaWidgetDelegate |
| 54 // can animate sibling views out of the position to be occuped by the | 43 // can animate sibling views out of the position to be occuped by the |
| 55 // TrayBackgroundView. | 44 // TrayBackgroundView. |
| 56 const int kShowAnimationDelayMs = 100; | 45 const int kShowAnimationDelayMs = 100; |
| 57 | 46 |
| 58 // Additional padding used to adjust the user-visible size of status tray | |
| 59 // and overview button dark background. | |
| 60 const int kBackgroundAdjustPadding = 3; | |
| 61 | |
| 62 // Switches left and right insets if RTL mode is active. | 47 // Switches left and right insets if RTL mode is active. |
| 63 void MirrorInsetsIfNecessary(gfx::Insets* insets) { | 48 void MirrorInsetsIfNecessary(gfx::Insets* insets) { |
| 64 if (base::i18n::IsRTL()) { | 49 if (base::i18n::IsRTL()) { |
| 65 insets->Set(insets->top(), insets->right(), insets->bottom(), | 50 insets->Set(insets->top(), insets->right(), insets->bottom(), |
| 66 insets->left()); | 51 insets->left()); |
| 67 } | 52 } |
| 68 } | 53 } |
| 69 | 54 |
| 70 // Returns background insets relative to the contents bounds of the view and | 55 // Returns background insets relative to the contents bounds of the view and |
| 71 // mirrored if RTL mode is active. | 56 // mirrored if RTL mode is active. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } | 92 } |
| 108 | 93 |
| 109 private: | 94 private: |
| 110 TrayBackgroundView* host_; | 95 TrayBackgroundView* host_; |
| 111 | 96 |
| 112 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); | 97 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); |
| 113 }; | 98 }; |
| 114 | 99 |
| 115 class TrayBackground : public views::Background { | 100 class TrayBackground : public views::Background { |
| 116 public: | 101 public: |
| 117 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) | 102 explicit TrayBackground(TrayBackgroundView* tray_background_view) |
| 118 : tray_background_view_(tray_background_view), | 103 : tray_background_view_(tray_background_view), |
| 119 draws_active_(draws_active), | |
| 120 color_(SK_ColorTRANSPARENT) {} | 104 color_(SK_ColorTRANSPARENT) {} |
| 121 | 105 |
| 122 ~TrayBackground() override {} | 106 ~TrayBackground() override {} |
| 123 | 107 |
| 124 void set_color(SkColor color) { color_ = color; } | 108 void set_color(SkColor color) { color_ = color; } |
| 125 | 109 |
| 126 private: | 110 private: |
| 127 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } | 111 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } |
| 128 | 112 |
| 129 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 113 // Overridden from views::Background. |
| 114 void Paint(gfx::Canvas* canvas, views::View* view) const override { | |
| 130 cc::PaintFlags background_flags; | 115 cc::PaintFlags background_flags; |
| 131 background_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 116 background_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
| 132 background_flags.setColor(color_); | 117 background_flags.setColor(color_); |
| 133 gfx::Insets insets = | 118 gfx::Insets insets = |
| 134 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); | 119 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); |
| 135 gfx::Rect bounds = view->GetLocalBounds(); | 120 gfx::Rect bounds = view->GetLocalBounds(); |
| 136 bounds.Inset(insets); | 121 bounds.Inset(insets); |
| 137 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); | 122 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); |
| 138 | |
| 139 if (draws_active_ && tray_background_view_->is_active()) { | |
| 140 cc::PaintFlags highlight_flags; | |
| 141 highlight_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | |
| 142 highlight_flags.setColor(kShelfButtonActivatedHighlightColor); | |
| 143 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_flags); | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | |
| 148 const static int kImageTypeDefault = 0; | |
| 149 // TODO(estade): leftover type which should be removed along with the rest | |
| 150 // of pre-MD code. | |
| 151 // const static int kImageTypeOnBlack = 1; | |
| 152 const static int kImageTypePressed = 2; | |
| 153 const static int kNumStates = 3; | |
| 154 | |
| 155 const static int kImageHorizontal = 0; | |
| 156 const static int kImageVertical = 1; | |
| 157 const static int kNumOrientations = 2; | |
| 158 | |
| 159 const int kGridSizeForPainter = 9; | |
| 160 | |
| 161 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { | |
| 162 { | |
| 163 // Horizontal | |
| 164 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), | |
| 165 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), | |
| 166 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), | |
| 167 }, | |
| 168 { | |
| 169 // Vertical | |
| 170 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), | |
| 171 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), | |
| 172 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), | |
| 173 }}; | |
| 174 | |
| 175 WmShelf* shelf = GetShelf(); | |
| 176 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) | |
| 177 ? kImageHorizontal | |
| 178 : kImageVertical; | |
| 179 | |
| 180 int state = kImageTypeDefault; | |
| 181 if (draws_active_ && tray_background_view_->is_active()) | |
| 182 state = kImageTypePressed; | |
| 183 else | |
| 184 state = kImageTypeDefault; | |
| 185 | |
| 186 ui::CreateNineImagePainter(kImages[orientation][state]) | |
| 187 ->Paint(canvas, view->GetLocalBounds()); | |
| 188 } | |
| 189 | |
| 190 // Overridden from views::Background. | |
| 191 void Paint(gfx::Canvas* canvas, views::View* view) const override { | |
| 192 if (MaterialDesignController::IsShelfMaterial()) | |
| 193 PaintMaterial(canvas, view); | |
| 194 else | |
| 195 PaintNonMaterial(canvas, view); | |
| 196 } | 123 } |
| 197 | 124 |
| 198 // Reference to the TrayBackgroundView for which this is a background. | 125 // Reference to the TrayBackgroundView for which this is a background. |
| 199 TrayBackgroundView* tray_background_view_; | 126 TrayBackgroundView* tray_background_view_; |
| 200 | 127 |
| 201 // Determines whether we should draw an active background for the view when it | |
| 202 // is active. This is used in non-MD mode. In material design mode, an active | |
| 203 // ink drop ripple would indicate if the view is active or not. | |
| 204 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code | |
| 205 // is removed (see https://crbug.com/614453). | |
| 206 bool draws_active_; | |
| 207 | |
| 208 SkColor color_; | 128 SkColor color_; |
| 209 | 129 |
| 210 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 130 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
| 211 }; | 131 }; |
| 212 | 132 |
| 213 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | 133 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) |
| 214 : alignment_(alignment) { | 134 : alignment_(alignment) { |
| 215 UpdateLayout(); | 135 UpdateLayout(); |
| 216 } | 136 } |
| 217 | 137 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 246 | 166 |
| 247 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 167 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
| 248 bool is_horizontal = IsHorizontalAlignment(alignment_); | 168 bool is_horizontal = IsHorizontalAlignment(alignment_); |
| 249 | 169 |
| 250 // Adjust the size of status tray dark background by adding additional | 170 // Adjust the size of status tray dark background by adding additional |
| 251 // empty border. | 171 // empty border. |
| 252 views::BoxLayout::Orientation orientation = | 172 views::BoxLayout::Orientation orientation = |
| 253 is_horizontal ? views::BoxLayout::kHorizontal | 173 is_horizontal ? views::BoxLayout::kHorizontal |
| 254 : views::BoxLayout::kVertical; | 174 : views::BoxLayout::kVertical; |
| 255 | 175 |
| 256 if (ash::MaterialDesignController::IsShelfMaterial()) { | 176 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth; |
| 257 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth; | 177 gfx::Insets insets( |
| 258 gfx::Insets insets( | 178 is_horizontal |
| 259 is_horizontal | 179 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator) |
| 260 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator) | 180 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0)); |
| 261 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0)); | 181 MirrorInsetsIfNecessary(&insets); |
| 262 MirrorInsetsIfNecessary(&insets); | 182 SetBorder(views::CreateEmptyBorder(insets)); |
| 263 SetBorder(views::CreateEmptyBorder(insets)); | |
| 264 } else { | |
| 265 SetBorder(views::CreateEmptyBorder(gfx::Insets(kBackgroundAdjustPadding))); | |
| 266 } | |
| 267 | 183 |
| 268 int horizontal_margin = main_axis_margin_; | 184 int horizontal_margin = main_axis_margin_; |
| 269 int vertical_margin = cross_axis_margin_; | 185 int vertical_margin = cross_axis_margin_; |
| 270 if (!is_horizontal) | 186 if (!is_horizontal) |
| 271 std::swap(horizontal_margin, vertical_margin); | 187 std::swap(horizontal_margin, vertical_margin); |
| 272 views::BoxLayout* layout = | 188 views::BoxLayout* layout = |
| 273 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0); | 189 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0); |
| 274 | 190 |
| 275 if (!ash::MaterialDesignController::IsShelfMaterial()) | |
| 276 layout->SetDefaultFlex(1); | |
| 277 layout->set_minimum_cross_axis_size(kTrayItemSize); | 191 layout->set_minimum_cross_axis_size(kTrayItemSize); |
| 278 views::View::SetLayoutManager(layout); | 192 views::View::SetLayoutManager(layout); |
| 279 | 193 |
| 280 PreferredSizeChanged(); | 194 PreferredSizeChanged(); |
| 281 } | 195 } |
| 282 | 196 |
| 283 //////////////////////////////////////////////////////////////////////////////// | 197 //////////////////////////////////////////////////////////////////////////////// |
| 284 // TrayBackgroundView | 198 // TrayBackgroundView |
| 285 | 199 |
| 286 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) | 200 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 bounds.set_width(bounds.width() + 2 * icon_size); | 334 bounds.set_width(bounds.width() + 2 * icon_size); |
| 421 bounds.set_height(bounds.height() + 2 * icon_size); | 335 bounds.set_height(bounds.height() + 2 * icon_size); |
| 422 std::unique_ptr<views::InkDropHighlight> highlight( | 336 std::unique_ptr<views::InkDropHighlight> highlight( |
| 423 new views::InkDropHighlight(bounds.size(), 0, | 337 new views::InkDropHighlight(bounds.size(), 0, |
| 424 gfx::RectF(bounds).CenterPoint(), | 338 gfx::RectF(bounds).CenterPoint(), |
| 425 GetInkDropBaseColor())); | 339 GetInkDropBaseColor())); |
| 426 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 340 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 427 return highlight; | 341 return highlight; |
| 428 } | 342 } |
| 429 | 343 |
| 430 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { | |
| 431 // If there is no ink drop, show "touch feedback". | |
| 432 // TODO(mohsen): This is used only in non-MD version. Remove when non-MD code | |
| 433 // is removed (see https://crbug.com/614453). | |
| 434 if (ink_drop_mode() == InkDropMode::OFF) { | |
| 435 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | |
| 436 SetIsActive(true); | |
| 437 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | |
| 438 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | |
| 439 SetIsActive(false); | |
| 440 } | |
| 441 } | |
| 442 ActionableView::OnGestureEvent(event); | |
| 443 } | |
| 444 | |
| 445 void TrayBackgroundView::SetContents(views::View* contents) { | 344 void TrayBackgroundView::SetContents(views::View* contents) { |
| 446 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 345 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 447 AddChildView(contents); | 346 AddChildView(contents); |
| 448 } | 347 } |
| 449 | 348 |
| 450 void TrayBackgroundView::SetContentsBackground(bool draws_active) { | 349 void TrayBackgroundView::SetContentsBackground() { |
| 451 background_ = new TrayBackground(this, draws_active); | 350 background_ = new TrayBackground(this); |
|
Evan Stade
2017/03/01 04:12:21
Do you need this function?
mohsen
2017/03/01 04:40:41
It is not called from LogoutButtonTray. So, I thin
Evan Stade
2017/03/01 07:20:21
Good point, but I still think we should remove it
mohsen
2017/03/01 17:48:05
I think logout button would still need a similar m
| |
| 452 tray_container_->set_background(background_); | 351 tray_container_->set_background(background_); |
| 453 } | 352 } |
| 454 | 353 |
| 455 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 354 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
| 456 shelf_alignment_ = alignment; | 355 shelf_alignment_ = alignment; |
| 457 tray_container_->SetAlignment(alignment); | 356 tray_container_->SetAlignment(alignment); |
| 458 } | 357 } |
| 459 | 358 |
| 460 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 359 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
| 461 // If there is another animation in the queue, the reverse animation was | 360 // If there is another animation in the queue, the reverse animation was |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 394 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 496 } | 395 } |
| 497 | 396 |
| 498 void TrayBackgroundView::SetIsActive(bool is_active) { | 397 void TrayBackgroundView::SetIsActive(bool is_active) { |
| 499 if (is_active_ == is_active) | 398 if (is_active_ == is_active) |
| 500 return; | 399 return; |
| 501 is_active_ = is_active; | 400 is_active_ = is_active; |
| 502 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED | 401 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED |
| 503 : views::InkDropState::DEACTIVATED, | 402 : views::InkDropState::DEACTIVATED, |
| 504 nullptr); | 403 nullptr); |
| 505 if (!background_) | |
| 506 return; | |
| 507 // TODO(mohsen): This is needed for non-MD version. Remove when non-MD code is | |
| 508 // removed (see https://crbug.com/614453). | |
| 509 SchedulePaint(); | |
| 510 } | 404 } |
| 511 | 405 |
| 512 void TrayBackgroundView::UpdateBubbleViewArrow( | 406 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 513 views::TrayBubbleView* bubble_view) { | 407 views::TrayBubbleView* bubble_view) { |
| 514 // Nothing to do here. | 408 // Nothing to do here. |
| 515 } | 409 } |
| 516 | 410 |
| 517 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { | 411 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { |
| 518 if (background_) { | 412 if (background_) { |
| 519 background_->set_color(color); | 413 background_->set_color(color); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 // When an action is performed, ink drop ripple is handled in SetIsActive(). | 453 // When an action is performed, ink drop ripple is handled in SetIsActive(). |
| 560 if (action_performed) | 454 if (action_performed) |
| 561 return; | 455 return; |
| 562 ActionableView::HandlePerformActionResult(action_performed, event); | 456 ActionableView::HandlePerformActionResult(action_performed, event); |
| 563 } | 457 } |
| 564 | 458 |
| 565 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { | 459 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { |
| 566 // The tray itself expands to the right and bottom edge of the screen to make | 460 // The tray itself expands to the right and bottom edge of the screen to make |
| 567 // sure clicking on the edges brings up the popup. However, the focus border | 461 // sure clicking on the edges brings up the popup. However, the focus border |
| 568 // should be only around the container. | 462 // should be only around the container. |
| 569 gfx::RectF paint_bounds; | 463 gfx::RectF paint_bounds(GetBackgroundBounds()); |
| 570 if (MaterialDesignController::IsShelfMaterial()) { | 464 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); |
| 571 paint_bounds = gfx::RectF(GetBackgroundBounds()); | |
| 572 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); | |
| 573 } else { | |
| 574 paint_bounds = gfx::RectF(GetContentsBounds()); | |
| 575 paint_bounds.Inset(gfx::Insets(1)); | |
| 576 } | |
| 577 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, | 465 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, |
| 578 kFocusBorderThickness); | 466 kFocusBorderThickness); |
| 579 } | 467 } |
| 580 | 468 |
| 581 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 469 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 582 ActionableView::OnPaint(canvas); | 470 ActionableView::OnPaint(canvas); |
| 583 if (!MaterialDesignController::IsShelfMaterial() || | 471 if (shelf()->GetBackgroundType() == |
| 584 shelf()->GetBackgroundType() == | |
| 585 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 472 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || |
| 586 !separator_visible_) { | 473 !separator_visible_) { |
| 587 return; | 474 return; |
| 588 } | 475 } |
| 589 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 476 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
| 590 // right or left of the TrayBackgroundView when the system is LTR or RTL | 477 // right or left of the TrayBackgroundView when the system is LTR or RTL |
| 591 // aligned, respectively. For a vertical shelf draw the separator line | 478 // aligned, respectively. For a vertical shelf draw the separator line |
| 592 // underneath the items instead. | 479 // underneath the items instead. |
| 593 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | 480 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); |
| 594 const gfx::Rect local_bounds = GetLocalBounds(); | 481 const gfx::Rect local_bounds = GetLocalBounds(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 } | 520 } |
| 634 | 521 |
| 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 522 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 636 gfx::Insets insets = GetBackgroundInsets(); | 523 gfx::Insets insets = GetBackgroundInsets(); |
| 637 gfx::Rect bounds = GetLocalBounds(); | 524 gfx::Rect bounds = GetLocalBounds(); |
| 638 bounds.Inset(insets); | 525 bounds.Inset(insets); |
| 639 return bounds; | 526 return bounds; |
| 640 } | 527 } |
| 641 | 528 |
| 642 } // namespace ash | 529 } // namespace ash |
| OLD | NEW |