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

Side by Side Diff: ui/views/widget/root_view.cc

Issue 8909002: views: Convert IsEnabled() to just enabled() since it's just a simple accessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « ui/views/widget/drop_helper.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 // Input ----------------------------------------------------------------------- 83 // Input -----------------------------------------------------------------------
84 84
85 bool RootView::OnKeyEvent(const KeyEvent& event) { 85 bool RootView::OnKeyEvent(const KeyEvent& event) {
86 bool consumed = false; 86 bool consumed = false;
87 87
88 View* v = GetFocusManager()->GetFocusedView(); 88 View* v = GetFocusManager()->GetFocusedView();
89 // Special case to handle right-click context menus triggered by the 89 // Special case to handle right-click context menus triggered by the
90 // keyboard. 90 // keyboard.
91 if (v && v->IsEnabled() && ((event.key_code() == ui::VKEY_APPS) || 91 if (v && v->enabled() && ((event.key_code() == ui::VKEY_APPS) ||
92 (event.key_code() == ui::VKEY_F10 && event.IsShiftDown()))) { 92 (event.key_code() == ui::VKEY_F10 && event.IsShiftDown()))) {
93 v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false); 93 v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false);
94 return true; 94 return true;
95 } 95 }
96 for (; v && v != this && !consumed; v = v->parent()) { 96 for (; v && v != this && !consumed; v = v->parent()) {
97 consumed = (event.type() == ui::ET_KEY_PRESSED) ? 97 consumed = (event.type() == ui::ET_KEY_PRESSED) ?
98 v->OnKeyPressed(event) : v->OnKeyReleased(event); 98 v->OnKeyPressed(event) : v->OnKeyReleased(event);
99 } 99 }
100 return consumed; 100 return consumed;
101 } 101 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 &drag_info); 181 &drag_info);
182 return true; 182 return true;
183 } 183 }
184 DCHECK(!explicit_mouse_handler_); 184 DCHECK(!explicit_mouse_handler_);
185 185
186 bool hit_disabled_view = false; 186 bool hit_disabled_view = false;
187 // Walk up the tree until we find a view that wants the mouse event. 187 // Walk up the tree until we find a view that wants the mouse event.
188 for (mouse_pressed_handler_ = GetEventHandlerForPoint(e.location()); 188 for (mouse_pressed_handler_ = GetEventHandlerForPoint(e.location());
189 mouse_pressed_handler_ && (mouse_pressed_handler_ != this); 189 mouse_pressed_handler_ && (mouse_pressed_handler_ != this);
190 mouse_pressed_handler_ = mouse_pressed_handler_->parent()) { 190 mouse_pressed_handler_ = mouse_pressed_handler_->parent()) {
191 if (!mouse_pressed_handler_->IsEnabled()) { 191 if (!mouse_pressed_handler_->enabled()) {
192 // Disabled views should eat events instead of propagating them upwards. 192 // Disabled views should eat events instead of propagating them upwards.
193 hit_disabled_view = true; 193 hit_disabled_view = true;
194 break; 194 break;
195 } 195 }
196 196
197 // See if this view wants to handle the mouse press. 197 // See if this view wants to handle the mouse press.
198 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_); 198 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_);
199 199
200 // Remove the double-click flag if the handler is different than the 200 // Remove the double-click flag if the handler is different than the
201 // one which got the first click part of the double-click. 201 // one which got the first click part of the double-click.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 } 283 }
284 284
285 void RootView::OnMouseMoved(const MouseEvent& event) { 285 void RootView::OnMouseMoved(const MouseEvent& event) {
286 MouseEvent e(event, this); 286 MouseEvent e(event, this);
287 View* v = GetEventHandlerForPoint(e.location()); 287 View* v = GetEventHandlerForPoint(e.location());
288 // Find the first enabled view, or the existing move handler, whichever comes 288 // Find the first enabled view, or the existing move handler, whichever comes
289 // first. The check for the existing handler is because if a view becomes 289 // first. The check for the existing handler is because if a view becomes
290 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED 290 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED
291 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet. 291 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet.
292 while (v && !v->IsEnabled() && (v != mouse_move_handler_)) 292 while (v && !v->enabled() && (v != mouse_move_handler_))
293 v = v->parent(); 293 v = v->parent();
294 if (v && v != this) { 294 if (v && v != this) {
295 if (v != mouse_move_handler_) { 295 if (v != mouse_move_handler_) {
296 if (mouse_move_handler_ != NULL) 296 if (mouse_move_handler_ != NULL)
297 mouse_move_handler_->OnMouseExited(e); 297 mouse_move_handler_->OnMouseExited(e);
298 mouse_move_handler_ = v; 298 mouse_move_handler_ = v;
299 MouseEvent entered_event(e, this, mouse_move_handler_); 299 MouseEvent entered_event(e, this, mouse_move_handler_);
300 mouse_move_handler_->OnMouseEntered(entered_event); 300 mouse_move_handler_->OnMouseEntered(entered_event);
301 } 301 }
302 MouseEvent moved_event(e, this, mouse_move_handler_); 302 MouseEvent moved_event(e, this, mouse_move_handler_);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 status = ui::TOUCH_STATUS_SYNTH_MOUSE; 340 status = ui::TOUCH_STATUS_SYNTH_MOUSE;
341 if (status == ui::TOUCH_STATUS_END) 341 if (status == ui::TOUCH_STATUS_END)
342 touch_pressed_handler_ = NULL; 342 touch_pressed_handler_ = NULL;
343 return status; 343 return status;
344 } 344 }
345 345
346 // Walk up the tree until we find a view that wants the touch event. 346 // Walk up the tree until we find a view that wants the touch event.
347 for (touch_pressed_handler_ = GetEventHandlerForPoint(e.location()); 347 for (touch_pressed_handler_ = GetEventHandlerForPoint(e.location());
348 touch_pressed_handler_ && (touch_pressed_handler_ != this); 348 touch_pressed_handler_ && (touch_pressed_handler_ != this);
349 touch_pressed_handler_ = touch_pressed_handler_->parent()) { 349 touch_pressed_handler_ = touch_pressed_handler_->parent()) {
350 if (!touch_pressed_handler_->IsEnabled()) { 350 if (!touch_pressed_handler_->enabled()) {
351 // Disabled views eat events but are treated as not handled by the 351 // Disabled views eat events but are treated as not handled by the
352 // the GestureManager. 352 // the GestureManager.
353 status = ui::TOUCH_STATUS_UNKNOWN; 353 status = ui::TOUCH_STATUS_UNKNOWN;
354 break; 354 break;
355 } 355 }
356 356
357 // See if this view wants to handle the touch 357 // See if this view wants to handle the touch
358 TouchEvent touch_event(e, this, touch_pressed_handler_); 358 TouchEvent touch_event(e, this, touch_pressed_handler_);
359 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); 359 status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
360 360
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 446 }
447 447
448 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { 448 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) {
449 last_mouse_event_flags_ = event.flags(); 449 last_mouse_event_flags_ = event.flags();
450 last_mouse_event_x_ = event.x(); 450 last_mouse_event_x_ = event.x();
451 last_mouse_event_y_ = event.y(); 451 last_mouse_event_y_ = event.y();
452 } 452 }
453 453
454 } // namespace internal 454 } // namespace internal
455 } // namespace views 455 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/drop_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698