OLD | NEW |
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/system/brightness/tray_brightness.h" | 5 #include "ash/system/brightness/tray_brightness.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/resources/grit/ash_resources.h" | 9 #include "ash/resources/grit/ash_resources.h" |
10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_observer.h" | 12 #include "ash/shell_observer.h" |
13 #include "ash/shell_port.h" | 13 #include "ash/shell_port.h" |
14 #include "ash/strings/grit/ash_strings.h" | 14 #include "ash/strings/grit/ash_strings.h" |
15 #include "ash/system/brightness_control_delegate.h" | 15 #include "ash/system/brightness_control_delegate.h" |
16 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
17 #include "ash/system/tray/tray_popup_utils.h" | 17 #include "ash/system/tray/tray_popup_utils.h" |
18 #include "ash/system/tray/tri_view.h" | 18 #include "ash/system/tray/tri_view.h" |
19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 19 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
20 #include "base/bind.h" | 20 #include "base/bind.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
23 #include "chromeos/dbus/dbus_thread_manager.h" | 23 #include "chromeos/dbus/dbus_thread_manager.h" |
24 #include "chromeos/dbus/power_manager_client.h" | 24 #include "chromeos/dbus/power_manager_client.h" |
25 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
27 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
28 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
29 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
(...skipping 20 matching lines...) Expand all Loading... |
50 public: | 50 public: |
51 BrightnessView(bool default_view, double initial_percent); | 51 BrightnessView(bool default_view, double initial_percent); |
52 ~BrightnessView() override; | 52 ~BrightnessView() override; |
53 | 53 |
54 bool is_default_view() const { return is_default_view_; } | 54 bool is_default_view() const { return is_default_view_; } |
55 | 55 |
56 // |percent| is in the range [0.0, 100.0]. | 56 // |percent| is in the range [0.0, 100.0]. |
57 void SetBrightnessPercent(double percent); | 57 void SetBrightnessPercent(double percent); |
58 | 58 |
59 // ShellObserver: | 59 // ShellObserver: |
60 void OnMaximizeModeStarted() override; | 60 void OnTabletModeStarted() override; |
61 void OnMaximizeModeEnded() override; | 61 void OnTabletModeEnded() override; |
62 | 62 |
63 private: | 63 private: |
64 // views::View: | 64 // views::View: |
65 void OnBoundsChanged(const gfx::Rect& old_bounds) override; | 65 void OnBoundsChanged(const gfx::Rect& old_bounds) override; |
66 | 66 |
67 // views:SliderListener: | 67 // views:SliderListener: |
68 void SliderValueChanged(views::Slider* sender, | 68 void SliderValueChanged(views::Slider* sender, |
69 float value, | 69 float value, |
70 float old_value, | 70 float old_value, |
71 views::SliderChangeReason reason) override; | 71 views::SliderChangeReason reason) override; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 slider_ = TrayPopupUtils::CreateSlider(this); | 109 slider_ = TrayPopupUtils::CreateSlider(this); |
110 slider_->SetValue(static_cast<float>(initial_percent / 100.0)); | 110 slider_->SetValue(static_cast<float>(initial_percent / 100.0)); |
111 slider_->SetAccessibleName( | 111 slider_->SetAccessibleName( |
112 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS)); | 112 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS)); |
113 tri_view->AddView(TriView::Container::CENTER, slider_); | 113 tri_view->AddView(TriView::Container::CENTER, slider_); |
114 | 114 |
115 if (is_default_view_) { | 115 if (is_default_view_) { |
116 Shell::Get()->AddShellObserver(this); | 116 Shell::Get()->AddShellObserver(this); |
117 SetVisible(Shell::Get() | 117 SetVisible(Shell::Get() |
118 ->maximize_mode_controller() | 118 ->tablet_mode_controller() |
119 ->IsMaximizeModeWindowManagerEnabled()); | 119 ->IsTabletModeWindowManagerEnabled()); |
120 } | 120 } |
121 tri_view->SetContainerVisible(TriView::Container::END, false); | 121 tri_view->SetContainerVisible(TriView::Container::END, false); |
122 } | 122 } |
123 | 123 |
124 BrightnessView::~BrightnessView() { | 124 BrightnessView::~BrightnessView() { |
125 if (is_default_view_) | 125 if (is_default_view_) |
126 Shell::Get()->RemoveShellObserver(this); | 126 Shell::Get()->RemoveShellObserver(this); |
127 } | 127 } |
128 | 128 |
129 void BrightnessView::SetBrightnessPercent(double percent) { | 129 void BrightnessView::SetBrightnessPercent(double percent) { |
130 last_percent_ = percent; | 130 last_percent_ = percent; |
131 if (!dragging_) | 131 if (!dragging_) |
132 slider_->SetValue(static_cast<float>(percent / 100.0)); | 132 slider_->SetValue(static_cast<float>(percent / 100.0)); |
133 } | 133 } |
134 | 134 |
135 void BrightnessView::OnMaximizeModeStarted() { | 135 void BrightnessView::OnTabletModeStarted() { |
136 SetVisible(true); | 136 SetVisible(true); |
137 } | 137 } |
138 | 138 |
139 void BrightnessView::OnMaximizeModeEnded() { | 139 void BrightnessView::OnTabletModeEnded() { |
140 SetVisible(false); | 140 SetVisible(false); |
141 } | 141 } |
142 | 142 |
143 void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 143 void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
144 int w = width() - slider_->x(); | 144 int w = width() - slider_->x(); |
145 slider_->SetSize(gfx::Size(w, slider_->height())); | 145 slider_->SetSize(gfx::Size(w, slider_->height())); |
146 } | 146 } |
147 | 147 |
148 void BrightnessView::SliderValueChanged(views::Slider* sender, | 148 void BrightnessView::SliderValueChanged(views::Slider* sender, |
149 float value, | 149 float value, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (!display::Display::HasInternalDisplay()) | 268 if (!display::Display::HasInternalDisplay()) |
269 return; | 269 return; |
270 | 270 |
271 if (brightness_view_ && brightness_view_->visible()) | 271 if (brightness_view_ && brightness_view_->visible()) |
272 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); | 272 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); |
273 else | 273 else |
274 ShowDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); | 274 ShowDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); |
275 } | 275 } |
276 | 276 |
277 } // namespace ash | 277 } // namespace ash |
OLD | NEW |