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

Side by Side Diff: ash/common/system/chromeos/brightness/tray_brightness.cc

Issue 2329333002: [Chrome OS MD] Enable the brightness row to be visible at all times (Closed)
Patch Set: address comments 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
« no previous file with comments | « no previous file | ash/common/system/chromeos/brightness/tray_brightness_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/brightness/tray_brightness.h" 5 #include "ash/common/system/chromeos/brightness/tray_brightness.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/ash_constants.h" 9 #include "ash/common/ash_constants.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 29 matching lines...) Expand all
40 namespace { 40 namespace {
41 41
42 // We don't let the screen brightness go lower than this when it's being 42 // We don't let the screen brightness go lower than this when it's being
43 // adjusted via the slider. Otherwise, if the user doesn't know about the 43 // adjusted via the slider. Otherwise, if the user doesn't know about the
44 // brightness keys, they may turn the backlight off and not know how to turn it 44 // brightness keys, they may turn the backlight off and not know how to turn it
45 // back on. 45 // back on.
46 const double kMinBrightnessPercent = 5.0; 46 const double kMinBrightnessPercent = 5.0;
47 47
48 } // namespace 48 } // namespace
49 49
50 // TODO(yiyix|tdanderson): Once Chrome OS material design is enabled by default,
51 // BrightnessView does not need to be a ShellObserver to observe touch view mode
52 // changes. See crbug.com/614453.
50 class BrightnessView : public ShellObserver, 53 class BrightnessView : public ShellObserver,
51 public views::View, 54 public views::View,
52 public views::SliderListener { 55 public views::SliderListener {
53 public: 56 public:
54 BrightnessView(bool default_view, double initial_percent); 57 BrightnessView(bool default_view, double initial_percent);
55 ~BrightnessView() override; 58 ~BrightnessView() override;
56 59
57 bool is_default_view() const { return is_default_view_; } 60 bool is_default_view() const { return is_default_view_; }
58 61
59 // |percent| is in the range [0.0, 100.0]. 62 // |percent| is in the range [0.0, 100.0].
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { 119 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) {
117 slider_->SetBorder(views::Border::CreateEmptyBorder( 120 slider_->SetBorder(views::Border::CreateEmptyBorder(
118 gfx::Insets(0, kTrayPopupSliderPaddingMD) + slider_->GetInsets())); 121 gfx::Insets(0, kTrayPopupSliderPaddingMD) + slider_->GetInsets()));
119 } 122 }
120 slider_->set_focus_border_color(kFocusBorderColor); 123 slider_->set_focus_border_color(kFocusBorderColor);
121 slider_->SetValue(static_cast<float>(initial_percent / 100.0)); 124 slider_->SetValue(static_cast<float>(initial_percent / 100.0));
122 slider_->SetAccessibleName( 125 slider_->SetAccessibleName(
123 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS)); 126 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS));
124 AddChildView(slider_); 127 AddChildView(slider_);
125 128
126 if (is_default_view_) { 129 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
127 WmShell::Get()->AddShellObserver(this); 130 SetVisible(true);
128 SetVisible(WmShell::Get() 131 } else {
129 ->maximize_mode_controller() 132 if (is_default_view_) {
130 ->IsMaximizeModeWindowManagerEnabled()); 133 WmShell::Get()->AddShellObserver(this);
134 SetVisible(WmShell::Get()
135 ->maximize_mode_controller()
136 ->IsMaximizeModeWindowManagerEnabled());
137 }
131 } 138 }
132 } 139 }
133 140
134 BrightnessView::~BrightnessView() { 141 BrightnessView::~BrightnessView() {
135 if (is_default_view_) 142 if (is_default_view_)
136 WmShell::Get()->RemoveShellObserver(this); 143 WmShell::Get()->RemoveShellObserver(this);
137 } 144 }
138 145
139 void BrightnessView::SetBrightnessPercent(double percent) { 146 void BrightnessView::SetBrightnessPercent(double percent) {
140 last_percent_ = percent; 147 last_percent_ = percent;
141 if (!dragging_) 148 if (!dragging_)
142 slider_->SetValue(static_cast<float>(percent / 100.0)); 149 slider_->SetValue(static_cast<float>(percent / 100.0));
143 } 150 }
144 151
145 void BrightnessView::OnMaximizeModeStarted() { 152 void BrightnessView::OnMaximizeModeStarted() {
146 SetVisible(true); 153 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
154 SetVisible(true);
147 } 155 }
148 156
149 void BrightnessView::OnMaximizeModeEnded() { 157 void BrightnessView::OnMaximizeModeEnded() {
150 SetVisible(false); 158 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
159 SetVisible(false);
151 } 160 }
152 161
153 void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) { 162 void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) {
154 int w = width() - slider_->x(); 163 int w = width() - slider_->x();
155 slider_->SetSize(gfx::Size(w, slider_->height())); 164 slider_->SetSize(gfx::Size(w, slider_->height()));
156 } 165 }
157 166
158 void BrightnessView::SliderValueChanged(views::Slider* sender, 167 void BrightnessView::SliderValueChanged(views::Slider* sender,
159 float value, 168 float value,
160 float old_value, 169 float old_value,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (!display::Display::HasInternalDisplay()) 291 if (!display::Display::HasInternalDisplay())
283 return; 292 return;
284 293
285 if (brightness_view_) 294 if (brightness_view_)
286 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); 295 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds);
287 else 296 else
288 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); 297 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
289 } 298 }
290 299
291 } // namespace ash 300 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/chromeos/brightness/tray_brightness_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698