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

Side by Side Diff: ash/common/system/overview/overview_button_tray.cc

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 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
OLDNEW
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
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 tray's dark
37 // background.
38 const int kBackgroundTrayPadding = 3;
39
36 } // namespace 40 } // namespace
37 41
38 namespace ash { 42 namespace ash {
39 43
40 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) 44 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf)
41 : TrayBackgroundView(wm_shelf), icon_(nullptr) { 45 : TrayBackgroundView(wm_shelf), icon_(nullptr) {
42 SetContentsBackground(); 46 SetContentsBackground();
47 SetOverviewTrayBorder();
43 48
44 icon_ = new views::ImageView(); 49 icon_ = new views::ImageView();
45 if (MaterialDesignController::IsShelfMaterial()) { 50 if (MaterialDesignController::IsShelfMaterial()) {
46 gfx::ImageSkia image_md = 51 gfx::ImageSkia image_md =
47 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); 52 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor);
48 icon_->SetImage(image_md); 53 icon_->SetImage(image_md);
49 } else { 54 } else {
50 gfx::ImageSkia* image_non_md = 55 gfx::ImageSkia* image_non_md =
51 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 56 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
52 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); 57 IDR_AURA_UBER_TRAY_OVERVIEW_MODE);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void OverviewButtonTray::HideBubbleWithView( 108 void OverviewButtonTray::HideBubbleWithView(
104 const views::TrayBubbleView* bubble_view) { 109 const views::TrayBubbleView* bubble_view) {
105 // This class has no bubbles to hide. 110 // This class has no bubbles to hide.
106 } 111 }
107 112
108 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { 113 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
109 if (alignment == shelf_alignment()) 114 if (alignment == shelf_alignment())
110 return; 115 return;
111 116
112 TrayBackgroundView::SetShelfAlignment(alignment); 117 TrayBackgroundView::SetShelfAlignment(alignment);
113 SetIconBorderForShelfAlignment(); 118 if (!ash::MaterialDesignController::IsShelfMaterial()) {
119 SetOverviewTrayBorder();
120 SetIconBorderForShelfAlignment();
121 }
114 } 122 }
115 123
116 void OverviewButtonTray::SetIconBorderForShelfAlignment() { 124 void OverviewButtonTray::SetIconBorderForShelfAlignment() {
117 if (ash::MaterialDesignController::IsShelfMaterial()) { 125 if (ash::MaterialDesignController::IsShelfMaterial()) {
118 // Pad button size to align with other controls in the system tray. 126 // Pad button size to align with other controls in the system tray.
119 const gfx::ImageSkia image = icon_->GetImage(); 127 const gfx::ImageSkia image = icon_->GetImage();
120 const int vertical_padding = (kTrayItemSize - image.height()) / 2; 128 const int vertical_padding = (kTrayItemSize - image.height()) / 2;
121 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; 129 const int horizontal_padding = (kTrayItemSize - image.width()) / 2;
122 icon_->SetBorder(views::Border::CreateEmptyBorder( 130 icon_->SetBorder(views::Border::CreateEmptyBorder(
123 gfx::Insets(vertical_padding, horizontal_padding))); 131 gfx::Insets(vertical_padding, horizontal_padding)));
124 } else { 132 } else {
125 if (IsHorizontalAlignment(shelf_alignment())) { 133 if (IsHorizontalAlignment(shelf_alignment())) {
126 icon_->SetBorder(views::Border::CreateEmptyBorder( 134 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
127 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, 135 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)));
128 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding));
129 } else { 136 } else {
130 icon_->SetBorder(views::Border::CreateEmptyBorder( 137 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
131 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, 138 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)));
132 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding));
133 } 139 }
134 } 140 }
135 } 141 }
136 142
143 void OverviewButtonTray::SetOverviewTrayBorder() {
144 if (!ash::MaterialDesignController::IsShelfMaterial()) {
145 tray_container()->SetBorder(
146 views::Border::CreateEmptyBorder(gfx::Insets(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
146 SetVisible( 158 SetVisible(
147 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && 159 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
148 session_state_delegate->IsActiveUserSessionStarted() && 160 session_state_delegate->IsActiveUserSessionStarted() &&
149 !session_state_delegate->IsScreenLocked() && 161 !session_state_delegate->IsScreenLocked() &&
150 session_state_delegate->GetSessionState() == 162 session_state_delegate->GetSessionState() ==
151 SessionStateDelegate::SESSION_STATE_ACTIVE && 163 SessionStateDelegate::SESSION_STATE_ACTIVE &&
152 shell->system_tray_delegate()->GetUserLoginStatus() != 164 shell->system_tray_delegate()->GetUserLoginStatus() !=
153 LoginStatus::KIOSK_APP); 165 LoginStatus::KIOSK_APP);
154 } 166 }
155 167
156 } // namespace ash 168 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698