unified_brightness_slider_controller.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_BRIGHTNESS_UNIFIED_BRIGHTNESS_SLIDER_CONTROLLER_H_
  5. #define ASH_SYSTEM_BRIGHTNESS_UNIFIED_BRIGHTNESS_SLIDER_CONTROLLER_H_
  6. #include "ash/system/unified/unified_slider_view.h"
  7. #include "base/memory/scoped_refptr.h"
  8. namespace ash {
  9. class UnifiedSystemTrayModel;
  10. // Controller of a slider that can change display brightness.
  11. class UnifiedBrightnessSliderController : public UnifiedSliderListener {
  12. public:
  13. explicit UnifiedBrightnessSliderController(
  14. scoped_refptr<UnifiedSystemTrayModel> model);
  15. UnifiedBrightnessSliderController(const UnifiedBrightnessSliderController&) =
  16. delete;
  17. UnifiedBrightnessSliderController& operator=(
  18. const UnifiedBrightnessSliderController&) = delete;
  19. ~UnifiedBrightnessSliderController() override;
  20. // UnifiedSliderListener:
  21. views::View* CreateView() override;
  22. void SliderValueChanged(views::Slider* sender,
  23. float value,
  24. float old_value,
  25. views::SliderChangeReason reason) override;
  26. private:
  27. scoped_refptr<UnifiedSystemTrayModel> model_;
  28. UnifiedSliderView* slider_ = nullptr;
  29. // We have to store previous manually set value because |old_value| might be
  30. // set by UnifiedSystemTrayModel::Observer.
  31. double previous_percent_ = 100.0;
  32. };
  33. } // namespace ash
  34. #endif // ASH_SYSTEM_BRIGHTNESS_UNIFIED_BRIGHTNESS_SLIDER_CONTROLLER_H_