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

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, 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 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 131 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
132 GetHourClockType()), 132 GetHourClockType()),
133 action_(TrayDate::NONE) { 133 action_(TrayDate::NONE) {
134 SetLayoutManager( 134 SetLayoutManager(
135 new views::BoxLayout( 135 new views::BoxLayout(
136 views::BoxLayout::kVertical, 0, 0, 0)); 136 views::BoxLayout::kVertical, 0, 0, 0));
137 date_label_ = CreateLabel(); 137 date_label_ = CreateLabel();
138 date_label_->SetEnabledColor(kHeaderTextColorNormal); 138 date_label_->SetEnabledColor(kHeaderTextColorNormal);
139 UpdateTextInternal(base::Time::Now()); 139 UpdateTextInternal(base::Time::Now());
140 AddChildView(date_label_); 140 AddChildView(date_label_);
141 SetFocusable(false); 141 SetFocusBehavior(FocusBehavior::NEVER);
tapted 2016/04/20 04:16:28 (wait for sky to comment on this, but I wonder if
sky 2016/04/20 19:26:02 I don't feel strongly here. I'm ok either way.
karandeepb 2016/04/21 03:16:33 I don't think we should do this since ActionableVi
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 SetFocusBehavior(FocusBehavior::NEVER);
230 } 231 }
231 232
232 TimeView::~TimeView() { 233 TimeView::~TimeView() {
233 } 234 }
234 235
235 void TimeView::UpdateTimeFormat() { 236 void TimeView::UpdateTimeFormat() {
236 hour_type_ = 237 hour_type_ =
237 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); 238 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
238 UpdateText(); 239 UpdateText();
239 } 240 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 334 }
334 335
335 void TimeView::SetupLabel(views::Label* label) { 336 void TimeView::SetupLabel(views::Label* label) {
336 label->set_owned_by_client(); 337 label->set_owned_by_client();
337 SetupLabelForTray(label); 338 SetupLabelForTray(label);
338 label->SetElideBehavior(gfx::NO_ELIDE); 339 label->SetElideBehavior(gfx::NO_ELIDE);
339 } 340 }
340 341
341 } // namespace tray 342 } // namespace tray
342 } // namespace ash 343 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698