| 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, bool draws_background) |
| 287 // Note the ink drop style is ignored. | 201 // Note the ink drop style is ignored. |
| 288 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), | 202 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
| 289 wm_shelf_(wm_shelf), | 203 wm_shelf_(wm_shelf), |
| 290 tray_container_(NULL), | 204 tray_container_(nullptr), |
| 291 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 205 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 292 background_(NULL), | 206 background_(nullptr), |
| 293 is_active_(false), | 207 is_active_(false), |
| 294 separator_visible_(true), | 208 separator_visible_(true), |
| 295 widget_observer_(new TrayWidgetObserver(this)) { | 209 widget_observer_(new TrayWidgetObserver(this)) { |
| 296 DCHECK(wm_shelf_); | 210 DCHECK(wm_shelf_); |
| 297 set_notify_enter_exit_on_child(true); | 211 set_notify_enter_exit_on_child(true); |
| 298 set_ink_drop_base_color(kShelfInkDropBaseColor); | 212 set_ink_drop_base_color(kShelfInkDropBaseColor); |
| 299 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 213 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
| 300 | 214 |
| 215 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 216 |
| 301 tray_container_ = new TrayContainer(shelf_alignment_); | 217 tray_container_ = new TrayContainer(shelf_alignment_); |
| 302 SetContents(tray_container_); | 218 if (draws_background) { |
| 219 background_ = new TrayBackground(this); |
| 220 tray_container_->set_background(background_); |
| 221 } |
| 222 AddChildView(tray_container_); |
| 223 |
| 303 tray_event_filter_.reset(new TrayEventFilter); | 224 tray_event_filter_.reset(new TrayEventFilter); |
| 304 | 225 |
| 305 SetPaintToLayer(); | 226 SetPaintToLayer(); |
| 306 layer()->SetFillsBoundsOpaquely(false); | 227 layer()->SetFillsBoundsOpaquely(false); |
| 307 // Start the tray items not visible, because visibility changes are animated. | 228 // Start the tray items not visible, because visibility changes are animated. |
| 308 views::View::SetVisible(false); | 229 views::View::SetVisible(false); |
| 309 } | 230 } |
| 310 | 231 |
| 311 TrayBackgroundView::~TrayBackgroundView() { | 232 TrayBackgroundView::~TrayBackgroundView() { |
| 312 if (GetWidget()) | 233 if (GetWidget()) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 bounds.set_width(bounds.width() + 2 * icon_size); | 341 bounds.set_width(bounds.width() + 2 * icon_size); |
| 421 bounds.set_height(bounds.height() + 2 * icon_size); | 342 bounds.set_height(bounds.height() + 2 * icon_size); |
| 422 std::unique_ptr<views::InkDropHighlight> highlight( | 343 std::unique_ptr<views::InkDropHighlight> highlight( |
| 423 new views::InkDropHighlight(bounds.size(), 0, | 344 new views::InkDropHighlight(bounds.size(), 0, |
| 424 gfx::RectF(bounds).CenterPoint(), | 345 gfx::RectF(bounds).CenterPoint(), |
| 425 GetInkDropBaseColor())); | 346 GetInkDropBaseColor())); |
| 426 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 347 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 427 return highlight; | 348 return highlight; |
| 428 } | 349 } |
| 429 | 350 |
| 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) { | |
| 446 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | |
| 447 AddChildView(contents); | |
| 448 } | |
| 449 | |
| 450 void TrayBackgroundView::SetContentsBackground(bool draws_active) { | |
| 451 background_ = new TrayBackground(this, draws_active); | |
| 452 tray_container_->set_background(background_); | |
| 453 } | |
| 454 | |
| 455 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 351 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
| 456 shelf_alignment_ = alignment; | 352 shelf_alignment_ = alignment; |
| 457 tray_container_->SetAlignment(alignment); | 353 tray_container_->SetAlignment(alignment); |
| 458 } | 354 } |
| 459 | 355 |
| 460 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 356 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
| 461 // If there is another animation in the queue, the reverse animation was | 357 // If there is another animation in the queue, the reverse animation was |
| 462 // triggered before the completion of animating to invisible. Do not turn off | 358 // triggered before the completion of animating to invisible. Do not turn off |
| 463 // the visibility so that the next animation may render. The value of | 359 // the visibility so that the next animation may render. The value of |
| 464 // layer()->GetTargetVisibility() can be incorrect if the hide animation was | 360 // layer()->GetTargetVisibility() can be incorrect if the hide animation was |
| (...skipping 30 matching lines...) Expand all Loading... |
| 495 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 391 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 496 } | 392 } |
| 497 | 393 |
| 498 void TrayBackgroundView::SetIsActive(bool is_active) { | 394 void TrayBackgroundView::SetIsActive(bool is_active) { |
| 499 if (is_active_ == is_active) | 395 if (is_active_ == is_active) |
| 500 return; | 396 return; |
| 501 is_active_ = is_active; | 397 is_active_ = is_active; |
| 502 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED | 398 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED |
| 503 : views::InkDropState::DEACTIVATED, | 399 : views::InkDropState::DEACTIVATED, |
| 504 nullptr); | 400 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 } | 401 } |
| 511 | 402 |
| 512 void TrayBackgroundView::UpdateBubbleViewArrow( | 403 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 513 views::TrayBubbleView* bubble_view) { | 404 views::TrayBubbleView* bubble_view) { |
| 514 // Nothing to do here. | 405 // Nothing to do here. |
| 515 } | 406 } |
| 516 | 407 |
| 517 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { | 408 void TrayBackgroundView::UpdateShelfItemBackground(SkColor color) { |
| 518 if (background_) { | 409 if (background_) { |
| 519 background_->set_color(color); | 410 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(). | 450 // When an action is performed, ink drop ripple is handled in SetIsActive(). |
| 560 if (action_performed) | 451 if (action_performed) |
| 561 return; | 452 return; |
| 562 ActionableView::HandlePerformActionResult(action_performed, event); | 453 ActionableView::HandlePerformActionResult(action_performed, event); |
| 563 } | 454 } |
| 564 | 455 |
| 565 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { | 456 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { |
| 566 // The tray itself expands to the right and bottom edge of the screen to make | 457 // 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 | 458 // sure clicking on the edges brings up the popup. However, the focus border |
| 568 // should be only around the container. | 459 // should be only around the container. |
| 569 gfx::RectF paint_bounds; | 460 gfx::RectF paint_bounds(GetBackgroundBounds()); |
| 570 if (MaterialDesignController::IsShelfMaterial()) { | 461 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, | 462 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, |
| 578 kFocusBorderThickness); | 463 kFocusBorderThickness); |
| 579 } | 464 } |
| 580 | 465 |
| 581 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 466 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 582 ActionableView::OnPaint(canvas); | 467 ActionableView::OnPaint(canvas); |
| 583 if (!MaterialDesignController::IsShelfMaterial() || | 468 if (shelf()->GetBackgroundType() == |
| 584 shelf()->GetBackgroundType() == | |
| 585 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 469 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || |
| 586 !separator_visible_) { | 470 !separator_visible_) { |
| 587 return; | 471 return; |
| 588 } | 472 } |
| 589 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 473 // 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 | 474 // right or left of the TrayBackgroundView when the system is LTR or RTL |
| 591 // aligned, respectively. For a vertical shelf draw the separator line | 475 // aligned, respectively. For a vertical shelf draw the separator line |
| 592 // underneath the items instead. | 476 // underneath the items instead. |
| 593 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | 477 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); |
| 594 const gfx::Rect local_bounds = GetLocalBounds(); | 478 const gfx::Rect local_bounds = GetLocalBounds(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 517 } |
| 634 | 518 |
| 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 519 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 636 gfx::Insets insets = GetBackgroundInsets(); | 520 gfx::Insets insets = GetBackgroundInsets(); |
| 637 gfx::Rect bounds = GetLocalBounds(); | 521 gfx::Rect bounds = GetLocalBounds(); |
| 638 bounds.Inset(insets); | 522 bounds.Inset(insets); |
| 639 return bounds; | 523 return bounds; |
| 640 } | 524 } |
| 641 | 525 |
| 642 } // namespace ash | 526 } // namespace ash |
| OLD | NEW |