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

Side by Side Diff: ash/system/chromeos/rotation/tray_rotation_lock.cc

Issue 2365523002: Materialized the font/icon color for some default rows in the system menu. (Closed)
Patch Set: Applied TrayPopupItemStyle to Network, SMS, Tracing, OS Update. Created 4 years, 3 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/system/chromeos/rotation/tray_rotation_lock.h" 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.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/system/tray/system_tray.h" 8 #include "ash/common/system/tray/system_tray.h"
9 #include "ash/common/system/tray/tray_constants.h" 9 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_item_more.h" 10 #include "ash/common/system/tray/tray_item_more.h"
11 #include "ash/common/system/tray/tray_popup_item_style.h"
11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
12 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
13 #include "ash/display/screen_orientation_controller_chromeos.h" 14 #include "ash/display/screen_orientation_controller_chromeos.h"
14 #include "ash/resources/vector_icons/vector_icons.h" 15 #include "ash/resources/vector_icons/vector_icons.h"
15 #include "ash/shell.h" 16 #include "ash/shell.h"
16 #include "grit/ash_resources.h" 17 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/display/display.h" 21 #include "ui/display/display.h"
(...skipping 12 matching lines...) Expand all
33 explicit RotationLockDefaultView(SystemTrayItem* owner); 34 explicit RotationLockDefaultView(SystemTrayItem* owner);
34 ~RotationLockDefaultView() override; 35 ~RotationLockDefaultView() override;
35 36
36 // ActionableView: 37 // ActionableView:
37 bool PerformAction(const ui::Event& event) override; 38 bool PerformAction(const ui::Event& event) override;
38 39
39 // ShellObserver: 40 // ShellObserver:
40 void OnMaximizeModeStarted() override; 41 void OnMaximizeModeStarted() override;
41 void OnMaximizeModeEnded() override; 42 void OnMaximizeModeEnded() override;
42 43
44 protected:
45 // TrayItemMore:
46 std::unique_ptr<TrayPopupItemStyle> CreateStyle() const override;
47 void UpdateStyle() override;
48
43 private: 49 private:
44 void UpdateImage(); 50 void UpdateImage();
45 51
46 DISALLOW_COPY_AND_ASSIGN(RotationLockDefaultView); 52 DISALLOW_COPY_AND_ASSIGN(RotationLockDefaultView);
47 }; 53 };
48 54
49 RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner) 55 RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner)
50 : TrayItemMore(owner, false) { 56 : TrayItemMore(owner, false) {
51 UpdateImage();
52 SetVisible(WmShell::Get() 57 SetVisible(WmShell::Get()
53 ->maximize_mode_controller() 58 ->maximize_mode_controller()
54 ->IsMaximizeModeWindowManagerEnabled()); 59 ->IsMaximizeModeWindowManagerEnabled());
55 WmShell::Get()->AddShellObserver(this); 60 WmShell::Get()->AddShellObserver(this);
56 } 61 }
57 62
58 RotationLockDefaultView::~RotationLockDefaultView() { 63 RotationLockDefaultView::~RotationLockDefaultView() {
59 WmShell::Get()->RemoveShellObserver(this); 64 WmShell::Get()->RemoveShellObserver(this);
60 } 65 }
61 66
62 bool RotationLockDefaultView::PerformAction(const ui::Event& event) { 67 bool RotationLockDefaultView::PerformAction(const ui::Event& event) {
63 ScreenOrientationController* screen_orientation_controller = 68 ScreenOrientationController* screen_orientation_controller =
64 Shell::GetInstance()->screen_orientation_controller(); 69 Shell::GetInstance()->screen_orientation_controller();
65 screen_orientation_controller->SetRotationLocked( 70 screen_orientation_controller->SetRotationLocked(
66 !screen_orientation_controller->rotation_locked()); 71 !screen_orientation_controller->rotation_locked());
67 UpdateImage(); 72 UpdateImage();
68 return true; 73 return true;
69 } 74 }
70 75
71 void RotationLockDefaultView::OnMaximizeModeStarted() { 76 void RotationLockDefaultView::OnMaximizeModeStarted() {
72 UpdateImage(); 77 UpdateImage();
73 SetVisible(true); 78 SetVisible(true);
74 } 79 }
75 80
76 void RotationLockDefaultView::OnMaximizeModeEnded() { 81 void RotationLockDefaultView::OnMaximizeModeEnded() {
77 SetVisible(false); 82 SetVisible(false);
78 } 83 }
79 84
85 std::unique_ptr<TrayPopupItemStyle> RotationLockDefaultView::CreateStyle()
86 const {
87 return base::MakeUnique<TrayPopupItemStyle>(
88 GetNativeTheme(), TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
89 }
90
91 void RotationLockDefaultView::UpdateStyle() {
92 TrayItemMore::UpdateStyle();
93 UpdateImage();
94 }
95
80 void RotationLockDefaultView::UpdateImage() { 96 void RotationLockDefaultView::UpdateImage() {
81 const bool rotation_locked = 97 const bool rotation_locked =
82 Shell::GetInstance()->screen_orientation_controller()->rotation_locked(); 98 Shell::GetInstance()->screen_orientation_controller()->rotation_locked();
83 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 99 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
100 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
84 SetImage(gfx::CreateVectorIcon(rotation_locked 101 SetImage(gfx::CreateVectorIcon(rotation_locked
85 ? kSystemMenuRotationLockLockedIcon 102 ? kSystemMenuRotationLockLockedIcon
86 : kSystemMenuRotationLockAutoIcon, 103 : kSystemMenuRotationLockAutoIcon,
87 kMenuIconSize, kMenuIconColor)); 104 kMenuIconSize, style->GetForegroundColor()));
88 } else { 105 } else {
89 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 106 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
90 const int resource_id = rotation_locked 107 const int resource_id = rotation_locked
91 ? IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED_DARK 108 ? IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED_DARK
92 : IDR_AURA_UBER_TRAY_AUTO_ROTATION_DARK; 109 : IDR_AURA_UBER_TRAY_AUTO_ROTATION_DARK;
93 SetImage(*bundle.GetImageNamed(resource_id).ToImageSkia()); 110 SetImage(*bundle.GetImageNamed(resource_id).ToImageSkia());
94 } 111 }
95 112
96 base::string16 label = l10n_util::GetStringUTF16( 113 base::string16 label = l10n_util::GetStringUTF16(
97 rotation_locked ? IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED 114 rotation_locked ? IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 192 }
176 193
177 void TrayRotationLock::StopObservingShell() { 194 void TrayRotationLock::StopObservingShell() {
178 if (!observing_shell_) 195 if (!observing_shell_)
179 return; 196 return;
180 WmShell::Get()->RemoveShellObserver(this); 197 WmShell::Get()->RemoveShellObserver(this);
181 observing_shell_ = false; 198 observing_shell_ = false;
182 } 199 }
183 200
184 } // namespace ash 201 } // namespace ash
OLDNEW
« ash/common/system/tray/tray_popup_item_style.h ('K') | « ash/common/system/update/tray_update.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698