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/system/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_util.h" | 10 #include "ash/shelf/shelf_util.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 ->Paint(canvas, view->GetLocalBounds()); | 150 ->Paint(canvas, view->GetLocalBounds()); |
151 } | 151 } |
152 | 152 |
153 SkColor color_; | 153 SkColor color_; |
154 // Reference to the TrayBackgroundView for which this is a background. | 154 // Reference to the TrayBackgroundView for which this is a background. |
155 TrayBackgroundView* tray_background_view_; | 155 TrayBackgroundView* tray_background_view_; |
156 | 156 |
157 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 157 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
158 }; | 158 }; |
159 | 159 |
160 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | 160 TrayBackgroundView::TrayContainer::TrayContainer(wm::ShelfAlignment alignment) |
161 : alignment_(alignment) { | 161 : alignment_(alignment) { |
162 UpdateLayout(); | 162 UpdateLayout(); |
163 } | 163 } |
164 | 164 |
165 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { | 165 void TrayBackgroundView::TrayContainer::SetAlignment( |
| 166 wm::ShelfAlignment alignment) { |
166 if (alignment_ == alignment) | 167 if (alignment_ == alignment) |
167 return; | 168 return; |
168 alignment_ = alignment; | 169 alignment_ = alignment; |
169 UpdateLayout(); | 170 UpdateLayout(); |
170 } | 171 } |
171 | 172 |
172 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const { | 173 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const { |
173 if (size_.IsEmpty()) | 174 if (size_.IsEmpty()) |
174 return views::View::GetPreferredSize(); | 175 return views::View::GetPreferredSize(); |
175 return size_; | 176 return size_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 219 } |
219 PreferredSizeChanged(); | 220 PreferredSizeChanged(); |
220 } | 221 } |
221 | 222 |
222 //////////////////////////////////////////////////////////////////////////////// | 223 //////////////////////////////////////////////////////////////////////////////// |
223 // TrayBackgroundView | 224 // TrayBackgroundView |
224 | 225 |
225 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) | 226 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) |
226 : status_area_widget_(status_area_widget), | 227 : status_area_widget_(status_area_widget), |
227 tray_container_(NULL), | 228 tray_container_(NULL), |
228 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 229 shelf_alignment_(wm::SHELF_ALIGNMENT_BOTTOM), |
229 background_(NULL), | 230 background_(NULL), |
230 hide_background_animator_(this, 0, kTrayBackgroundAlpha), | 231 hide_background_animator_(this, 0, kTrayBackgroundAlpha), |
231 hover_background_animator_( | 232 hover_background_animator_( |
232 this, | 233 this, |
233 0, | 234 0, |
234 kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), | 235 kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), |
235 hovered_(false), | 236 hovered_(false), |
236 draw_background_as_active_(false), | 237 draw_background_as_active_(false), |
237 widget_observer_(new TrayWidgetObserver(this)) { | 238 widget_observer_(new TrayWidgetObserver(this)) { |
238 set_notify_enter_exit_on_child(true); | 239 set_notify_enter_exit_on_child(true); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 387 |
387 void TrayBackgroundView::SetContentsBackground() { | 388 void TrayBackgroundView::SetContentsBackground() { |
388 background_ = new TrayBackground(this); | 389 background_ = new TrayBackground(this); |
389 tray_container_->set_background(background_); | 390 tray_container_->set_background(background_); |
390 } | 391 } |
391 | 392 |
392 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 393 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
393 return status_area_widget()->shelf_widget()->shelf_layout_manager(); | 394 return status_area_widget()->shelf_widget()->shelf_layout_manager(); |
394 } | 395 } |
395 | 396 |
396 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 397 void TrayBackgroundView::SetShelfAlignment(wm::ShelfAlignment alignment) { |
397 shelf_alignment_ = alignment; | 398 shelf_alignment_ = alignment; |
398 SetTrayBorder(); | 399 SetTrayBorder(); |
399 tray_container_->SetAlignment(alignment); | 400 tray_container_->SetAlignment(alignment); |
400 } | 401 } |
401 | 402 |
402 void TrayBackgroundView::SetTrayBorder() { | 403 void TrayBackgroundView::SetTrayBorder() { |
403 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 404 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
404 // Tray views are laid out right-to-left or bottom-to-top | 405 // Tray views are laid out right-to-left or bottom-to-top |
405 bool on_edge = (this == parent->child_at(0)); | 406 bool on_edge = (this == parent->child_at(0)); |
406 int left_edge, top_edge, right_edge, bottom_edge; | 407 int left_edge, top_edge, right_edge, bottom_edge; |
407 if (IsHorizontalAlignment(shelf_alignment())) { | 408 if (IsHorizontalAlignment(shelf_alignment())) { |
408 top_edge = ShelfLayoutManager::kShelfItemInset; | 409 top_edge = ShelfLayoutManager::kShelfItemInset; |
409 left_edge = 0; | 410 left_edge = 0; |
410 bottom_edge = kShelfSize - | 411 bottom_edge = kShelfSize - |
411 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 412 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
412 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 413 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
413 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 414 } else if (shelf_alignment() == wm::SHELF_ALIGNMENT_LEFT) { |
414 top_edge = 0; | 415 top_edge = 0; |
415 left_edge = kShelfSize - | 416 left_edge = kShelfSize - |
416 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 417 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
417 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 418 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
418 right_edge = ShelfLayoutManager::kShelfItemInset; | 419 right_edge = ShelfLayoutManager::kShelfItemInset; |
419 } else { // SHELF_ALIGNMENT_RIGHT | 420 } else { // SHELF_ALIGNMENT_RIGHT |
420 top_edge = 0; | 421 top_edge = 0; |
421 left_edge = ShelfLayoutManager::kShelfItemInset; | 422 left_edge = ShelfLayoutManager::kShelfItemInset; |
422 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 423 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
423 right_edge = kShelfSize - | 424 right_edge = kShelfSize - |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 kPaddingFromRightEdgeOfScreenBottomAlignment : | 553 kPaddingFromRightEdgeOfScreenBottomAlignment : |
553 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, | 554 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, |
554 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | 555 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, |
555 0, 0); | 556 0, 0); |
556 } | 557 } |
557 } | 558 } |
558 return rect; | 559 return rect; |
559 } | 560 } |
560 | 561 |
561 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 562 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
562 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) | 563 if (shelf_alignment_ == wm::SHELF_ALIGNMENT_LEFT) |
563 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 564 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
564 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT) | 565 if (shelf_alignment_ == wm::SHELF_ALIGNMENT_RIGHT) |
565 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 566 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
566 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 567 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
567 } | 568 } |
568 | 569 |
569 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 570 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
570 if (draw_background_as_active_ == visible) | 571 if (draw_background_as_active_ == visible) |
571 return; | 572 return; |
572 draw_background_as_active_ = visible; | 573 draw_background_as_active_ = visible; |
573 if (!background_) | 574 if (!background_) |
574 return; | 575 return; |
575 | 576 |
576 // Do not change gradually, changing color between grey and blue is weird. | 577 // Do not change gradually, changing color between grey and blue is weird. |
577 if (draw_background_as_active_) | 578 if (draw_background_as_active_) |
578 background_->set_color(kTrayBackgroundPressedColor); | 579 background_->set_color(kTrayBackgroundPressedColor); |
579 else if (hovered_) | 580 else if (hovered_) |
580 background_->set_alpha(kTrayBackgroundHoverAlpha); | 581 background_->set_alpha(kTrayBackgroundHoverAlpha); |
581 else | 582 else |
582 background_->set_alpha(kTrayBackgroundAlpha); | 583 background_->set_alpha(kTrayBackgroundAlpha); |
583 SchedulePaint(); | 584 SchedulePaint(); |
584 } | 585 } |
585 | 586 |
586 void TrayBackgroundView::UpdateBubbleViewArrow( | 587 void TrayBackgroundView::UpdateBubbleViewArrow( |
587 views::TrayBubbleView* bubble_view) { | 588 views::TrayBubbleView* bubble_view) { |
588 // Nothing to do here. | 589 // Nothing to do here. |
589 } | 590 } |
590 | 591 |
591 } // namespace ash | 592 } // namespace ash |
OLD | NEW |