| 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_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; | 64 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; |
| 65 | 65 |
| 66 // Used to track when the anchor widget changes position on screen so that the | 66 // Used to track when the anchor widget changes position on screen so that the |
| 67 // bubble position can be updated. | 67 // bubble position can be updated. |
| 68 class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver { | 68 class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver { |
| 69 public: | 69 public: |
| 70 explicit TrayWidgetObserver(TrayBackgroundView* host) | 70 explicit TrayWidgetObserver(TrayBackgroundView* host) |
| 71 : host_(host) { | 71 : host_(host) { |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void OnWidgetBoundsChanged(views::Widget* widget, | 74 void OnWidgetBoundsChanged(views::Widget* widget, |
| 75 const gfx::Rect& new_bounds) override { | 75 const gfx::Rect& new_bounds) override { |
| 76 host_->AnchorUpdated(); | 76 host_->AnchorUpdated(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | 79 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override { |
| 80 bool visible) override { | |
| 81 host_->AnchorUpdated(); | 80 host_->AnchorUpdated(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 TrayBackgroundView* host_; | 84 TrayBackgroundView* host_; |
| 86 | 85 |
| 87 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); | 86 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 class TrayBackground : public views::Background { | 89 class TrayBackground : public views::Background { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 leading_images_[kImageVertical][kImageTypePressed] = | 142 leading_images_[kImageVertical][kImageTypePressed] = |
| 144 rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_PRESSED).ToImageSkia(); | 143 rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_PRESSED).ToImageSkia(); |
| 145 middle_images_[kImageVertical][kImageTypePressed] = | 144 middle_images_[kImageVertical][kImageTypePressed] = |
| 146 rb.GetImageNamed( | 145 rb.GetImageNamed( |
| 147 IDR_AURA_TRAY_BG_VERTICAL_CENTER_PRESSED).ToImageSkia(); | 146 IDR_AURA_TRAY_BG_VERTICAL_CENTER_PRESSED).ToImageSkia(); |
| 148 trailing_images_[kImageVertical][kImageTypePressed] = | 147 trailing_images_[kImageVertical][kImageTypePressed] = |
| 149 rb.GetImageNamed( | 148 rb.GetImageNamed( |
| 150 IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_PRESSED).ToImageSkia(); | 149 IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_PRESSED).ToImageSkia(); |
| 151 } | 150 } |
| 152 | 151 |
| 153 virtual ~TrayBackground() {} | 152 ~TrayBackground() override {} |
| 154 | 153 |
| 155 SkColor color() { return color_; } | 154 SkColor color() { return color_; } |
| 156 void set_color(SkColor color) { color_ = color; } | 155 void set_color(SkColor color) { color_ = color; } |
| 157 void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); } | 156 void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); } |
| 158 | 157 |
| 159 private: | 158 private: |
| 160 ShelfWidget* GetShelfWidget() const { | 159 ShelfWidget* GetShelfWidget() const { |
| 161 return RootWindowController::ForWindow(tray_background_view_-> | 160 return RootWindowController::ForWindow(tray_background_view_-> |
| 162 status_area_widget()->GetNativeWindow())->shelf(); | 161 status_area_widget()->GetNativeWindow())->shelf(); |
| 163 } | 162 } |
| 164 | 163 |
| 165 // Overridden from views::Background. | 164 // Overridden from views::Background. |
| 166 virtual void Paint(gfx::Canvas* canvas, views::View* view) const override { | 165 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 167 int orientation = kImageHorizontal; | 166 int orientation = kImageHorizontal; |
| 168 ShelfWidget* shelf_widget = GetShelfWidget(); | 167 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 169 if (shelf_widget && | 168 if (shelf_widget && |
| 170 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) | 169 !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) |
| 171 orientation = kImageVertical; | 170 orientation = kImageVertical; |
| 172 | 171 |
| 173 int state = kImageTypeDefault; | 172 int state = kImageTypeDefault; |
| 174 if (tray_background_view_->draw_background_as_active()) | 173 if (tray_background_view_->draw_background_as_active()) |
| 175 state = kImageTypePressed; | 174 state = kImageTypePressed; |
| 176 else if (shelf_widget && shelf_widget->GetDimsShelf()) | 175 else if (shelf_widget && shelf_widget->GetDimsShelf()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 background_->set_alpha(kTrayBackgroundAlpha); | 656 background_->set_alpha(kTrayBackgroundAlpha); |
| 658 SchedulePaint(); | 657 SchedulePaint(); |
| 659 } | 658 } |
| 660 | 659 |
| 661 void TrayBackgroundView::UpdateBubbleViewArrow( | 660 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 662 views::TrayBubbleView* bubble_view) { | 661 views::TrayBubbleView* bubble_view) { |
| 663 // Nothing to do here. | 662 // Nothing to do here. |
| 664 } | 663 } |
| 665 | 664 |
| 666 } // namespace ash | 665 } // namespace ash |
| OLD | NEW |