Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: ash/system/tray/tray_background_view.cc

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_container.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/tray/tray_background_view.h" 5 #include "ash/system/tray/tray_background_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_constants.h" 11 #include "ash/shelf/shelf_constants.h"
11 #include "ash/shelf/wm_shelf.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/system/status_area_widget_delegate.h" 13 #include "ash/system/status_area_widget_delegate.h"
14 #include "ash/system/tray/system_tray_notifier.h" 14 #include "ash/system/tray/system_tray_notifier.h"
15 #include "ash/system/tray/tray_constants.h" 15 #include "ash/system/tray/tray_constants.h"
16 #include "ash/system/tray/tray_container.h" 16 #include "ash/system/tray/tray_container.h"
17 #include "ash/system/tray/tray_event_filter.h" 17 #include "ash/system/tray/tray_event_filter.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "ui/accessibility/ax_node_data.h" 19 #include "ui/accessibility/ax_node_data.h"
20 #include "ui/compositor/layer.h" 20 #include "ui/compositor/layer.h"
21 #include "ui/compositor/layer_animation_element.h" 21 #include "ui/compositor/layer_animation_element.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 TrayBackgroundView* tray_background_view_; 124 TrayBackgroundView* tray_background_view_;
125 125
126 SkColor color_; 126 SkColor color_;
127 127
128 DISALLOW_COPY_AND_ASSIGN(TrayBackground); 128 DISALLOW_COPY_AND_ASSIGN(TrayBackground);
129 }; 129 };
130 130
131 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
132 // TrayBackgroundView 132 // TrayBackgroundView
133 133
134 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) 134 TrayBackgroundView::TrayBackgroundView(Shelf* shelf)
135 // Note the ink drop style is ignored. 135 // Note the ink drop style is ignored.
136 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), 136 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS),
137 wm_shelf_(wm_shelf), 137 shelf_(shelf),
138 tray_container_(new TrayContainer(wm_shelf)), 138 tray_container_(new TrayContainer(shelf)),
139 background_(new TrayBackground(this)), 139 background_(new TrayBackground(this)),
140 is_active_(false), 140 is_active_(false),
141 separator_visible_(true), 141 separator_visible_(true),
142 widget_observer_(new TrayWidgetObserver(this)) { 142 widget_observer_(new TrayWidgetObserver(this)) {
143 DCHECK(wm_shelf_); 143 DCHECK(shelf_);
144 set_notify_enter_exit_on_child(true); 144 set_notify_enter_exit_on_child(true);
145 set_ink_drop_base_color(kShelfInkDropBaseColor); 145 set_ink_drop_base_color(kShelfInkDropBaseColor);
146 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 146 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
147 147
148 SetLayoutManager(new views::FillLayout); 148 SetLayoutManager(new views::FillLayout);
149 149
150 tray_container_->set_background(background_); 150 tray_container_->set_background(background_);
151 AddChildView(tray_container_); 151 AddChildView(tray_container_);
152 152
153 tray_event_filter_.reset(new TrayEventFilter); 153 tray_event_filter_.reset(new TrayEventFilter);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // This is needed so that OnImplicitAnimationsCompleted() is called even upon 296 // This is needed so that OnImplicitAnimationsCompleted() is called even upon
297 // destruction of the animator. This can occure when parallel animations 297 // destruction of the animator. This can occure when parallel animations
298 // caused by ScreenRotationAnimator end before the animations of 298 // caused by ScreenRotationAnimator end before the animations of
299 // TrayBackgroundView. This allows for a proper update to the visual state of 299 // TrayBackgroundView. This allows for a proper update to the visual state of
300 // the view. (crbug.com/476667) 300 // the view. (crbug.com/476667)
301 return true; 301 return true;
302 } 302 }
303 303
304 void TrayBackgroundView::HideTransformation() { 304 void TrayBackgroundView::HideTransformation() {
305 gfx::Transform transform; 305 gfx::Transform transform;
306 if (wm_shelf_->IsHorizontalAlignment()) 306 if (shelf_->IsHorizontalAlignment())
307 transform.Translate(width(), 0.0f); 307 transform.Translate(width(), 0.0f);
308 else 308 else
309 transform.Translate(0.0f, height()); 309 transform.Translate(0.0f, height());
310 layer()->SetTransform(transform); 310 layer()->SetTransform(transform);
311 } 311 }
312 312
313 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { 313 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const {
314 if (wm_shelf_->alignment() == SHELF_ALIGNMENT_LEFT) 314 if (shelf_->alignment() == SHELF_ALIGNMENT_LEFT)
315 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; 315 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT;
316 if (wm_shelf_->alignment() == SHELF_ALIGNMENT_RIGHT) 316 if (shelf_->alignment() == SHELF_ALIGNMENT_RIGHT)
317 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; 317 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT;
318 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; 318 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
319 } 319 }
320 320
321 void TrayBackgroundView::SetIsActive(bool is_active) { 321 void TrayBackgroundView::SetIsActive(bool is_active) {
322 if (is_active_ == is_active) 322 if (is_active_ == is_active)
323 return; 323 return;
324 is_active_ = is_active; 324 is_active_ = is_active;
325 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED 325 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED
326 : views::InkDropState::DEACTIVATED, 326 : views::InkDropState::DEACTIVATED,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 !separator_visible_) { 395 !separator_visible_) {
396 return; 396 return;
397 } 397 }
398 // In the given |canvas|, for a horizontal shelf draw a separator line to the 398 // In the given |canvas|, for a horizontal shelf draw a separator line to the
399 // right or left of the TrayBackgroundView when the system is LTR or RTL 399 // right or left of the TrayBackgroundView when the system is LTR or RTL
400 // aligned, respectively. For a vertical shelf draw the separator line 400 // aligned, respectively. For a vertical shelf draw the separator line
401 // underneath the items instead. 401 // underneath the items instead.
402 const gfx::Rect local_bounds = GetLocalBounds(); 402 const gfx::Rect local_bounds = GetLocalBounds();
403 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); 403 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D);
404 404
405 if (wm_shelf_->IsHorizontalAlignment()) { 405 if (shelf_->IsHorizontalAlignment()) {
406 const gfx::PointF point( 406 const gfx::PointF point(
407 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), 407 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth),
408 (kShelfSize - kTrayItemSize) / 2); 408 (kShelfSize - kTrayItemSize) / 2);
409 const gfx::Vector2dF vector(0, kTrayItemSize); 409 const gfx::Vector2dF vector(0, kTrayItemSize);
410 canvas->Draw1pxLine(point, point + vector, color); 410 canvas->Draw1pxLine(point, point + vector, color);
411 } else { 411 } else {
412 const gfx::PointF point((kShelfSize - kTrayItemSize) / 2, 412 const gfx::PointF point((kShelfSize - kTrayItemSize) / 2,
413 local_bounds.height() - kSeparatorWidth); 413 local_bounds.height() - kSeparatorWidth);
414 const gfx::Vector2dF vector(kTrayItemSize, 0); 414 const gfx::Vector2dF vector(kTrayItemSize, 0);
415 canvas->Draw1pxLine(point, point + vector, color); 415 canvas->Draw1pxLine(point, point + vector, color);
416 } 416 }
417 } 417 }
418 418
419 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { 419 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const {
420 gfx::Insets insets = 420 gfx::Insets insets =
421 GetMirroredBackgroundInsets(wm_shelf_->IsHorizontalAlignment()); 421 GetMirroredBackgroundInsets(shelf_->IsHorizontalAlignment());
422 422
423 // |insets| are relative to contents bounds. Change them to be relative to 423 // |insets| are relative to contents bounds. Change them to be relative to
424 // local bounds. 424 // local bounds.
425 gfx::Insets local_contents_insets = 425 gfx::Insets local_contents_insets =
426 GetLocalBounds().InsetsFrom(GetContentsBounds()); 426 GetLocalBounds().InsetsFrom(GetContentsBounds());
427 MirrorInsetsIfNecessary(&local_contents_insets); 427 MirrorInsetsIfNecessary(&local_contents_insets);
428 insets += local_contents_insets; 428 insets += local_contents_insets;
429 429
430 return insets; 430 return insets;
431 } 431 }
432 432
433 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { 433 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const {
434 gfx::Insets insets = GetBackgroundInsets(); 434 gfx::Insets insets = GetBackgroundInsets();
435 gfx::Rect bounds = GetLocalBounds(); 435 gfx::Rect bounds = GetLocalBounds();
436 bounds.Inset(insets); 436 bounds.Inset(insets);
437 return bounds; 437 return bounds;
438 } 438 }
439 439
440 } // namespace ash 440 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698