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

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

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 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
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 #include "ash/system/date/date_view.h" 5 #include "ash/system/date/date_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_utils.h" 10 #include "ash/system/tray/tray_utils.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 void BaseDateTimeView::UpdateText() { 88 void BaseDateTimeView::UpdateText() {
89 base::Time now = base::Time::Now(); 89 base::Time now = base::Time::Now();
90 UpdateTextInternal(now); 90 UpdateTextInternal(now);
91 SchedulePaint(); 91 SchedulePaint();
92 SetTimer(now); 92 SetTimer(now);
93 } 93 }
94 94
95 BaseDateTimeView::BaseDateTimeView() { 95 BaseDateTimeView::BaseDateTimeView() {
96 SetTimer(base::Time::Now()); 96 SetTimer(base::Time::Now());
97 SetFocusBehavior(FocusBehavior::NEVER);
97 } 98 }
98 99
99 void BaseDateTimeView::SetTimer(const base::Time& now) { 100 void BaseDateTimeView::SetTimer(const base::Time& now) {
100 // Try to set the timer to go off at the next change of the minute. We don't 101 // Try to set the timer to go off at the next change of the minute. We don't
101 // want to have the timer go off more than necessary since that will cause 102 // want to have the timer go off more than necessary since that will cause
102 // the CPU to wake up and consume power. 103 // the CPU to wake up and consume power.
103 base::Time::Exploded exploded; 104 base::Time::Exploded exploded;
104 now.LocalExplode(&exploded); 105 now.LocalExplode(&exploded);
105 106
106 // Often this will be called at minute boundaries, and we'll actually want 107 // Often this will be called at minute boundaries, and we'll actually want
(...skipping 24 matching lines...) Expand all
131 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 132 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
132 GetHourClockType()), 133 GetHourClockType()),
133 action_(TrayDate::NONE) { 134 action_(TrayDate::NONE) {
134 SetLayoutManager( 135 SetLayoutManager(
135 new views::BoxLayout( 136 new views::BoxLayout(
136 views::BoxLayout::kVertical, 0, 0, 0)); 137 views::BoxLayout::kVertical, 0, 0, 0));
137 date_label_ = CreateLabel(); 138 date_label_ = CreateLabel();
138 date_label_->SetEnabledColor(kHeaderTextColorNormal); 139 date_label_->SetEnabledColor(kHeaderTextColorNormal);
139 UpdateTextInternal(base::Time::Now()); 140 UpdateTextInternal(base::Time::Now());
140 AddChildView(date_label_); 141 AddChildView(date_label_);
141 SetFocusable(false);
142 } 142 }
143 143
144 DateView::~DateView() { 144 DateView::~DateView() {
145 } 145 }
146 146
147 void DateView::SetAction(TrayDate::DateAction action) { 147 void DateView::SetAction(TrayDate::DateAction action) {
148 if (action == action_) 148 if (action == action_)
149 return; 149 return;
150 if (IsMouseHovered()) { 150 if (IsMouseHovered()) {
151 date_label_->SetEnabledColor( 151 date_label_->SetEnabledColor(
152 action == TrayDate::NONE ? kHeaderTextColorNormal : 152 action == TrayDate::NONE ? kHeaderTextColorNormal :
153 kHeaderTextColorHover); 153 kHeaderTextColorHover);
154 SchedulePaint(); 154 SchedulePaint();
155 } 155 }
156 action_ = action; 156 action_ = action;
157 SetFocusable(action_ != TrayDate::NONE); 157 SetFocusBehavior(action_ != TrayDate::NONE ? FocusBehavior::ALWAYS
158 : FocusBehavior::NEVER);
158 } 159 }
159 160
160 void DateView::UpdateTimeFormat() { 161 void DateView::UpdateTimeFormat() {
161 hour_type_ = 162 hour_type_ =
162 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); 163 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
163 UpdateText(); 164 UpdateText();
164 } 165 }
165 166
166 base::HourClockType DateView::GetHourTypeForTesting() const { 167 base::HourClockType DateView::GetHourTypeForTesting() const {
167 return hour_type_; 168 return hour_type_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 221
221 /////////////////////////////////////////////////////////////////////////////// 222 ///////////////////////////////////////////////////////////////////////////////
222 223
223 TimeView::TimeView(TrayDate::ClockLayout clock_layout) 224 TimeView::TimeView(TrayDate::ClockLayout clock_layout)
224 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 225 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
225 GetHourClockType()) { 226 GetHourClockType()) {
226 SetupLabels(); 227 SetupLabels();
227 UpdateTextInternal(base::Time::Now()); 228 UpdateTextInternal(base::Time::Now());
228 UpdateClockLayout(clock_layout); 229 UpdateClockLayout(clock_layout);
229 SetFocusable(false);
230 } 230 }
231 231
232 TimeView::~TimeView() { 232 TimeView::~TimeView() {
233 } 233 }
234 234
235 void TimeView::UpdateTimeFormat() { 235 void TimeView::UpdateTimeFormat() {
236 hour_type_ = 236 hour_type_ =
237 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); 237 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
238 UpdateText(); 238 UpdateText();
239 } 239 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 333 }
334 334
335 void TimeView::SetupLabel(views::Label* label) { 335 void TimeView::SetupLabel(views::Label* label) {
336 label->set_owned_by_client(); 336 label->set_owned_by_client();
337 SetupLabelForTray(label); 337 SetupLabelForTray(label);
338 label->SetElideBehavior(gfx::NO_ELIDE); 338 label->SetElideBehavior(gfx::NO_ELIDE);
339 } 339 }
340 340
341 } // namespace tray 341 } // namespace tray
342 } // namespace ash 342 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_state_list_detailed_view.cc ('k') | ash/system/toast/toast_overlay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698