summaryrefslogtreecommitdiffstats
path: root/ash/system
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-31 06:34:53 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-31 06:34:53 +0000
commit84896cf532157415201d85c98fb0f6eb7cee7e69 (patch)
treefaa5c1b91d734f33755e9349aac4ee7ad76657f3 /ash/system
parent05ee36910ac5577373e247012e006603e9768cd1 (diff)
downloadchromium_src-84896cf532157415201d85c98fb0f6eb7cee7e69.zip
chromium_src-84896cf532157415201d85c98fb0f6eb7cee7e69.tar.gz
chromium_src-84896cf532157415201d85c98fb0f6eb7cee7e69.tar.bz2
ash: Make the date entry in the tray popup accesible.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9950031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r--ash/system/date/date_view.cc8
-rw-r--r--ash/system/date/date_view.h12
-rw-r--r--ash/system/power/tray_power.cc2
3 files changed, 17 insertions, 5 deletions
diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc
index 4eccd79..1a39580 100644
--- a/ash/system/date/date_view.cc
+++ b/ash/system/date/date_view.cc
@@ -61,6 +61,7 @@ DateView::DateView(TimeType type)
label_->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
UpdateText();
AddChildView(label_);
+ set_focusable(actionable_);
}
DateView::~DateView() {
@@ -72,6 +73,11 @@ void DateView::UpdateTimeFormat() {
UpdateText();
}
+void DateView::SetActionable(bool actionable) {
+ actionable_ = actionable;
+ set_focusable(actionable_);
+}
+
void DateView::UpdateText() {
base::Time now = base::Time::Now();
gfx::Size old_size = label_->GetPreferredSize();
@@ -111,7 +117,7 @@ void DateView::UpdateText() {
&DateView::UpdateText);
}
-bool DateView::OnMousePressed(const views::MouseEvent& event) {
+bool DateView::PerformAction(const views::Event& event) {
if (!actionable_)
return false;
diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h
index 83a13ee..8e0faaa 100644
--- a/ash/system/date/date_view.h
+++ b/ash/system/date/date_view.h
@@ -6,6 +6,7 @@
#define ASH_SYSTEM_DATE_DATE_VIEW_H_
#pragma once
+#include "ash/system/tray/tray_views.h"
#include "base/i18n/time_formatting.h"
#include "base/timer.h"
#include "ui/views/view.h"
@@ -19,7 +20,7 @@ namespace internal {
namespace tray {
// This view is used for both the TrayDate tray icon and the TrayPower popup.
-class DateView : public views::View {
+class DateView : public ActionableView {
public:
enum TimeType {
TIME,
@@ -31,13 +32,18 @@ class DateView : public views::View {
void UpdateTimeFormat();
views::Label* label() const { return label_; }
- void set_actionable(bool actionable) { actionable_ = actionable; }
+ // 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 ActionableView.
+ virtual bool PerformAction(const views::Event& event) OVERRIDE;
+
// Overridden from views::View.
- virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual void OnLocaleChanged() OVERRIDE;
diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc
index ae64503..8419dbc 100644
--- a/ash/system/power/tray_power.cc
+++ b/ash/system/power/tray_power.cc
@@ -173,7 +173,7 @@ views::View* TrayPower::CreateTrayView(user::LoginStatus status) {
views::View* TrayPower::CreateDefaultView(user::LoginStatus status) {
date_.reset(new tray::DateView(tray::DateView::DATE));
if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED)
- date_->set_actionable(true);
+ date_->SetActionable(true);
views::View* container = new views::View;
views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal,