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

Side by Side Diff: ash/system/tray/tray_views.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/system/tray/tray_views.h ('k') | ash/system/web_notification/web_notification_tray.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 #include "ash/system/tray/tray_views.h" 5 #include "ash/system/tray/tray_views.h"
6 6
7 #include "ash/system/tray/tray_constants.h" 7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_item_view.h" 8 #include "ash/system/tray/tray_item_view.h"
9 #include "grit/ash_strings.h" 9 #include "grit/ash_strings.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 void ActionableView::DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds) { 113 void ActionableView::DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds) {
114 gfx::Rect rect = bounds; 114 gfx::Rect rect = bounds;
115 rect.Inset(1, 1, 3, 3); 115 rect.Inset(1, 1, 3, 3);
116 canvas->DrawRect(rect, kFocusBorderColor); 116 canvas->DrawRect(rect, kFocusBorderColor);
117 } 117 }
118 118
119 bool ActionableView::OnKeyPressed(const ui::KeyEvent& event) { 119 bool ActionableView::OnKeyPressed(const ui::KeyEvent& event) {
120 if (event.key_code() == ui::VKEY_SPACE || 120 if (event.key_code() == ui::VKEY_SPACE ||
121 event.key_code() == ui::VKEY_RETURN) { 121 event.key_code() == ui::VKEY_RETURN) {
122 // TODO(beng): remove once views::Event is gone. 122 return PerformAction(event);
123 views::MouseEvent synthetic_event(
124 ui::ET_MOUSE_RELEASED, 0, 0, ui::EF_LEFT_MOUSE_BUTTON);
125 return PerformAction(synthetic_event);
126 } 123 }
127 return false; 124 return false;
128 } 125 }
129 126
130 bool ActionableView::OnMousePressed(const views::MouseEvent& event) { 127 bool ActionableView::OnMousePressed(const ui::MouseEvent& event) {
131 // Return true so that this view starts capturing the events. 128 // Return true so that this view starts capturing the events.
132 has_capture_ = true; 129 has_capture_ = true;
133 return true; 130 return true;
134 } 131 }
135 132
136 void ActionableView::OnMouseReleased(const views::MouseEvent& event) { 133 void ActionableView::OnMouseReleased(const ui::MouseEvent& event) {
137 if (has_capture_ && GetLocalBounds().Contains(event.location())) 134 if (has_capture_ && GetLocalBounds().Contains(event.location()))
138 PerformAction(event); 135 PerformAction(event);
139 } 136 }
140 137
141 void ActionableView::OnMouseCaptureLost() { 138 void ActionableView::OnMouseCaptureLost() {
142 has_capture_ = false; 139 has_capture_ = false;
143 } 140 }
144 141
145 void ActionableView::SetAccessibleName(const string16& name) { 142 void ActionableView::SetAccessibleName(const string16& name) {
146 accessible_name_ = name; 143 accessible_name_ = name;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return true; 222 return true;
226 } 223 }
227 224
228 gfx::Size HoverHighlightView::GetPreferredSize() { 225 gfx::Size HoverHighlightView::GetPreferredSize() {
229 gfx::Size size = ActionableView::GetPreferredSize(); 226 gfx::Size size = ActionableView::GetPreferredSize();
230 if (fixed_height_) 227 if (fixed_height_)
231 size.set_height(fixed_height_); 228 size.set_height(fixed_height_);
232 return size; 229 return size;
233 } 230 }
234 231
235 void HoverHighlightView::OnMouseEntered(const views::MouseEvent& event) { 232 void HoverHighlightView::OnMouseEntered(const ui::MouseEvent& event) {
236 hover_ = true; 233 hover_ = true;
237 if (text_highlight_color_ && text_label_) 234 if (text_highlight_color_ && text_label_)
238 text_label_->SetEnabledColor(text_highlight_color_); 235 text_label_->SetEnabledColor(text_highlight_color_);
239 SchedulePaint(); 236 SchedulePaint();
240 } 237 }
241 238
242 void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) { 239 void HoverHighlightView::OnMouseExited(const ui::MouseEvent& event) {
243 hover_ = false; 240 hover_ = false;
244 if (text_default_color_ && text_label_) 241 if (text_default_color_ && text_label_)
245 text_label_->SetEnabledColor(text_default_color_); 242 text_label_->SetEnabledColor(text_default_color_);
246 SchedulePaint(); 243 SchedulePaint();
247 } 244 }
248 245
249 void HoverHighlightView::OnEnabledChanged() { 246 void HoverHighlightView::OnEnabledChanged() {
250 for (int i = 0; i < child_count(); ++i) 247 for (int i = 0; i < child_count(); ++i)
251 child_at(i)->SetEnabled(enabled()); 248 child_at(i)->SetEnabled(enabled());
252 } 249 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 301 }
305 } 302 }
306 303
307 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 304 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
308 views::View* contents = GetContents(); 305 views::View* contents = GetContents();
309 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize()); 306 gfx::Rect bounds = gfx::Rect(contents->GetPreferredSize());
310 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); 307 bounds.set_width(std::max(0, width() - GetScrollBarWidth()));
311 contents->SetBoundsRect(bounds); 308 contents->SetBoundsRect(bounds);
312 } 309 }
313 310
314 void FixedSizedScrollView::OnMouseEntered(const views::MouseEvent& event) { 311 void FixedSizedScrollView::OnMouseEntered(const ui::MouseEvent& event) {
315 // TODO(sad): This is done to make sure that the scroll view scrolls on 312 // TODO(sad): This is done to make sure that the scroll view scrolls on
316 // mouse-wheel events. This is ugly, and Ben thinks this is weird. There 313 // mouse-wheel events. This is ugly, and Ben thinks this is weird. There
317 // should be a better fix for this. 314 // should be a better fix for this.
318 RequestFocus(); 315 RequestFocus();
319 } 316 }
320 317
321 void FixedSizedScrollView::OnPaintFocusBorder(gfx::Canvas* canvas) { 318 void FixedSizedScrollView::OnPaintFocusBorder(gfx::Canvas* canvas) {
322 // Do not paint the focus border. 319 // Do not paint the focus border.
323 } 320 }
324 321
(...skipping 14 matching lines...) Expand all
339 } 336 }
340 337
341 TrayPopupTextButton::~TrayPopupTextButton() {} 338 TrayPopupTextButton::~TrayPopupTextButton() {}
342 339
343 gfx::Size TrayPopupTextButton::GetPreferredSize() { 340 gfx::Size TrayPopupTextButton::GetPreferredSize() {
344 gfx::Size size = views::TextButton::GetPreferredSize(); 341 gfx::Size size = views::TextButton::GetPreferredSize();
345 size.Enlarge(32, 16); 342 size.Enlarge(32, 16);
346 return size; 343 return size;
347 } 344 }
348 345
349 void TrayPopupTextButton::OnMouseEntered(const views::MouseEvent& event) { 346 void TrayPopupTextButton::OnMouseEntered(const ui::MouseEvent& event) {
350 hover_ = true; 347 hover_ = true;
351 SchedulePaint(); 348 SchedulePaint();
352 } 349 }
353 350
354 void TrayPopupTextButton::OnMouseExited(const views::MouseEvent& event) { 351 void TrayPopupTextButton::OnMouseExited(const ui::MouseEvent& event) {
355 hover_ = false; 352 hover_ = false;
356 SchedulePaint(); 353 SchedulePaint();
357 } 354 }
358 355
359 void TrayPopupTextButton::OnPaintBackground(gfx::Canvas* canvas) { 356 void TrayPopupTextButton::OnPaintBackground(gfx::Canvas* canvas) {
360 if (hover_) 357 if (hover_)
361 hover_bg_->Paint(canvas, this); 358 hover_bg_->Paint(canvas, this);
362 else 359 else
363 views::TextButton::OnPaintBackground(canvas); 360 views::TextButton::OnPaintBackground(canvas);
364 } 361 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 tray_view->set_border(views::Border::CreateEmptyBorder( 649 tray_view->set_border(views::Border::CreateEmptyBorder(
653 kTrayLabelItemVerticalPaddingVeriticalAlignment, 650 kTrayLabelItemVerticalPaddingVeriticalAlignment,
654 horizontal_padding, 651 horizontal_padding,
655 kTrayLabelItemVerticalPaddingVeriticalAlignment, 652 kTrayLabelItemVerticalPaddingVeriticalAlignment,
656 horizontal_padding)); 653 horizontal_padding));
657 } 654 }
658 } 655 }
659 656
660 } // namespace internal 657 } // namespace internal
661 } // namespace ash 658 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_views.h ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698