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

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: merge 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"
11 #include "ash/common/shelf/wm_shelf_observer.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 12 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/system/tray/tray_constants.h" 14 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_utils.h" 15 #include "ash/common/system/tray/tray_utils.h"
15 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 16 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
16 #include "ash/common/wm/overview/window_selector_controller.h" 17 #include "ash/common/wm/overview/window_selector_controller.h"
17 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
18 #include "grit/ash_resources.h" 19 #include "grit/ash_resources.h"
19 #include "grit/ash_strings.h" 20 #include "grit/ash_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/paint_vector_icon.h" 23 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/gfx/vector_icons_public.h" 24 #include "ui/gfx/vector_icons_public.h"
24 #include "ui/views/border.h" 25 #include "ui/views/border.h"
25 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
26 27
27 namespace { 28 namespace {
28 29
29 // Predefined padding for the icon used in this tray. These are to be set to the 30 // 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() 31 // border of the icon, depending on the current shelf_alignment()
31 const int kHorizontalShelfHorizontalPadding = 8; 32 const int kHorizontalShelfHorizontalPadding = 8;
32 const int kHorizontalShelfVerticalPadding = 4; 33 const int kHorizontalShelfVerticalPadding = 4;
33 const int kVerticalShelfHorizontalPadding = 2; 34 const int kVerticalShelfHorizontalPadding = 2;
34 const int kVerticalShelfVerticalPadding = 5; 35 const int kVerticalShelfVerticalPadding = 5;
35 36
37 // Padding used to adjust the user-visible size of overview tray's dark
38 // background.
39 const int kBackgroundTrayPadding = 3;
40
36 } // namespace 41 } // namespace
37 42
38 namespace ash { 43 namespace ash {
39 44
40 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) 45 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf,
41 : TrayBackgroundView(wm_shelf), icon_(nullptr) { 46 WmShelfObserver* wm_shelf_observer)
47 : TrayBackgroundView(wm_shelf, wm_shelf_observer), icon_(nullptr) {
42 SetContentsBackground(); 48 SetContentsBackground();
49 SetOverviewTrayBorder();
43 50
44 icon_ = new views::ImageView(); 51 icon_ = new views::ImageView();
45 if (MaterialDesignController::IsShelfMaterial()) { 52 if (MaterialDesignController::IsShelfMaterial()) {
46 gfx::ImageSkia image_md = 53 gfx::ImageSkia image_md =
47 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor); 54 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERVIEW, kShelfIconColor);
48 icon_->SetImage(image_md); 55 icon_->SetImage(image_md);
49 } else { 56 } else {
50 gfx::ImageSkia* image_non_md = 57 gfx::ImageSkia* image_non_md =
51 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 58 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
52 IDR_AURA_UBER_TRAY_OVERVIEW_MODE); 59 IDR_AURA_UBER_TRAY_OVERVIEW_MODE);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void OverviewButtonTray::HideBubbleWithView( 110 void OverviewButtonTray::HideBubbleWithView(
104 const views::TrayBubbleView* bubble_view) { 111 const views::TrayBubbleView* bubble_view) {
105 // This class has no bubbles to hide. 112 // This class has no bubbles to hide.
106 } 113 }
107 114
108 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) { 115 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
109 if (alignment == shelf_alignment()) 116 if (alignment == shelf_alignment())
110 return; 117 return;
111 118
112 TrayBackgroundView::SetShelfAlignment(alignment); 119 TrayBackgroundView::SetShelfAlignment(alignment);
113 SetIconBorderForShelfAlignment(); 120 if (!ash::MaterialDesignController::IsShelfMaterial()) {
121 SetOverviewTrayBorder();
122 SetIconBorderForShelfAlignment();
123 }
114 } 124 }
115 125
116 void OverviewButtonTray::SetIconBorderForShelfAlignment() { 126 void OverviewButtonTray::SetIconBorderForShelfAlignment() {
117 if (ash::MaterialDesignController::IsShelfMaterial()) { 127 if (ash::MaterialDesignController::IsShelfMaterial()) {
118 // Pad button size to align with other controls in the system tray. 128 // Pad button size to align with other controls in the system tray.
119 const gfx::ImageSkia image = icon_->GetImage(); 129 const gfx::ImageSkia image = icon_->GetImage();
120 const int vertical_padding = (kTrayItemSize - image.height()) / 2; 130 const int vertical_padding = (kTrayItemSize - image.height()) / 2;
121 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; 131 const int horizontal_padding = (kTrayItemSize - image.width()) / 2;
122 icon_->SetBorder(views::Border::CreateEmptyBorder( 132 icon_->SetBorder(views::Border::CreateEmptyBorder(
123 gfx::Insets(vertical_padding, horizontal_padding))); 133 gfx::Insets(vertical_padding, horizontal_padding)));
124 } else { 134 } else {
125 if (IsHorizontalAlignment(shelf_alignment())) { 135 if (IsHorizontalAlignment(shelf_alignment())) {
126 icon_->SetBorder(views::Border::CreateEmptyBorder( 136 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
127 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding, 137 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)));
128 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding));
129 } else { 138 } else {
130 icon_->SetBorder(views::Border::CreateEmptyBorder( 139 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
131 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding, 140 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)));
132 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding));
133 } 141 }
134 } 142 }
135 } 143 }
136 144
145 void OverviewButtonTray::SetOverviewTrayBorder() {
146 if (!ash::MaterialDesignController::IsShelfMaterial()) {
147 tray_container()->SetBorder(
148 views::Border::CreateEmptyBorder(gfx::Insets(kBackgroundTrayPadding)));
149 }
150 }
151
137 void OverviewButtonTray::UpdateIconVisibility() { 152 void OverviewButtonTray::UpdateIconVisibility() {
138 // The visibility of the OverviewButtonTray has diverge from 153 // The visibility of the OverviewButtonTray has diverge from
139 // WindowSelectorController::CanSelect. The visibility of the button should 154 // WindowSelectorController::CanSelect. The visibility of the button should
140 // not change during transient times in which CanSelect is false. Such as when 155 // not change during transient times in which CanSelect is false. Such as when
141 // a modal dialog is present. 156 // a modal dialog is present.
142 WmShell* shell = WmShell::Get(); 157 WmShell* shell = WmShell::Get();
143 SessionStateDelegate* session_state_delegate = 158 SessionStateDelegate* session_state_delegate =
144 shell->GetSessionStateDelegate(); 159 shell->GetSessionStateDelegate();
145
146 SetVisible( 160 SetVisible(
147 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && 161 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
148 session_state_delegate->IsActiveUserSessionStarted() && 162 session_state_delegate->IsActiveUserSessionStarted() &&
149 !session_state_delegate->IsScreenLocked() && 163 !session_state_delegate->IsScreenLocked() &&
150 session_state_delegate->GetSessionState() == 164 session_state_delegate->GetSessionState() ==
151 SessionStateDelegate::SESSION_STATE_ACTIVE && 165 SessionStateDelegate::SESSION_STATE_ACTIVE &&
152 shell->system_tray_delegate()->GetUserLoginStatus() != 166 shell->system_tray_delegate()->GetUserLoginStatus() !=
153 LoginStatus::KIOSK_APP); 167 LoginStatus::KIOSK_APP);
154 } 168 }
155 169
156 } // namespace ash 170 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698