glanceable_info_view.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2020 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_AMBIENT_UI_GLANCEABLE_INFO_VIEW_H_
  5. #define ASH_AMBIENT_UI_GLANCEABLE_INFO_VIEW_H_
  6. #include "ash/ambient/model/ambient_weather_model.h"
  7. #include "ash/ambient/model/ambient_weather_model_observer.h"
  8. #include "base/scoped_observation.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. #include "ui/views/view.h"
  11. namespace views {
  12. class ImageView;
  13. class Label;
  14. } // namespace views
  15. namespace ash {
  16. class AmbientViewDelegate;
  17. class TimeView;
  18. // Container for displaying a glanceable clock and weather info.
  19. class GlanceableInfoView : public views::View,
  20. public AmbientWeatherModelObserver {
  21. public:
  22. METADATA_HEADER(GlanceableInfoView);
  23. GlanceableInfoView(AmbientViewDelegate* delegate,
  24. int time_font_size_dip,
  25. SkColor time_temperature_font_color);
  26. GlanceableInfoView(const GlanceableInfoView&) = delete;
  27. GlanceableInfoView& operator=(const GlanceableInfoView&) = delete;
  28. ~GlanceableInfoView() override;
  29. // views::View:
  30. void OnThemeChanged() override;
  31. // AmbientWeatherModelObserver:
  32. void OnWeatherInfoUpdated() override;
  33. void Show();
  34. private:
  35. void InitLayout();
  36. std::u16string GetTemperatureText() const;
  37. // View for the time info. Owned by the view hierarchy.
  38. TimeView* time_view_ = nullptr;
  39. // Views for weather icon and temperature.
  40. views::ImageView* weather_condition_icon_ = nullptr;
  41. views::Label* temperature_ = nullptr;
  42. // Owned by |AmbientController|.
  43. AmbientViewDelegate* const delegate_ = nullptr;
  44. const int time_font_size_dip_;
  45. const SkColor time_temperature_font_color_;
  46. base::ScopedObservation<AmbientWeatherModel, AmbientWeatherModelObserver>
  47. scoped_weather_model_observer_{this};
  48. };
  49. } // namespace ash
  50. #endif // ASH_AMBIENT_UI_GLANCEABLE_INFO_VIEW_H_