| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef ASH_SYSTEM_DATE_DATE_VIEW_H_ | 5 #ifndef ASH_SYSTEM_DATE_DATE_VIEW_H_ |
| 6 #define ASH_SYSTEM_DATE_DATE_VIEW_H_ | 6 #define ASH_SYSTEM_DATE_DATE_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Abstract base class containing common updating and layout code for the | 25 // Abstract base class containing common updating and layout code for the |
| 26 // DateView popup and the TimeView tray icon. Exported for tests. | 26 // DateView popup and the TimeView tray icon. Exported for tests. |
| 27 class ASH_EXPORT BaseDateTimeView : public ActionableView { | 27 class ASH_EXPORT BaseDateTimeView : public ActionableView { |
| 28 public: | 28 public: |
| 29 ~BaseDateTimeView() override; | 29 ~BaseDateTimeView() override; |
| 30 | 30 |
| 31 // Updates the displayed text for the current time and calls SetTimer(). | 31 // Updates the displayed text for the current time and calls SetTimer(). |
| 32 void UpdateText(); | 32 void UpdateText(); |
| 33 | 33 |
| 34 // views::View overrides: |
| 35 void GetAccessibleState(ui::AXViewState* state) override; |
| 36 |
| 34 protected: | 37 protected: |
| 35 BaseDateTimeView(); | 38 BaseDateTimeView(); |
| 36 | 39 |
| 40 // Updates labels to display the current time. |
| 41 virtual void UpdateTextInternal(const base::Time& now); |
| 42 |
| 43 // Time format (12/24hr) used for accessibility string. |
| 44 base::HourClockType hour_type_; |
| 45 |
| 37 private: | 46 private: |
| 38 // Starts |timer_| to schedule the next update. | 47 // Starts |timer_| to schedule the next update. |
| 39 void SetTimer(const base::Time& now); | 48 void SetTimer(const base::Time& now); |
| 40 | 49 |
| 41 // Updates labels to display the current time. | |
| 42 virtual void UpdateTextInternal(const base::Time& now) = 0; | |
| 43 | |
| 44 // Overridden from views::View. | 50 // Overridden from views::View. |
| 45 void ChildPreferredSizeChanged(views::View* child) override; | 51 void ChildPreferredSizeChanged(views::View* child) override; |
| 46 void OnLocaleChanged() override; | 52 void OnLocaleChanged() override; |
| 47 | 53 |
| 48 // Invokes UpdateText() when the displayed time should change. | 54 // Invokes UpdateText() when the displayed time should change. |
| 49 base::OneShotTimer timer_; | 55 base::OneShotTimer timer_; |
| 50 | 56 |
| 51 DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView); | 57 DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView); |
| 52 }; | 58 }; |
| 53 | 59 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 // Overridden from ActionableView. | 83 // Overridden from ActionableView. |
| 78 bool PerformAction(const ui::Event& event) override; | 84 bool PerformAction(const ui::Event& event) override; |
| 79 | 85 |
| 80 // Overridden from views::View. | 86 // Overridden from views::View. |
| 81 void OnMouseEntered(const ui::MouseEvent& event) override; | 87 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 82 void OnMouseExited(const ui::MouseEvent& event) override; | 88 void OnMouseExited(const ui::MouseEvent& event) override; |
| 83 void OnGestureEvent(ui::GestureEvent* event) override; | 89 void OnGestureEvent(ui::GestureEvent* event) override; |
| 84 | 90 |
| 85 views::Label* date_label_; | 91 views::Label* date_label_; |
| 86 | 92 |
| 87 // Time format (12/24hr) used for accessibility string. | |
| 88 base::HourClockType hour_type_; | |
| 89 | |
| 90 TrayDate::DateAction action_; | 93 TrayDate::DateAction action_; |
| 91 | 94 |
| 92 DISALLOW_COPY_AND_ASSIGN(DateView); | 95 DISALLOW_COPY_AND_ASSIGN(DateView); |
| 93 }; | 96 }; |
| 94 | 97 |
| 95 // Tray view used to display the current time. | 98 // Tray view used to display the current time. |
| 96 // Exported for tests. | 99 // Exported for tests. |
| 97 class ASH_EXPORT TimeView : public BaseDateTimeView { | 100 class ASH_EXPORT TimeView : public BaseDateTimeView { |
| 98 public: | 101 public: |
| 99 explicit TimeView(TrayDate::ClockLayout clock_layout); | 102 explicit TimeView(TrayDate::ClockLayout clock_layout); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 123 void SetupLabels(); | 126 void SetupLabels(); |
| 124 void SetupLabel(views::Label* label); | 127 void SetupLabel(views::Label* label); |
| 125 | 128 |
| 126 // Label text used for the normal horizontal shelf. | 129 // Label text used for the normal horizontal shelf. |
| 127 std::unique_ptr<views::Label> horizontal_label_; | 130 std::unique_ptr<views::Label> horizontal_label_; |
| 128 | 131 |
| 129 // The time label is split into two lines for the vertical shelf. | 132 // The time label is split into two lines for the vertical shelf. |
| 130 std::unique_ptr<views::Label> vertical_label_hours_; | 133 std::unique_ptr<views::Label> vertical_label_hours_; |
| 131 std::unique_ptr<views::Label> vertical_label_minutes_; | 134 std::unique_ptr<views::Label> vertical_label_minutes_; |
| 132 | 135 |
| 133 base::HourClockType hour_type_; | |
| 134 | |
| 135 DISALLOW_COPY_AND_ASSIGN(TimeView); | 136 DISALLOW_COPY_AND_ASSIGN(TimeView); |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 } // namespace tray | 139 } // namespace tray |
| 139 } // namespace ash | 140 } // namespace ash |
| 140 | 141 |
| 141 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_ | 142 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_ |
| OLD | NEW |