Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overview/overview_button_tray.h" | 5 #include "ash/common/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/shelf_types.h" | 10 #include "ash/common/shelf/shelf_types.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // Predefined padding for the icon used in this tray. These are to be set to the | 29 // Predefined padding for the icon used in this tray. These are to be set to the |
| 30 // border of the icon, depending on the current shelf_alignment() | 30 // border of the icon, depending on the current shelf_alignment() |
| 31 const int kHorizontalShelfHorizontalPadding = 8; | 31 const int kHorizontalShelfHorizontalPadding = 8; |
| 32 const int kHorizontalShelfVerticalPadding = 4; | 32 const int kHorizontalShelfVerticalPadding = 4; |
| 33 const int kVerticalShelfHorizontalPadding = 2; | 33 const int kVerticalShelfHorizontalPadding = 2; |
| 34 const int kVerticalShelfVerticalPadding = 5; | 34 const int kVerticalShelfVerticalPadding = 5; |
| 35 | 35 |
| 36 // Padding used to adjust the user-visible size of overview dark background. | |
|
varkha
2016/07/14 21:34:47
nit: s/overview/overview tray
yiyix
2016/07/26 20:27:30
Done.
| |
| 37 const int kBackgroundTrayPadding = 3; | |
| 38 | |
| 36 } // namespace | 39 } // namespace |
| 37 | 40 |
| 38 namespace ash { | 41 namespace ash { |
| 39 | 42 |
| 40 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) | 43 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) |
| 41 : TrayBackgroundView(wm_shelf), icon_(nullptr) { | 44 : TrayBackgroundView(wm_shelf), icon_(nullptr) { |
| 42 SetContentsBackground(); | 45 SetContentsBackground(); |
| 46 AdjustOverviewBackground(); | |
| 43 | 47 |
| 44 icon_ = new views::ImageView(); | 48 icon_ = new views::ImageView(); |
| 45 if (MaterialDesignController::IsShelfMaterial()) { | 49 if (MaterialDesignController::IsShelfMaterial()) { |
| 46 gfx::ImageSkia image_md = | 50 gfx::ImageSkia image_md = |
| 47 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); | 51 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); |
| 48 icon_->SetImage(image_md); | 52 icon_->SetImage(image_md); |
| 49 } else { | 53 } else { |
| 50 gfx::ImageSkia* image_non_md = | 54 gfx::ImageSkia* image_non_md = |
| 51 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 55 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 52 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); | 56 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 void OverviewButtonTray::HideBubbleWithView( | 107 void OverviewButtonTray::HideBubbleWithView( |
| 104 const views::TrayBubbleView* bubble_view) { | 108 const views::TrayBubbleView* bubble_view) { |
| 105 // This class has no bubbles to hide. | 109 // This class has no bubbles to hide. |
| 106 } | 110 } |
| 107 | 111 |
| 108 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | 112 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 109 if (alignment == shelf_alignment()) | 113 if (alignment == shelf_alignment()) |
| 110 return; | 114 return; |
| 111 | 115 |
| 112 TrayBackgroundView::SetShelfAlignment(alignment); | 116 TrayBackgroundView::SetShelfAlignment(alignment); |
| 117 AdjustOverviewBackground(); | |
|
varkha
2016/07/14 21:34:47
Do you need to call those 2 methods that create bo
yiyix
2016/07/26 20:27:30
true, I will add a condition. thanks
| |
| 113 SetIconBorderForShelfAlignment(); | 118 SetIconBorderForShelfAlignment(); |
| 114 } | 119 } |
| 115 | 120 |
| 116 void OverviewButtonTray::SetIconBorderForShelfAlignment() { | 121 void OverviewButtonTray::SetIconBorderForShelfAlignment() { |
| 117 if (ash::MaterialDesignController::IsShelfMaterial()) { | 122 if (ash::MaterialDesignController::IsShelfMaterial()) { |
| 118 // Pad button size to align with other controls in the system tray. | 123 // Pad button size to align with other controls in the system tray. |
| 119 const gfx::ImageSkia image = icon_->GetImage(); | 124 const gfx::ImageSkia image = icon_->GetImage(); |
| 120 const int vertical_padding = (kTrayItemSize - image.height()) / 2; | 125 const int vertical_padding = (kTrayItemSize - image.height()) / 2; |
| 121 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; | 126 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; |
| 122 icon_->SetBorder(views::Border::CreateEmptyBorder( | 127 icon_->SetBorder(views::Border::CreateEmptyBorder( |
| 123 gfx::Insets(vertical_padding, horizontal_padding))); | 128 gfx::Insets(vertical_padding, horizontal_padding))); |
| 124 } else { | 129 } else { |
| 125 if (IsHorizontalAlignment(shelf_alignment())) { | 130 if (IsHorizontalAlignment(shelf_alignment())) { |
| 126 icon_->SetBorder(views::Border::CreateEmptyBorder( | 131 icon_->SetBorder(views::Border::CreateEmptyBorder( |
| 127 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, | 132 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, |
| 128 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)); | 133 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)); |
| 129 } else { | 134 } else { |
| 130 icon_->SetBorder(views::Border::CreateEmptyBorder( | 135 icon_->SetBorder(views::Border::CreateEmptyBorder( |
| 131 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, | 136 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, |
| 132 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)); | 137 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)); |
| 133 } | 138 } |
| 134 } | 139 } |
| 135 } | 140 } |
| 136 | 141 |
| 142 void OverviewButtonTray::AdjustOverviewBackground() { | |
| 143 if (!ash::MaterialDesignController::IsShelfMaterial()) { | |
| 144 tray_container()->SetBorder(views::Border::CreateEmptyBorder( | |
|
varkha
2016/07/14 21:34:47
nit: simpler to use gfx::Insets(kBackgroundTrayPad
yiyix
2016/07/26 20:27:30
Done.
| |
| 145 kBackgroundTrayPadding, kBackgroundTrayPadding, kBackgroundTrayPadding, | |
| 146 kBackgroundTrayPadding)); | |
| 147 } | |
| 148 } | |
| 149 | |
| 137 void OverviewButtonTray::UpdateIconVisibility() { | 150 void OverviewButtonTray::UpdateIconVisibility() { |
| 138 // The visibility of the OverviewButtonTray has diverge from | 151 // The visibility of the OverviewButtonTray has diverge from |
| 139 // WindowSelectorController::CanSelect. The visibility of the button should | 152 // WindowSelectorController::CanSelect. The visibility of the button should |
| 140 // not change during transient times in which CanSelect is false. Such as when | 153 // not change during transient times in which CanSelect is false. Such as when |
| 141 // a modal dialog is present. | 154 // a modal dialog is present. |
| 142 WmShell* shell = WmShell::Get(); | 155 WmShell* shell = WmShell::Get(); |
| 143 SessionStateDelegate* session_state_delegate = | 156 SessionStateDelegate* session_state_delegate = |
| 144 shell->GetSessionStateDelegate(); | 157 shell->GetSessionStateDelegate(); |
| 145 | 158 |
| 146 SetVisible( | 159 SetVisible( |
| 147 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && | 160 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
| 148 session_state_delegate->IsActiveUserSessionStarted() && | 161 session_state_delegate->IsActiveUserSessionStarted() && |
| 149 !session_state_delegate->IsScreenLocked() && | 162 !session_state_delegate->IsScreenLocked() && |
| 150 session_state_delegate->GetSessionState() == | 163 session_state_delegate->GetSessionState() == |
| 151 SessionStateDelegate::SESSION_STATE_ACTIVE && | 164 SessionStateDelegate::SESSION_STATE_ACTIVE && |
| 152 shell->system_tray_delegate()->GetUserLoginStatus() != | 165 shell->system_tray_delegate()->GetUserLoginStatus() != |
| 153 LoginStatus::KIOSK_APP); | 166 LoginStatus::KIOSK_APP); |
| 154 } | 167 } |
| 155 | 168 |
| 156 } // namespace ash | 169 } // namespace ash |
| OLD | NEW |