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

Side by Side Diff: ash/system/date/date_view.h

Issue 10209038: ash: Add vertical spacing to multi-line text in tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/system/date/date_view.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 (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 #pragma once 7 #pragma once
8 8
9 #include "ash/system/tray/tray_views.h" 9 #include "ash/system/tray/tray_views.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
11 #include "base/timer.h" 11 #include "base/timer.h"
12 #include "ui/views/view.h" 12 #include "ui/views/view.h"
13 13
14 namespace views { 14 namespace views {
15 class Label; 15 class Label;
16 } 16 }
17 17
18 namespace ash { 18 namespace ash {
19 namespace internal { 19 namespace internal {
20 namespace tray { 20 namespace tray {
21 21
22 // This view is used for both the TrayDate tray icon and the TrayPower popup. 22 // Abstract base class containing common updating and layout code for the
23 class DateView : public ActionableView { 23 // DateView popup and the TimeView tray icon.
24 class BaseDateTimeView : public ActionableView {
24 public: 25 public:
25 enum TimeType { 26 virtual ~BaseDateTimeView();
26 TIME,
27 DATE
28 };
29 27
30 explicit DateView(TimeType type); 28 // Updates the displayed text for the current time.
29 void UpdateText();
30
31 protected:
32 BaseDateTimeView();
33
34 private:
35 // Updates labels to display the current time.
36 virtual void UpdateTextInternal(const base::Time& now) = 0;
37
38 // Overridden from views::View.
39 virtual void OnLocaleChanged() OVERRIDE;
40
41 base::OneShotTimer<BaseDateTimeView> timer_;
42
43 DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView);
44 };
45
46 // Popup view used to display the date and day of week.
47 class DateView : public BaseDateTimeView {
48 public:
49 DateView();
31 virtual ~DateView(); 50 virtual ~DateView();
32 void UpdateTimeFormat();
33 views::Label* label() const { return label_; }
34 51
35 // Sets whether the view is actionable. An actionable date view gives visual 52 // Sets whether the view is actionable. An actionable date view gives visual
36 // feedback on hover, can be focused by keyboard, and clicking/pressing space 53 // feedback on hover, can be focused by keyboard, and clicking/pressing space
37 // or enter on the view shows date-related settings. 54 // or enter on the view shows date-related settings.
38 void SetActionable(bool actionable); 55 void SetActionable(bool actionable);
39 56
40 void UpdateText(); 57 private:
58 // Overridden from BaseDateTimeView.
59 virtual void UpdateTextInternal(const base::Time& now) OVERRIDE;
41 60
42 private:
43 // Overridden from ActionableView. 61 // Overridden from ActionableView.
44 virtual bool PerformAction(const views::Event& event) OVERRIDE; 62 virtual bool PerformAction(const views::Event& event) OVERRIDE;
45 63
46 // Overridden from views::View. 64 views::Label* date_label_;
47 virtual void OnLocaleChanged() OVERRIDE; 65 views::Label* day_of_week_label_;
48 66
49 base::OneShotTimer<DateView> timer_;
50 base::HourClockType hour_type_;
51 TimeType type_;
52 bool actionable_; 67 bool actionable_;
68
69 DISALLOW_COPY_AND_ASSIGN(DateView);
70 };
71
72 // Tray view used to display the current time.
73 class TimeView : public BaseDateTimeView {
74 public:
75 TimeView();
76 virtual ~TimeView();
77
78 views::Label* label() const { return label_; }
79
80 // Updates the format of the displayed time.
81 void UpdateTimeFormat();
82
83 private:
84 // Overridden from BaseDateTimeView.
85 virtual void UpdateTextInternal(const base::Time& now) OVERRIDE;
86
87 // Overridden from ActionableView.
88 virtual bool PerformAction(const views::Event& event) OVERRIDE;
89
53 views::Label* label_; 90 views::Label* label_;
54 91
55 DISALLOW_COPY_AND_ASSIGN(DateView); 92 base::HourClockType hour_type_;
93
94 DISALLOW_COPY_AND_ASSIGN(TimeView);
56 }; 95 };
57 96
58 } // namespace tray 97 } // namespace tray
59 } // namespace internal 98 } // namespace internal
60 } // namespace ash 99 } // namespace ash
61 100
62 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_ 101 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/system/date/date_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698