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

Unified 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: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/date/date_view.h
diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h
index 787ca690978f7dc829ceedb9f0f9318ff4164f0e..d605815261de6bc88ee0bcd4a7499a41c0b4ec0b 100644
--- a/ash/system/date/date_view.h
+++ b/ash/system/date/date_view.h
@@ -19,42 +19,81 @@ namespace ash {
namespace internal {
namespace tray {
-// This view is used for both the TrayDate tray icon and the TrayPower popup.
-class DateView : public ActionableView {
+// Abstract base class containing common updating and layout code for the
+// DateView popup and the TimeView tray icon.
+class BaseDateTimeView : public ActionableView {
Daniel Erat 2012/04/27 23:22:06 Let me know if you think that this is ugly and wou
sadrul 2012/04/30 15:05:52 This looks good.
public:
- enum TimeType {
- TIME,
- DATE
- };
+ virtual ~BaseDateTimeView();
- explicit DateView(TimeType type);
+ // Updates the displayed text for the current time.
+ void UpdateText();
+
+ protected:
+ BaseDateTimeView();
+
+ private:
+ // Updates labels to display the current time.
+ virtual void UpdateTextInternal(const base::Time& now) = 0;
+
+ // Overridden from views::View.
+ virtual void OnLocaleChanged() OVERRIDE;
+
+ base::OneShotTimer<BaseDateTimeView> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView);
+};
+
+// Popup view used to display the date and day of week.
+class DateView : public BaseDateTimeView {
+ public:
+ DateView();
virtual ~DateView();
- void UpdateTimeFormat();
- views::Label* label() const { return label_; }
// Sets whether the view is actionable. An actionable date view gives visual
// feedback on hover, can be focused by keyboard, and clicking/pressing space
// or enter on the view shows date-related settings.
void SetActionable(bool actionable);
- void UpdateText();
-
private:
+ // Overridden from BaseDateTimeView.
+ virtual void UpdateTextInternal(const base::Time& now) OVERRIDE;
+
// Overridden from ActionableView.
virtual bool PerformAction(const views::Event& event) OVERRIDE;
- // Overridden from views::View.
- virtual void OnLocaleChanged() OVERRIDE;
+ views::Label* date_label_;
+ views::Label* day_of_week_label_;
- base::OneShotTimer<DateView> timer_;
- base::HourClockType hour_type_;
- TimeType type_;
bool actionable_;
- views::Label* label_;
DISALLOW_COPY_AND_ASSIGN(DateView);
};
+// Tray view used to display the current time.
+class TimeView : public BaseDateTimeView {
+ public:
+ TimeView();
+ virtual ~TimeView();
+
+ views::Label* label() const { return label_; }
+
+ // Updates the format of the displayed time.
+ void UpdateTimeFormat();
+
+ private:
+ // Overridden from BaseDateTimeView.
+ virtual void UpdateTextInternal(const base::Time& now) OVERRIDE;
+
+ // Overridden from ActionableView.
+ virtual bool PerformAction(const views::Event& event) OVERRIDE;
+
+ views::Label* label_;
+
+ base::HourClockType hour_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(TimeView);
+};
+
} // namespace tray
} // namespace internal
} // namespace ash
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/system/date/date_view.cc » ('j') | ash/system/date/date_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698