diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 23:17:20 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 23:17:20 +0000 |
commit | 2c831b235ec39e7e4258cfd93b735de06f079a0e (patch) | |
tree | f0a49df25f1d7736bd8483de7cf09794fc06f055 | |
parent | 05a1ba49bd770a52a3a84aa2ce6241b0e538d7da (diff) | |
download | chromium_src-2c831b235ec39e7e4258cfd93b735de06f079a0e.zip chromium_src-2c831b235ec39e7e4258cfd93b735de06f079a0e.tar.gz chromium_src-2c831b235ec39e7e4258cfd93b735de06f079a0e.tar.bz2 |
Clean up some event code:
Update some RootView event construction.
Fixup some *MouseExited/OnLeaveNotify codepaths.
Normalize event argument names.
Move View::ConvertPoint*Ancestor defs to private section.
Review URL: http://codereview.chromium.org/6685018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78121 0039d316-1c4b-4281-b951-d872f2087c98
41 files changed, 393 insertions, 393 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc index 184aa9d..922908a 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc @@ -53,13 +53,14 @@ class AutocompleteTextfield : public views::Textfield { autocomplete_edit_view_->HandleFocusOut(); } - virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE { - bool handled = views::Textfield::OnKeyPressed(e); - return autocomplete_edit_view_->HandleAfterKeyEvent(e, handled) || handled; + virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE { + bool handled = views::Textfield::OnKeyPressed(event); + return autocomplete_edit_view_->HandleAfterKeyEvent(event, handled) || + handled; } - virtual bool OnKeyReleased(const views::KeyEvent& e) OVERRIDE { - return autocomplete_edit_view_->HandleKeyReleaseEvent(e); + virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE { + return autocomplete_edit_view_->HandleKeyReleaseEvent(event); } virtual bool IsFocusable() const OVERRIDE { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 68211de..6adb0be 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -1007,12 +1007,13 @@ void AutocompleteEditViewWin::PasteAndGo(const string16& text) { } bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( - const views::KeyEvent& e) { - ui::KeyboardCode key = e.key_code(); + const views::KeyEvent& event) { + ui::KeyboardCode key = event.key_code(); // We don't process ALT + numpad digit as accelerators, they are used for // entering special characters. We do translate alt-home. - if (e.IsAltDown() && (key != ui::VKEY_HOME) && - views::NativeTextfieldWin::IsNumPadDigit(key, views::IsExtendedKey(e))) + if (event.IsAltDown() && (key != ui::VKEY_HOME) && + views::NativeTextfieldWin::IsNumPadDigit(key, + views::IsExtendedKey(event))) return true; // Skip accelerators for key combinations omnibox wants to crack. This list @@ -1033,15 +1034,16 @@ bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( case ui::VKEY_UP: case ui::VKEY_DOWN: - return !e.IsAltDown(); + return !event.IsAltDown(); case ui::VKEY_DELETE: case ui::VKEY_INSERT: - return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); + return !event.IsAltDown() && event.IsShiftDown() && + !event.IsControlDown(); case ui::VKEY_X: case ui::VKEY_V: - return !e.IsAltDown() && e.IsControlDown(); + return !event.IsAltDown() && event.IsControlDown(); case ui::VKEY_BACK: case ui::VKEY_OEM_PLUS: diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index fb6bfd5..e0b57f9 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -168,7 +168,7 @@ class AutocompleteEditViewWin // Called before an accelerator is processed to give us a chance to override // it. - bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); + bool SkipDefaultKeyEventProcessing(const views::KeyEvent& event); // Handler for external events passed in to us. The View that owns us may // send us events that we should treat as if they were events on us. diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index 722f298..3195eb1 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -130,14 +130,14 @@ void UpdateTouchPointPosition(const views::TouchEvent* event, tpoint->screenPosition.y = tpoint->position.y + origin.y(); } -void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& e, +void InitializeWebMouseEventFromViewsEvent(const views::LocatedEvent& event, const gfx::Point& origin, WebKit::WebMouseEvent* wmevent) { wmevent->timeStampSeconds = base::Time::Now().ToDoubleT(); - wmevent->modifiers = WebInputEventFlagsFromViewsEvent(e); + wmevent->modifiers = WebInputEventFlagsFromViewsEvent(event); - wmevent->windowX = wmevent->x = e.x(); - wmevent->windowY = wmevent->y = e.y(); + wmevent->windowX = wmevent->x = event.x(); + wmevent->windowY = wmevent->y = event.y(); wmevent->globalX = wmevent->x + origin.x(); wmevent->globalY = wmevent->y + origin.y(); } @@ -681,30 +681,31 @@ void RenderWidgetHostViewViews::OnMouseExited(const views::MouseEvent& event) { // Already generated synthetically by webkit. } -bool RenderWidgetHostViewViews::OnMouseWheel(const views::MouseWheelEvent& e) { +bool RenderWidgetHostViewViews::OnMouseWheel( + const views::MouseWheelEvent& event) { WebMouseWheelEvent wmwe; - InitializeWebMouseEventFromViewsEvent(e, GetMirroredPosition(), &wmwe); + InitializeWebMouseEventFromViewsEvent(event, GetMirroredPosition(), &wmwe); wmwe.type = WebKit::WebInputEvent::MouseWheel; wmwe.button = WebKit::WebMouseEvent::ButtonNone; // TODO(sadrul): How do we determine if it's a horizontal scroll? - wmwe.deltaY = e.offset(); + wmwe.deltaY = event.offset(); wmwe.wheelTicksY = wmwe.deltaY > 0 ? 1 : -1; GetRenderWidgetHost()->ForwardWheelEvent(wmwe); return true; } -bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& e) { - if (!ime_context_->FilterKeyEvent(e)) - ForwardKeyEvent(e); +bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent& event) { + if (!ime_context_->FilterKeyEvent(event)) + ForwardKeyEvent(event); return TRUE; } -bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& e) { - if (!ime_context_->FilterKeyEvent(e)) - ForwardKeyEvent(e); +bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent& event) { + if (!ime_context_->FilterKeyEvent(event)) + ForwardKeyEvent(event); return TRUE; } @@ -861,18 +862,18 @@ void RenderWidgetHostViewViews::ForwardWebKeyboardEvent( } views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( - const views::TouchEvent& e) { + const views::TouchEvent& event) { // Update the list of touch points first. WebKit::WebTouchPoint* point = NULL; TouchStatus status = TOUCH_STATUS_UNKNOWN; - switch (e.type()) { + switch (event.type()) { case ui::ET_TOUCH_PRESSED: // Add a new touch point. if (touch_event_.touchPointsLength < WebTouchEvent::touchPointsLengthCap) { point = &touch_event_.touchPoints[touch_event_.touchPointsLength++]; - point->id = e.identity(); + point->id = event.identity(); if (touch_event_.touchPointsLength == 1) { // A new touch sequence has started. @@ -892,7 +893,7 @@ views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( // simple loop should be sufficient. for (int i = 0; i < touch_event_.touchPointsLength; ++i) { point = touch_event_.touchPoints + i; - if (point->id == e.identity()) { + if (point->id == event.identity()) { break; } point = NULL; @@ -900,7 +901,7 @@ views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( break; } default: - DLOG(WARNING) << "Unknown touch event " << e.type(); + DLOG(WARNING) << "Unknown touch event " << event.type(); break; } @@ -911,16 +912,16 @@ views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( status = TOUCH_STATUS_CONTINUE; // Update the location and state of the point. - point->state = TouchPointStateFromEvent(&e); + point->state = TouchPointStateFromEvent(&event); if (point->state == WebKit::WebTouchPoint::StateMoved) { // It is possible for badly written touch drivers to emit Move events even // when the touch location hasn't changed. In such cases, consume the event // and pretend nothing happened. - if (point->position.x == e.x() && point->position.y == e.y()) { + if (point->position.x == event.x() && point->position.y == event.y()) { return status; } } - UpdateTouchPointPosition(&e, GetMirroredPosition(), point); + UpdateTouchPointPosition(&event, GetMirroredPosition(), point); // Mark the rest of the points as stationary. for (int i = 0; i < touch_event_.touchPointsLength; ++i) { @@ -931,14 +932,14 @@ views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( } // Update the type of the touch event. - touch_event_.type = TouchEventTypeFromEvent(&e); + touch_event_.type = TouchEventTypeFromEvent(&event); touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT(); // The event and all the touches have been updated. Dispatch. host_->ForwardTouchEvent(touch_event_); // If the touch was released, then remove it from the list of touch points. - if (e.type() == ui::ET_TOUCH_RELEASED) { + if (event.type() == ui::ET_TOUCH_RELEASED) { --touch_event_.touchPointsLength; for (int i = point - touch_event_.touchPoints; i < touch_event_.touchPointsLength; @@ -947,7 +948,7 @@ views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( } if (touch_event_.touchPointsLength == 0) status = TOUCH_STATUS_END; - } else if (e.type() == ui::ET_TOUCH_CANCELLED) { + } else if (event.type() == ui::ET_TOUCH_CANCELLED) { status = TOUCH_STATUS_CANCEL; } diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h index ec6c6fc..538c45a 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.h +++ b/chrome/browser/renderer_host/render_widget_host_view_views.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -101,14 +101,14 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled) OVERRIDE; - virtual void OnMouseMoved(const views::MouseEvent& e) OVERRIDE; + virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; - virtual bool OnMouseWheel(const views::MouseWheelEvent& e) OVERRIDE; + virtual bool OnMouseWheel(const views::MouseWheelEvent& event) OVERRIDE; // Views keyboard events, overridden from views::View. - virtual bool OnKeyPressed(const views::KeyEvent &e) OVERRIDE; - virtual bool OnKeyReleased(const views::KeyEvent &e) OVERRIDE; + virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; + virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; @@ -120,7 +120,8 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, void ForwardKeyEvent(const views::KeyEvent& event); // Views touch events, overridden from views::View. - virtual View::TouchStatus OnTouchEvent(const views::TouchEvent& e) OVERRIDE; + virtual View::TouchStatus OnTouchEvent( + const views::TouchEvent& event) OVERRIDE; private: friend class RenderWidgetHostViewViewsWidget; diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h index e29779a..2373d29 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h @@ -77,12 +77,13 @@ class AutocompletePopupContentsView : public views::View, virtual void PaintChildren(gfx::Canvas* canvas); virtual void Layout(); virtual void LayoutChildren(); - virtual void OnMouseEntered(const views::MouseEvent& event); - virtual void OnMouseMoved(const views::MouseEvent& event); - virtual void OnMouseExited(const views::MouseEvent& event); - virtual bool OnMousePressed(const views::MouseEvent& event); - virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); - virtual bool OnMouseDragged(const views::MouseEvent& event); + virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; + virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const views::MouseEvent& event, + bool canceled) OVERRIDE; + virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; virtual views::View* GetEventHandlerForPoint(const gfx::Point& point); protected: diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index 984590b..faf7879 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -209,10 +209,10 @@ bool BrowserActionButton::Activate() { return false; } -bool BrowserActionButton::OnMousePressed(const views::MouseEvent& e) { - if (!e.IsRightMouseButton()) { +bool BrowserActionButton::OnMousePressed(const views::MouseEvent& event) { + if (!event.IsRightMouseButton()) { return IsPopup() ? - MenuButton::OnMousePressed(e) : TextButton::OnMousePressed(e); + MenuButton::OnMousePressed(event) : TextButton::OnMousePressed(event); } // Get the top left point of this button in screen coordinates. @@ -226,27 +226,27 @@ bool BrowserActionButton::OnMousePressed(const views::MouseEvent& e) { return false; } -void BrowserActionButton::OnMouseReleased(const views::MouseEvent& e, +void BrowserActionButton::OnMouseReleased(const views::MouseEvent& event, bool canceled) { if (IsPopup() || showing_context_menu_) { // TODO(erikkay) this never actually gets called (probably because of the // loss of focus). - MenuButton::OnMouseReleased(e, canceled); + MenuButton::OnMouseReleased(event, canceled); } else { - TextButton::OnMouseReleased(e, canceled); + TextButton::OnMouseReleased(event, canceled); } } -bool BrowserActionButton::OnKeyReleased(const views::KeyEvent& e) { +bool BrowserActionButton::OnKeyReleased(const views::KeyEvent& event) { return IsPopup() ? - MenuButton::OnKeyReleased(e) : TextButton::OnKeyReleased(e); + MenuButton::OnKeyReleased(event) : TextButton::OnKeyReleased(event); } -void BrowserActionButton::OnMouseExited(const views::MouseEvent& e) { +void BrowserActionButton::OnMouseExited(const views::MouseEvent& event) { if (IsPopup() || showing_context_menu_) - MenuButton::OnMouseExited(e); + MenuButton::OnMouseExited(event); else - TextButton::OnMouseExited(e); + TextButton::OnMouseExited(event); } void BrowserActionButton::ShowContextMenu(const gfx::Point& p, diff --git a/chrome/browser/ui/views/browser_actions_container.h b/chrome/browser/ui/views/browser_actions_container.h index e951ddb..d2e1853 100644 --- a/chrome/browser/ui/views/browser_actions_container.h +++ b/chrome/browser/ui/views/browser_actions_container.h @@ -75,31 +75,37 @@ class BrowserActionButton : public views::MenuButton, const SkBitmap& default_icon() const { return default_icon_; } // Overridden from views::View: - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); + virtual void ViewHierarchyChanged(bool is_add, + View* parent, + View* child) OVERRIDE; // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* sender, const views::Event& event); + virtual void ButtonPressed(views::Button* sender, + const views::Event& event) OVERRIDE; // Overridden from ImageLoadingTracker. - virtual void OnImageLoaded( - SkBitmap* image, const ExtensionResource& resource, int index); + virtual void OnImageLoaded(SkBitmap* image, + const ExtensionResource& resource, + int index) OVERRIDE; // Overridden from NotificationObserver: virtual void Observe(NotificationType type, const NotificationSource& source, - const NotificationDetails& details); + const NotificationDetails& details) OVERRIDE; // MenuButton behavior overrides. These methods all default to TextButton // behavior unless this button is a popup. In that case, it uses MenuButton // behavior. MenuButton has the notion of a child popup being shown where the // button will stay in the pushed state until the "menu" (a popup in this // case) is dismissed. - virtual bool Activate(); - virtual bool OnMousePressed(const views::MouseEvent& e); - virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); - virtual bool OnKeyReleased(const views::KeyEvent& e); - virtual void OnMouseExited(const views::MouseEvent& event); - virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture); + virtual bool Activate() OVERRIDE; + virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const views::MouseEvent& event, + bool canceled) OVERRIDE; + virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE; + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual void ShowContextMenu(const gfx::Point& p, + bool is_mouse_gesture) OVERRIDE; // Does this button's action have a popup? virtual bool IsPopup(); diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc index eaafa09..1c8de0f 100644 --- a/chrome/browser/ui/views/download_item_view.cc +++ b/chrome/browser/ui/views/download_item_view.cc @@ -891,12 +891,13 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) { return true; } -bool DownloadItemView::OnKeyPressed(const views::KeyEvent& e) { +bool DownloadItemView::OnKeyPressed(const views::KeyEvent& event) { // Key press should not activate us in dangerous mode. if (IsDangerousMode()) return true; - if (e.key_code() == ui::VKEY_SPACE || e.key_code() == ui::VKEY_RETURN) { + if (event.key_code() == ui::VKEY_SPACE || + event.key_code() == ui::VKEY_RETURN) { OpenDownload(); return true; } diff --git a/chrome/browser/ui/views/download_item_view.h b/chrome/browser/ui/views/download_item_view.h index d244b66..97f2b2aa 100644 --- a/chrome/browser/ui/views/download_item_view.h +++ b/chrome/browser/ui/views/download_item_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -76,7 +76,7 @@ class DownloadItemView : public views::ButtonListener, virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled) OVERRIDE; virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; - virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE; + virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index de96fef..29cba84 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -969,14 +969,15 @@ std::string LocationBarView::GetClassName() const { return kViewClassName; } -bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { +bool LocationBarView::SkipDefaultKeyEventProcessing( + const views::KeyEvent& event) { #if defined(OS_WIN) - if (views::FocusManager::IsTabTraversalKeyEvent(e)) { + if (views::FocusManager::IsTabTraversalKeyEvent(event)) { if (HasValidSuggestText()) { // Return true so that the edit sees the tab and commits the suggestion. return true; } - if (keyword_hint_view_->IsVisible() && !e.IsShiftDown()) { + if (keyword_hint_view_->IsVisible() && !event.IsShiftDown()) { // Return true so the edit gets the tab event and enters keyword mode. return true; } @@ -992,7 +993,7 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { return true; } - return location_entry_->SkipDefaultKeyEventProcessing(e); + return location_entry_->SkipDefaultKeyEventProcessing(event); #else // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in // src/views/focus/focus_manager.cc for details. diff --git a/chrome/browser/ui/views/reload_button.cc b/chrome/browser/ui/views/reload_button.cc index 87a88b7..da60cd1 100644 --- a/chrome/browser/ui/views/reload_button.cc +++ b/chrome/browser/ui/views/reload_button.cc @@ -115,7 +115,7 @@ void ReloadButton::ButtonPressed(views::Button* /* button */, //////////////////////////////////////////////////////////////////////////////// // ReloadButton, View overrides: -void ReloadButton::OnMouseExited(const views::MouseEvent& e) { +void ReloadButton::OnMouseExited(const views::MouseEvent& event) { ChangeMode(intended_mode_, true); if (state() != BS_DISABLED) SetState(BS_NORMAL); diff --git a/chrome/browser/ui/views/reload_button.h b/chrome/browser/ui/views/reload_button.h index d83eeeb..3183673ed 100644 --- a/chrome/browser/ui/views/reload_button.h +++ b/chrome/browser/ui/views/reload_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,11 +39,12 @@ class ReloadButton : public views::ToggleImageButton, // Overridden from views::ButtonListener: virtual void ButtonPressed(views::Button* /* button */, - const views::Event& event); + const views::Event& event) OVERRIDE; // Overridden from views::View: - virtual void OnMouseExited(const views::MouseEvent& e); - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, + std::wstring* tooltip) OVERRIDE; private: friend class ReloadButtonTest; diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index 4b0389f..3ee7e76 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -49,7 +49,7 @@ class TabCloseButton : public views::ImageButton { } virtual ~TabCloseButton() {} - virtual bool OnMousePressed(const views::MouseEvent& event) { + virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { bool handled = ImageButton::OnMousePressed(event); // Explicitly mark midle-mouse clicks as non-handled to ensure the tab // sees them. @@ -59,12 +59,12 @@ class TabCloseButton : public views::ImageButton { // We need to let the parent know about mouse state so that it // can highlight itself appropriately. Note that Exit events // fire before Enter events, so this works. - virtual void OnMouseEntered(const views::MouseEvent& event) { + virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE { CustomButton::OnMouseEntered(event); parent()->OnMouseEntered(event); } - virtual void OnMouseExited(const views::MouseEvent& event) { + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE { CustomButton::OnMouseExited(event); parent()->OnMouseExited(event); } @@ -268,7 +268,7 @@ bool BaseTab::IsCloseable() const { return controller() ? controller()->IsTabCloseable(this) : true; } -void BaseTab::OnMouseEntered(const views::MouseEvent& e) { +void BaseTab::OnMouseEntered(const views::MouseEvent& event) { if (!hover_animation_.get()) { hover_animation_.reset(new ui::SlideAnimation(this)); hover_animation_->SetContainer(animation_container_.get()); @@ -278,7 +278,7 @@ void BaseTab::OnMouseEntered(const views::MouseEvent& e) { hover_animation_->Show(); } -void BaseTab::OnMouseExited(const views::MouseEvent& e) { +void BaseTab::OnMouseExited(const views::MouseEvent& event) { hover_animation_->SetTweenType(ui::Tween::EASE_IN); hover_animation_->Hide(); } diff --git a/chrome/browser/ui/views/tabs/base_tab.h b/chrome/browser/ui/views/tabs/base_tab.h index c237bdb..9ed52d2 100644 --- a/chrome/browser/ui/views/tabs/base_tab.h +++ b/chrome/browser/ui/views/tabs/base_tab.h @@ -89,8 +89,8 @@ class BaseTab : public ui::AnimationDelegate, virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) - OVERRIDE; + virtual bool GetTooltipText(const gfx::Point& p, + std::wstring* tooltip) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual ThemeProvider* GetThemeProvider() const OVERRIDE; diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 341e742..ad9937a9 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -350,8 +350,8 @@ bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) { return true; } -void Tab::OnMouseMoved(const views::MouseEvent& e) { - hover_point_ = e.location(); +void Tab::OnMouseMoved(const views::MouseEvent& event) { + hover_point_ = event.location(); // We need to redraw here because otherwise the hover glow does not update // and follow the new mouse position. SchedulePaint(); diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index 7bc5910..cdd93c3 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -41,12 +41,12 @@ ButtonDropDown::~ButtonDropDown() { // //////////////////////////////////////////////////////////////////////////////// -bool ButtonDropDown::OnMousePressed(const MouseEvent& e) { - if (IsEnabled() && IsTriggerableEvent(e) && HitTest(e.location())) { +bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { + if (IsEnabled() && IsTriggerableEvent(event) && HitTest(event.location())) { // Store the y pos of the mouse coordinates so we can use them later to // determine if the user dragged the mouse down (which should pop up the // drag down menu immediately, instead of waiting for the timer) - y_position_on_lbuttondown_ = e.y(); + y_position_on_lbuttondown_ = event.y(); // Schedule a task that will show the menu. MessageLoop::current()->PostDelayedTask(FROM_HERE, @@ -54,37 +54,37 @@ bool ButtonDropDown::OnMousePressed(const MouseEvent& e) { GetWidget()->GetNativeView()), kMenuTimerDelay); } - return ImageButton::OnMousePressed(e); + return ImageButton::OnMousePressed(event); } -void ButtonDropDown::OnMouseReleased(const MouseEvent& e, bool canceled) { +void ButtonDropDown::OnMouseReleased(const MouseEvent& event, bool canceled) { // Showing the drop down results in a MouseReleased with a canceled drag, we // need to ignore it. - if (!canceled && (IsTriggerableEvent(e) || - (e.IsRightMouseButton() && !HitTest(e.location())))) { - ImageButton::OnMouseReleased(e, canceled); + if (!canceled && (IsTriggerableEvent(event) || + (event.IsRightMouseButton() && !HitTest(event.location())))) { + ImageButton::OnMouseReleased(event, canceled); } if (canceled) return; - if (IsTriggerableEvent(e)) + if (IsTriggerableEvent(event)) show_menu_factory_.RevokeAll(); - if (IsEnabled() && e.IsRightMouseButton() && HitTest(e.location())) { + if (IsEnabled() && event.IsRightMouseButton() && HitTest(event.location())) { show_menu_factory_.RevokeAll(); ShowDropDownMenu(GetWidget()->GetNativeView()); } } -bool ButtonDropDown::OnMouseDragged(const MouseEvent& e) { - bool result = ImageButton::OnMouseDragged(e); +bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) { + bool result = ImageButton::OnMouseDragged(event); if (!show_menu_factory_.empty()) { // If the mouse is dragged to a y position lower than where it was when // clicked then we should not wait for the menu to appear but show // it immediately. - if (e.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) { + if (event.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) { show_menu_factory_.RevokeAll(); ShowDropDownMenu(GetWidget()->GetNativeView()); } @@ -93,7 +93,7 @@ bool ButtonDropDown::OnMouseDragged(const MouseEvent& e) { return result; } -void ButtonDropDown::OnMouseExited(const MouseEvent& e) { +void ButtonDropDown::OnMouseExited(const MouseEvent& event) { // Starting a drag results in a MouseExited, we need to ignore it. // A right click release triggers an exit event. We want to // remain in a PUSHED state until the drop down menu closes. @@ -114,11 +114,11 @@ void ButtonDropDown::ShowContextMenu(const gfx::Point& p, SetState(BS_HOT); } -bool ButtonDropDown::ShouldEnterPushedState(const MouseEvent& e) { +bool ButtonDropDown::ShouldEnterPushedState(const MouseEvent& event) { // Enter PUSHED state on press with Left or Right mouse button. Remain // in this state while the context menu is open. return ((ui::EF_LEFT_BUTTON_DOWN | - ui::EF_RIGHT_BUTTON_DOWN) & e.flags()) != 0; + ui::EF_RIGHT_BUTTON_DOWN) & event.flags()) != 0; } void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h index 32f2c5c..fe558e1 100644 --- a/views/controls/button/button_dropdown.h +++ b/views/controls/button/button_dropdown.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -30,22 +30,22 @@ class ButtonDropDown : public ImageButton { private: // Overridden from CustomButton - virtual bool OnMousePressed(const MouseEvent& e); - virtual void OnMouseReleased(const MouseEvent& e, bool canceled); - virtual bool OnMouseDragged(const MouseEvent& e); - virtual void OnMouseExited(const MouseEvent& e); + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; // Overridden from View. Used to display the right-click menu, as triggered // by the keyboard, for instance. Using the member function ShowDropDownMenu // for the actual display. virtual void ShowContextMenu(const gfx::Point& p, - bool is_mouse_gesture); + bool is_mouse_gesture) OVERRIDE; // Overridden from CustomButton. Returns true if the button should become // pressed when a user holds the mouse down over the button. For this // implementation, both left and right mouse buttons can trigger a change // to the PUSHED state. - virtual bool ShouldEnterPushedState(const MouseEvent& e); + virtual bool ShouldEnterPushedState(const MouseEvent& event) OVERRIDE; // Internal function to show the dropdown menu void ShowDropDownMenu(gfx::NativeView window); diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 2a34cc5..45aea1c 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -122,32 +122,32 @@ void Checkbox::OnPaintFocusBorder(gfx::Canvas* canvas) { // Our focus border is rendered by the label, so we don't do anything here. } -void Checkbox::OnMouseEntered(const MouseEvent& e) { - native_wrapper_->SetPushed(HitTestLabel(e)); +void Checkbox::OnMouseEntered(const MouseEvent& event) { + native_wrapper_->SetPushed(HitTestLabel(event)); } -void Checkbox::OnMouseMoved(const MouseEvent& e) { - native_wrapper_->SetPushed(HitTestLabel(e)); +void Checkbox::OnMouseMoved(const MouseEvent& event) { + native_wrapper_->SetPushed(HitTestLabel(event)); } -void Checkbox::OnMouseExited(const MouseEvent& e) { +void Checkbox::OnMouseExited(const MouseEvent& event) { native_wrapper_->SetPushed(false); } -bool Checkbox::OnMousePressed(const MouseEvent& e) { - native_wrapper_->SetPushed(HitTestLabel(e)); +bool Checkbox::OnMousePressed(const MouseEvent& event) { + native_wrapper_->SetPushed(HitTestLabel(event)); return true; } -void Checkbox::OnMouseReleased(const MouseEvent& e, bool canceled) { +void Checkbox::OnMouseReleased(const MouseEvent& event, bool canceled) { native_wrapper_->SetPushed(false); - if (!canceled && HitTestLabel(e)) { + if (!canceled && HitTestLabel(event)) { SetChecked(!checked()); ButtonPressed(); } } -bool Checkbox::OnMouseDragged(const MouseEvent& e) { +bool Checkbox::OnMouseDragged(const MouseEvent& event) { return false; } @@ -193,8 +193,8 @@ void Checkbox::SetLabel(const std::wstring& label) { //////////////////////////////////////////////////////////////////////////////// // Checkbox, protected: -bool Checkbox::HitTestLabel(const MouseEvent& e) { - gfx::Point tmp(e.location()); +bool Checkbox::HitTestLabel(const MouseEvent& event) { + gfx::Point tmp(event.location()); ConvertPointToView(this, label_, &tmp); return label_->HitTest(tmp); } diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index 801b0fd..75660b4 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -47,12 +47,12 @@ class Checkbox : public NativeButton { virtual void Layout() OVERRIDE; virtual void SetEnabled(bool enabled) OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; - virtual void OnMouseEntered(const MouseEvent& e) OVERRIDE; - virtual void OnMouseMoved(const MouseEvent& e) OVERRIDE; - virtual void OnMouseExited(const MouseEvent& e) OVERRIDE; - virtual bool OnMousePressed(const MouseEvent& e) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& e, bool canceled) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& e) OVERRIDE; + virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; + virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; @@ -71,7 +71,7 @@ class Checkbox : public NativeButton { // Returns true if the event (in Checkbox coordinates) is within the bounds of // the label. - bool HitTestLabel(const MouseEvent& e); + bool HitTestLabel(const MouseEvent& event); private: // Called from the constructor to create and configure the checkbox label. diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 04ee51a..2e7b4cdd 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -125,8 +125,8 @@ CustomButton::CustomButton(ButtonListener* listener) hover_animation_->SetSlideDuration(kHoverFadeDurationMs); } -bool CustomButton::IsTriggerableEvent(const MouseEvent& e) { - return (triggerable_event_flags_ & e.flags()) != 0; +bool CustomButton::IsTriggerableEvent(const MouseEvent& event) { + return (triggerable_event_flags_ & event.flags()) != 0; } //////////////////////////////////////////////////////////////////////////////// @@ -143,9 +143,9 @@ bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { return true; } -bool CustomButton::OnMousePressed(const MouseEvent& e) { +bool CustomButton::OnMousePressed(const MouseEvent& event) { if (state_ != BS_DISABLED) { - if (ShouldEnterPushedState(e) && HitTest(e.location())) + if (ShouldEnterPushedState(event) && HitTest(event.location())) SetState(BS_PUSHED); if (request_focus_on_press_) RequestFocus(); @@ -153,74 +153,74 @@ bool CustomButton::OnMousePressed(const MouseEvent& e) { return true; } -bool CustomButton::OnMouseDragged(const MouseEvent& e) { +bool CustomButton::OnMouseDragged(const MouseEvent& event) { if (state_ != BS_DISABLED) { - if (HitTest(e.location())) - SetState(ShouldEnterPushedState(e) ? BS_PUSHED : BS_HOT); + if (HitTest(event.location())) + SetState(ShouldEnterPushedState(event) ? BS_PUSHED : BS_HOT); else SetState(BS_NORMAL); } return true; } -void CustomButton::OnMouseReleased(const MouseEvent& e, bool canceled) { +void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) { // Starting a drag results in a MouseReleased, we need to ignore it. if ((state_ == BS_DISABLED) || InDrag()) return; - if (!HitTest(e.location())) { + if (!HitTest(event.location())) { SetState(BS_NORMAL); return; } SetState(BS_HOT); - if (!canceled && IsTriggerableEvent(e)) { - NotifyClick(e); + if (!canceled && IsTriggerableEvent(event)) { + NotifyClick(event); // NOTE: We may be deleted at this point (by the listener's notification // handler). } } -void CustomButton::OnMouseEntered(const MouseEvent& e) { +void CustomButton::OnMouseEntered(const MouseEvent& event) { if (state_ != BS_DISABLED) SetState(BS_HOT); } -void CustomButton::OnMouseMoved(const MouseEvent& e) { +void CustomButton::OnMouseMoved(const MouseEvent& event) { if (state_ != BS_DISABLED) - SetState(HitTest(e.location()) ? BS_HOT : BS_NORMAL); + SetState(HitTest(event.location()) ? BS_HOT : BS_NORMAL); } -void CustomButton::OnMouseExited(const MouseEvent& e) { +void CustomButton::OnMouseExited(const MouseEvent& event) { // Starting a drag results in a MouseExited, we need to ignore it. if (state_ != BS_DISABLED && !InDrag()) SetState(BS_NORMAL); } -bool CustomButton::OnKeyPressed(const KeyEvent& e) { +bool CustomButton::OnKeyPressed(const KeyEvent& event) { if (state_ == BS_DISABLED) return false; // Space sets button state to pushed. Enter clicks the button. This matches // the Windows native behavior of buttons, where Space clicks the button on // KeyRelease and Enter clicks the button on KeyPressed. - if (e.key_code() == ui::VKEY_SPACE) { + if (event.key_code() == ui::VKEY_SPACE) { SetState(BS_PUSHED); - } else if (e.key_code() == ui::VKEY_RETURN) { + } else if (event.key_code() == ui::VKEY_RETURN) { SetState(BS_NORMAL); - NotifyClick(e); + NotifyClick(event); } else { return false; } return true; } -bool CustomButton::OnKeyReleased(const KeyEvent& e) { - if ((state_ == BS_DISABLED) || (e.key_code() != ui::VKEY_SPACE)) +bool CustomButton::OnKeyReleased(const KeyEvent& event) { + if ((state_ == BS_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) return false; SetState(BS_NORMAL); - NotifyClick(e); + NotifyClick(event); return true; } @@ -271,8 +271,8 @@ void CustomButton::AnimationProgressed(const ui::Animation* animation) { SchedulePaint(); } -bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { - return IsTriggerableEvent(e); +bool CustomButton::ShouldEnterPushedState(const MouseEvent& event) { + return IsTriggerableEvent(event); } } // namespace views diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h index 6dcabc9..3f6f22a 100644 --- a/views/controls/button/custom_button.h +++ b/views/controls/button/custom_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -87,18 +87,18 @@ class CustomButton : public Button, // Returns true if the event is one that can trigger notifying the listener. // This implementation returns true if the left mouse button is down. - virtual bool IsTriggerableEvent(const MouseEvent& e); + virtual bool IsTriggerableEvent(const MouseEvent& event); // Overridden from View: virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; - virtual bool OnMousePressed(const MouseEvent& e) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& e) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& e, bool canceled) OVERRIDE; - virtual void OnMouseEntered(const MouseEvent& e) OVERRIDE; - virtual void OnMouseMoved(const MouseEvent& e) OVERRIDE; - virtual void OnMouseExited(const MouseEvent& e) OVERRIDE; - virtual bool OnKeyPressed(const KeyEvent& e) OVERRIDE; - virtual bool OnKeyReleased(const KeyEvent& e) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; + virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; + virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; virtual void OnDragDone() OVERRIDE; virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; @@ -114,8 +114,8 @@ class CustomButton : public Button, // Returns true if the button should become pressed when the user // holds the mouse down over the button. For this implementation, - // we simply return IsTriggerableEvent(e). - virtual bool ShouldEnterPushedState(const MouseEvent& e); + // we simply return IsTriggerableEvent(event). + virtual bool ShouldEnterPushedState(const MouseEvent& event); // The button state (defined in implementation) ButtonState state_; diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index a3859ba..822ca39 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -188,13 +188,13 @@ bool MenuButton::Activate() { return true; } -bool MenuButton::OnMousePressed(const MouseEvent& e) { +bool MenuButton::OnMousePressed(const MouseEvent& event) { RequestFocus(); if (state() != BS_DISABLED) { // If we're draggable (GetDragOperations returns a non-zero value), then // don't pop on press, instead wait for release. - if (e.IsOnlyLeftMouseButton() && HitTest(e.location()) && - GetDragOperations(e.location()) == ui::DragDropTypes::DRAG_NONE) { + if (event.IsOnlyLeftMouseButton() && HitTest(event.location()) && + GetDragOperations(event.location()) == ui::DragDropTypes::DRAG_NONE) { TimeDelta delta = Time::Now() - menu_closed_time_; int64 delta_in_milliseconds = delta.InMilliseconds(); if (delta_in_milliseconds > kMinimumTimeBetweenButtonClicks) { @@ -205,23 +205,22 @@ bool MenuButton::OnMousePressed(const MouseEvent& e) { return true; } -void MenuButton::OnMouseReleased(const MouseEvent& e, - bool canceled) { +void MenuButton::OnMouseReleased(const MouseEvent& event, bool canceled) { // Explicitly test for left mouse button to show the menu. If we tested for // !IsTriggerableEvent it could lead to a situation where we end up showing // the menu and context menu (this would happen if the right button is not // triggerable and there's a context menu). - if (GetDragOperations(e.location()) != ui::DragDropTypes::DRAG_NONE && + if (GetDragOperations(event.location()) != ui::DragDropTypes::DRAG_NONE && state() != BS_DISABLED && !canceled && !InDrag() && - e.IsOnlyLeftMouseButton() && HitTest(e.location())) { + event.IsOnlyLeftMouseButton() && HitTest(event.location())) { Activate(); } else { - TextButton::OnMouseReleased(e, canceled); + TextButton::OnMouseReleased(event, canceled); } } -bool MenuButton::OnKeyPressed(const KeyEvent& e) { - switch (e.key_code()) { +bool MenuButton::OnKeyPressed(const KeyEvent& event) { + switch (event.key_code()) { case ui::VKEY_SPACE: case ui::VKEY_RETURN: case ui::VKEY_UP: @@ -237,7 +236,7 @@ bool MenuButton::OnKeyPressed(const KeyEvent& e) { return false; } -bool MenuButton::OnKeyReleased(const KeyEvent& e) { +bool MenuButton::OnKeyReleased(const KeyEvent& event) { // Override CustomButton's implementation, which presses the button when // you press space and clicks it when you release space. For a MenuButton // we always activate the menu on key press. diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h index eb5ca9c..d9622e4 100644 --- a/views/controls/button/menu_button.h +++ b/views/controls/button/menu_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,17 +51,17 @@ class MenuButton : public TextButton { // These methods are overriden to implement a simple push button // behavior. - virtual bool OnMousePressed(const MouseEvent& e); - virtual void OnMouseReleased(const MouseEvent& e, bool canceled); - virtual void OnMouseExited(const MouseEvent& event); - virtual bool OnKeyPressed(const KeyEvent& e); - virtual bool OnKeyReleased(const KeyEvent& e); + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; + virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; // Accessibility accessors, overridden from View. virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; // Returns views/MenuButton. - virtual std::string GetClassName() const; + virtual std::string GetClassName() const OVERRIDE; // Accessors for menu_offset_. const gfx::Point& menu_offset() const { diff --git a/views/controls/label.cc b/views/controls/label.cc index 21510af..c422ad0 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -200,8 +200,8 @@ bool Label::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { return false; } -void Label::OnMouseMoved(const MouseEvent& e) { - UpdateContainsMouse(e); +void Label::OnMouseMoved(const MouseEvent& event) { + UpdateContainsMouse(event); } void Label::OnMouseEntered(const MouseEvent& event) { diff --git a/views/controls/label.h b/views/controls/label.h index 0a2118e..7d8c64d 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -153,7 +153,7 @@ class Label : public View { // Mouse enter/exit are overridden to render mouse over background color. // These invoke SetContainsMouse as necessary. - virtual void OnMouseMoved(const MouseEvent& e) OVERRIDE; + virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 62f41e5..baabf69 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1025,13 +1025,14 @@ void MenuController::Accept(MenuItemView* item, int mouse_event_flags) { result_mouse_event_flags_ = mouse_event_flags; } -bool MenuController::ShowSiblingMenu(SubmenuView* source, const MouseEvent& e) { +bool MenuController::ShowSiblingMenu(SubmenuView* source, + const MouseEvent& event) { if (!menu_stack_.empty() || !menu_button_) return false; View* source_view = source->GetScrollViewContainer(); - if (e.x() >= 0 && e.x() < source_view->width() && e.y() >= 0 && - e.y() < source_view->height()) { + if (event.x() >= 0 && event.x() < source_view->width() && event.y() >= 0 && + event.y() < source_view->height()) { // The mouse is over the menu, no need to continue. return false; } @@ -1042,7 +1043,7 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, const MouseEvent& e) { // The user moved the mouse outside the menu and over the owning window. See // if there is a sibling menu we should show. - gfx::Point screen_point(e.location()); + gfx::Point screen_point(event.location()); View::ConvertPointToScreen(source_view, &screen_point); MenuItemView::AnchorPosition anchor; bool has_mnemonics; @@ -1787,10 +1788,9 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, } if (target != active_mouse_view_) { if (active_mouse_view_) { + // TODO(msw): Revise api and uses with OnMouseCaptureLost (like ui/views). // Send a mouse release with cancel set to true. - MouseEvent release_event(ui::ET_MOUSE_RELEASED, -1, -1, 0); - active_mouse_view_->OnMouseReleased(release_event, true); - + active_mouse_view_->OnMouseReleased(event, true); active_mouse_view_ = NULL; } active_mouse_view_ = target; diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index dfd68b4..3838c45 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -238,7 +238,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { // when blocking. This schedules the loop to quit. void Accept(MenuItemView* item, int mouse_event_flags); - bool ShowSiblingMenu(SubmenuView* source, const MouseEvent& e); + bool ShowSiblingMenu(SubmenuView* source, const MouseEvent& event); // Closes all menus, including any menus of nested invocations of Run. void CloseAllNestedMenus(); diff --git a/views/controls/menu/menu_host_root_view.cc b/views/controls/menu/menu_host_root_view.cc index cc0124c..bb791fc 100644 --- a/views/controls/menu/menu_host_root_view.cc +++ b/views/controls/menu/menu_host_root_view.cc @@ -66,17 +66,17 @@ void MenuHostRootView::OnMouseMoved(const MouseEvent& event) { GetMenuController()->OnMouseMoved(submenu_, event); } -bool MenuHostRootView::OnMouseWheel(const MouseWheelEvent& e) { +bool MenuHostRootView::OnMouseWheel(const MouseWheelEvent& event) { // RootView::OnMouseWheel forwards to the focused view. We don't have a // focused view, so we need to override this then forward to the menu. - return submenu_->OnMouseWheel(e); + return submenu_->OnMouseWheel(event); } -void MenuHostRootView::ProcessOnMouseExited() { +void MenuHostRootView::OnMouseExited(const MouseEvent& event) { if (suspend_events_) return; - RootView::ProcessOnMouseExited(); + RootView::OnMouseExited(event); } MenuController* MenuHostRootView::GetMenuController() { diff --git a/views/controls/menu/menu_host_root_view.h b/views/controls/menu/menu_host_root_view.h index 00648b4..f989170 100644 --- a/views/controls/menu/menu_host_root_view.h +++ b/views/controls/menu/menu_host_root_view.h @@ -32,8 +32,8 @@ class MenuHostRootView : public RootView { virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; - virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; - virtual void ProcessOnMouseExited() OVERRIDE; + virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; private: // Returns the MenuController for this MenuHostRootView. diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/bitmap_scroll_bar.h index d0138b4..839e872 100644 --- a/views/controls/scrollbar/bitmap_scroll_bar.h +++ b/views/controls/scrollbar/bitmap_scroll_bar.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -95,33 +95,34 @@ class BitmapScrollBar : public ScrollBar, void ScrollByContentsOffset(int contents_offset); // View overrides: - virtual gfx::Size GetPreferredSize(); - virtual void OnPaint(gfx::Canvas* canvas); - virtual void Layout(); - virtual bool OnMousePressed(const MouseEvent& event); - virtual void OnMouseReleased(const MouseEvent& event, bool canceled); - virtual bool OnMouseWheel(const MouseWheelEvent& event); - virtual bool OnKeyPressed(const KeyEvent& event); + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + virtual void Layout() OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; + virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; // BaseButton::ButtonListener overrides: - virtual void ButtonPressed(Button* sender, const views::Event& event); + virtual void ButtonPressed(Button* sender, + const views::Event& event) OVERRIDE; // ScrollBar overrides: virtual void Update(int viewport_size, int content_size, - int contents_scroll_offset); - virtual int GetLayoutSize() const; - virtual int GetPosition() const; + int contents_scroll_offset) OVERRIDE; + virtual int GetLayoutSize() const OVERRIDE; + virtual int GetPosition() const OVERRIDE; // ContextMenuController overrides. virtual void ShowContextMenuForView(View* source, const gfx::Point& p, - bool is_mouse_gesture); + bool is_mouse_gesture) OVERRIDE; // Menu::Delegate overrides: - virtual std::wstring GetLabel(int id) const; - virtual bool IsCommandEnabled(int id) const; - virtual void ExecuteCommand(int id); + virtual std::wstring GetLabel(int id) const OVERRIDE; + virtual bool IsCommandEnabled(int id) const OVERRIDE; + virtual void ExecuteCommand(int id) OVERRIDE; private: // Called when the mouse is pressed down in the track area. diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 443cc6e..0cc8700 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -352,11 +352,11 @@ size_t NativeTextfieldWin::GetCursorPosition() const { return 0U; } -bool NativeTextfieldWin::HandleKeyPressed(const views::KeyEvent& e) { +bool NativeTextfieldWin::HandleKeyPressed(const views::KeyEvent& event) { return false; } -bool NativeTextfieldWin::HandleKeyReleased(const views::KeyEvent& e) { +bool NativeTextfieldWin::HandleKeyReleased(const views::KeyEvent& event) { return false; } diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h index bea98c2..7946a00 100644 --- a/views/controls/textfield/native_textfield_win.h +++ b/views/controls/textfield/native_textfield_win.h @@ -82,8 +82,8 @@ class NativeTextfieldWin virtual void GetSelectedRange(TextRange* range) const OVERRIDE; virtual void SelectRange(const TextRange& range) OVERRIDE; virtual size_t GetCursorPosition() const OVERRIDE; - virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE; - virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE; + virtual bool HandleKeyPressed(const views::KeyEvent& event) OVERRIDE; + virtual bool HandleKeyReleased(const views::KeyEvent& event) OVERRIDE; virtual void HandleFocus() OVERRIDE; virtual void HandleBlur() OVERRIDE; diff --git a/views/events/event_gtk.cc b/views/events/event_gtk.cc index 8b29369..a3496c1 100644 --- a/views/events/event_gtk.cc +++ b/views/events/event_gtk.cc @@ -16,10 +16,14 @@ namespace { ui::EventType EventTypeFromNative(NativeEvent native_event) { // Add new event types as necessary. switch (native_event->type) { + case GDK_ENTER_NOTIFY: + return ui::ET_MOUSE_ENTERED; case GDK_KEY_PRESS: return ui::ET_KEY_PRESSED; case GDK_KEY_RELEASE: return ui::ET_KEY_RELEASED; + case GDK_LEAVE_NOTIFY: + return ui::ET_MOUSE_EXITED; case GDK_SCROLL: return ui::ET_MOUSEWHEEL; default: diff --git a/views/view.cc b/views/view.cc index 7a706992..0547efb7 100644 --- a/views/view.cc +++ b/views/view.cc @@ -613,50 +613,6 @@ gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { return x_rect; } -bool View::ConvertPointForAncestor(const View* ancestor, - gfx::Point* point) const { - scoped_ptr<ui::Transform> trans(ui::Transform::Create()); - - // TODO(sad): Have some way of caching the transformation results. - - const View* v = this; - for (; v && v != ancestor; v = v->parent()) { - if (v->GetTransform().HasChange()) { - if (!trans->ConcatTransform(v->GetTransform())) - return false; - } - trans->ConcatTranslate(static_cast<float>(v->GetMirroredX()), - static_cast<float>(v->y())); - } - - if (trans->HasChange()) { - trans->TransformPoint(point); - } - - return v == ancestor; -} - -bool View::ConvertPointFromAncestor(const View* ancestor, - gfx::Point* point) const { - scoped_ptr<ui::Transform> trans(ui::Transform::Create()); - - const View* v = this; - for (; v && v != ancestor; v = v->parent()) { - if (v->GetTransform().HasChange()) { - if (!trans->ConcatTransform(v->GetTransform())) - return false; - } - trans->ConcatTranslate(static_cast<float>(v->GetMirroredX()), - static_cast<float>(v->y())); - } - - if (trans->HasChange()) { - trans->TransformPointReverse(point); - } - - return v == ancestor; -} - // Painting -------------------------------------------------------------------- void View::SchedulePaint() { @@ -781,24 +737,24 @@ bool View::HitTest(const gfx::Point& l) const { return false; } -bool View::OnMousePressed(const MouseEvent& e) { +bool View::OnMousePressed(const MouseEvent& event) { return false; } -bool View::OnMouseDragged(const MouseEvent& e) { +bool View::OnMouseDragged(const MouseEvent& event) { return false; } -void View::OnMouseReleased(const MouseEvent& e, bool canceled) { +void View::OnMouseReleased(const MouseEvent& event, bool canceled) { } -void View::OnMouseMoved(const MouseEvent& e) { +void View::OnMouseMoved(const MouseEvent& event) { } -void View::OnMouseEntered(const MouseEvent& e) { +void View::OnMouseEntered(const MouseEvent& event) { } -void View::OnMouseExited(const MouseEvent& e) { +void View::OnMouseExited(const MouseEvent& event) { } #if defined(TOUCH_UI) @@ -814,15 +770,15 @@ void View::SetMouseHandler(View *new_mouse_handler) { parent_->SetMouseHandler(new_mouse_handler); } -bool View::OnKeyPressed(const KeyEvent& e) { +bool View::OnKeyPressed(const KeyEvent& event) { return false; } -bool View::OnKeyReleased(const KeyEvent& e) { +bool View::OnKeyReleased(const KeyEvent& event) { return false; } -bool View::OnMouseWheel(const MouseWheelEvent& e) { +bool View::OnMouseWheel(const MouseWheelEvent& event) { return false; } @@ -927,7 +883,7 @@ void View::RequestFocus() { focus_manager->SetFocusedView(this); } -bool View::SkipDefaultKeyEventProcessing(const KeyEvent& e) { +bool View::SkipDefaultKeyEventProcessing(const KeyEvent& event) { return false; } @@ -1437,42 +1393,87 @@ void View::ConvertPointToView(const View* src, } } +bool View::ConvertPointForAncestor(const View* ancestor, + gfx::Point* point) const { + scoped_ptr<ui::Transform> trans(ui::Transform::Create()); + + // TODO(sad): Have some way of caching the transformation results. + + const View* v = this; + for (; v && v != ancestor; v = v->parent()) { + if (v->GetTransform().HasChange()) { + if (!trans->ConcatTransform(v->GetTransform())) + return false; + } + trans->ConcatTranslate(static_cast<float>(v->GetMirroredX()), + static_cast<float>(v->y())); + } + + if (trans->HasChange()) { + trans->TransformPoint(point); + } + + return v == ancestor; +} + +bool View::ConvertPointFromAncestor(const View* ancestor, + gfx::Point* point) const { + scoped_ptr<ui::Transform> trans(ui::Transform::Create()); + + const View* v = this; + for (; v && v != ancestor; v = v->parent()) { + if (v->GetTransform().HasChange()) { + if (!trans->ConcatTransform(v->GetTransform())) + return false; + } + trans->ConcatTranslate(static_cast<float>(v->GetMirroredX()), + static_cast<float>(v->y())); + } + + if (trans->HasChange()) { + trans->TransformPointReverse(point); + } + + return v == ancestor; +} + // Input ----------------------------------------------------------------------- -bool View::ProcessMousePressed(const MouseEvent& e, DragInfo* drag_info) { +bool View::ProcessMousePressed(const MouseEvent& event, DragInfo* drag_info) { const bool enabled = IsEnabled(); int drag_operations = - (enabled && e.IsOnlyLeftMouseButton() && HitTest(e.location())) ? - GetDragOperations(e.location()) : 0; - ContextMenuController* context_menu_controller = e.IsRightMouseButton() ? + (enabled && event.IsOnlyLeftMouseButton() && HitTest(event.location())) ? + GetDragOperations(event.location()) : 0; + ContextMenuController* context_menu_controller = event.IsRightMouseButton() ? context_menu_controller_ : 0; - const bool result = OnMousePressed(e); + const bool result = OnMousePressed(event); // WARNING: we may have been deleted, don't use any View variables. if (!enabled) return result; if (drag_operations != ui::DragDropTypes::DRAG_NONE) { - drag_info->PossibleDrag(e.location()); + drag_info->PossibleDrag(event.location()); return true; } return !!context_menu_controller || result; } -bool View::ProcessMouseDragged(const MouseEvent& e, DragInfo* drag_info) { +bool View::ProcessMouseDragged(const MouseEvent& event, DragInfo* drag_info) { // Copy the field, that way if we're deleted after drag and drop no harm is // done. ContextMenuController* context_menu_controller = context_menu_controller_; const bool possible_drag = drag_info->possible_drag; - if (possible_drag && ExceededDragThreshold(drag_info->start_pt.x() - e.x(), - drag_info->start_pt.y() - e.y())) { + if (possible_drag && ExceededDragThreshold( + drag_info->start_pt.x() - event.x(), + drag_info->start_pt.y() - event.y())) { if (!drag_controller_ || drag_controller_->CanStartDragForView( - this, drag_info->start_pt, e.location())) - DoDrag(e, drag_info->start_pt); + this, drag_info->start_pt, event.location())) + DoDrag(event, drag_info->start_pt); } else { - if (OnMouseDragged(e)) + if (OnMouseDragged(event)) return true; // Fall through to return value based on context menu controller. } @@ -1480,27 +1481,27 @@ bool View::ProcessMouseDragged(const MouseEvent& e, DragInfo* drag_info) { return (context_menu_controller != NULL) || possible_drag; } -void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) { - if (!canceled && context_menu_controller_ && e.IsOnlyRightMouseButton()) { +void View::ProcessMouseReleased(const MouseEvent& event, bool canceled) { + if (!canceled && context_menu_controller_ && event.IsOnlyRightMouseButton()) { // Assume that if there is a context menu controller we won't be deleted // from mouse released. - gfx::Point location(e.location()); - OnMouseReleased(e, canceled); + gfx::Point location(event.location()); + OnMouseReleased(event, canceled); if (HitTest(location)) { ConvertPointToScreen(this, &location); ShowContextMenu(location, true); } } else { - OnMouseReleased(e, canceled); + OnMouseReleased(event, canceled); } // WARNING: we may have been deleted. } #if defined(TOUCH_UI) -View::TouchStatus View::ProcessTouchEvent(const TouchEvent& e) { +View::TouchStatus View::ProcessTouchEvent(const TouchEvent& event) { // TODO(rjkroege): Implement a grab scheme similar to as // as is found in MousePressed. - return OnTouchEvent(e); + return OnTouchEvent(event); } #endif @@ -1635,7 +1636,7 @@ void View::UpdateTooltip() { // Drag and drop --------------------------------------------------------------- -void View::DoDrag(const MouseEvent& e, const gfx::Point& press_pt) { +void View::DoDrag(const MouseEvent& event, const gfx::Point& press_pt) { int drag_operations = GetDragOperations(press_pt); if (drag_operations == ui::DragDropTypes::DRAG_NONE) return; diff --git a/views/view.h b/views/view.h index 1c059f1..8117ab2 100644 --- a/views/view.h +++ b/views/view.h @@ -625,7 +625,7 @@ class View : public AcceleratorTarget { // The event is in the receiver's coordinate system. // // Default implementation does nothing. Override as needed. - virtual void OnMouseMoved(const MouseEvent& e); + virtual void OnMouseMoved(const MouseEvent& event); // This method is invoked when the mouse enters this control. // @@ -667,14 +667,14 @@ class View : public AcceleratorTarget { // Subclasser should return true if the event has been processed and false // otherwise. If the event has not been processed, the parent will be given a // chance. - virtual bool OnKeyPressed(const KeyEvent& e); - virtual bool OnKeyReleased(const KeyEvent& e); + virtual bool OnKeyPressed(const KeyEvent& event); + virtual bool OnKeyReleased(const KeyEvent& event); // Invoked when the user uses the mousewheel. Implementors should return true // if the event has been processed and false otherwise. This message is sent // if the view is focused. If the event has not been processed, the parent // will be given a chance. - virtual bool OnMouseWheel(const MouseWheelEvent& e); + virtual bool OnMouseWheel(const MouseWheelEvent& event); // Accelerators -------------------------------------------------------------- @@ -756,7 +756,7 @@ class View : public AcceleratorTarget { // have it processed as an accelerator (if any) or as a tab traversal (if the // key event is for the TAB key). In that case, OnKeyPressed will // subsequently be invoked for that event. - virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); + virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& event); // Subclasses that contain traversable children that are not directly // accessible through the children hierarchy should return the associated @@ -1215,14 +1215,14 @@ class View : public AcceleratorTarget { // RootView invokes these. These in turn invoke the appropriate OnMouseXXX // method. If a drag is detected, DoDrag is invoked. - bool ProcessMousePressed(const MouseEvent& e, DragInfo* drop_info); - bool ProcessMouseDragged(const MouseEvent& e, DragInfo* drop_info); - void ProcessMouseReleased(const MouseEvent& e, bool canceled); + bool ProcessMousePressed(const MouseEvent& event, DragInfo* drop_info); + bool ProcessMouseDragged(const MouseEvent& event, DragInfo* drop_info); + void ProcessMouseReleased(const MouseEvent& event, bool canceled); #if defined(TOUCH_UI) // RootView will invoke this with incoming TouchEvents. Returns the // the result of OnTouchEvent. - TouchStatus ProcessTouchEvent(const TouchEvent& e); + TouchStatus ProcessTouchEvent(const TouchEvent& event); #endif // Accelerators -------------------------------------------------------------- @@ -1266,7 +1266,7 @@ class View : public AcceleratorTarget { // Starts a drag and drop operation originating from this view. This invokes // WriteDragData to write the data and GetDragOperations to determine the // supported drag operations. When done, OnDragDone is invoked. - void DoDrag(const MouseEvent& e, const gfx::Point& press_pt); + void DoDrag(const MouseEvent& event, const gfx::Point& press_pt); ////////////////////////////////////////////////////////////////////////////// diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 32805df..0ce608c 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -91,14 +91,6 @@ void RootView::ProcessMouseDragCanceled() { } } -void RootView::ProcessOnMouseExited() { - if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); - mouse_move_handler_ = NULL; - } -} - bool RootView::ProcessKeyEvent(const KeyEvent& event) { bool consumed = false; @@ -171,6 +163,13 @@ Widget* RootView::GetWidget() { return const_cast<Widget*>(const_cast<const RootView*>(this)->GetWidget()); } +void RootView::OnMouseExited(const MouseEvent& event) { + if (mouse_move_handler_ != NULL) { + mouse_move_handler_->OnMouseExited(event); + mouse_move_handler_ = NULL; + } +} + bool RootView::OnMousePressed(const MouseEvent& event) { MouseEvent e(event, this); @@ -290,33 +289,20 @@ void RootView::OnMouseMoved(const MouseEvent& event) { v = v->parent(); if (v && v != this) { if (v != mouse_move_handler_) { - if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); - } - + if (mouse_move_handler_ != NULL) + mouse_move_handler_->OnMouseExited(e); mouse_move_handler_ = v; - - MouseEvent entered_event(ui::ET_MOUSE_ENTERED, - this, - mouse_move_handler_, - e.location(), - 0); + MouseEvent entered_event(e, this, mouse_move_handler_); mouse_move_handler_->OnMouseEntered(entered_event); } - MouseEvent moved_event(ui::ET_MOUSE_MOVED, - this, - mouse_move_handler_, - e.location(), - 0); + MouseEvent moved_event(e, this, mouse_move_handler_); mouse_move_handler_->OnMouseMoved(moved_event); gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint( moved_event.type(), moved_event.location()); widget_->SetCursor(cursor); } else if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); + mouse_move_handler_->OnMouseExited(e); widget_->SetCursor(NULL); } } @@ -435,49 +421,39 @@ void RootView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { // Coordinate conversion ------------------------------------------------------- -bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, - gfx::Point* p) { - // - // If the mouse_handler was set explicitly, we need to keep - // sending events even if it was re-parented in a different - // window. (a non explicit mouse handler is automatically - // cleared when the control is removed from the hierarchy) +bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point* p) { + // If the mouse_handler was set explicitly, keep sending events even if it was + // re-parented in a different window. (a non explicit mouse handler is + // automatically cleared when the control is removed from the hierarchy) + *p = l; if (explicit_mouse_handler_) { - if (mouse_pressed_handler_->GetWidget()) { - *p = l; - ConvertPointToScreen(this, p); + // If the mouse_pressed_handler_ is not connected, we send the + // event in screen coordinate system + ConvertPointToScreen(this, p); + if (mouse_pressed_handler_->GetWidget()) ConvertPointToView(NULL, mouse_pressed_handler_, p); - } else { - // If the mouse_pressed_handler_ is not connected, we send the - // event in screen coordinate system - *p = l; - ConvertPointToScreen(this, p); - return true; - } - } else { - *p = l; + } else ConvertPointToView(this, mouse_pressed_handler_, p); - } return true; } // Input ----------------------------------------------------------------------- -void RootView::UpdateCursor(const MouseEvent& e) { +void RootView::UpdateCursor(const MouseEvent& event) { gfx::NativeCursor cursor = NULL; - View* v = GetEventHandlerForPoint(e.location()); + View* v = GetEventHandlerForPoint(event.location()); if (v && v != this) { - gfx::Point l(e.location()); + gfx::Point l(event.location()); View::ConvertPointToView(this, v, &l); - cursor = v->GetCursorForPoint(e.type(), l); + cursor = v->GetCursorForPoint(event.type(), l); } widget_->SetCursor(cursor); } -void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { - last_mouse_event_flags_ = e.flags(); - last_mouse_event_x_ = e.x(); - last_mouse_event_y_ = e.y(); +void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { + last_mouse_event_flags_ = event.flags(); + last_mouse_event_x_ = event.x(); + last_mouse_event_y_ = event.y(); } } // namespace views diff --git a/views/widget/root_view.h b/views/widget/root_view.h index d9634b2..3eac199 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -63,10 +63,6 @@ class RootView : public View, // the system. Invokes OnMouseReleased with a value of true for canceled. void ProcessMouseDragCanceled(); - // Invoked by the Widget instance when the mouse moves outside of the Widget - // bounds. - virtual void ProcessOnMouseExited(); - // Process a key event. Send the event to the focused view and up the focus // path, and finally to the default keyboard handler, until someone consumes // it. Returns whether anyone consumed the event. @@ -106,14 +102,15 @@ class RootView : public View, virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; virtual const Widget* GetWidget() const OVERRIDE; virtual Widget* GetWidget() OVERRIDE; - virtual bool OnMousePressed(const MouseEvent& e) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& e) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& e, bool canceled) OVERRIDE; - virtual void OnMouseMoved(const MouseEvent& e) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE; - virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; + virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; #if defined(TOUCH_UI) - virtual TouchStatus OnTouchEvent(const TouchEvent& e) OVERRIDE; + virtual TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; #endif virtual bool IsVisibleInRootView() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; @@ -148,12 +145,12 @@ class RootView : public View, // cursor during drag operations. The location of the mouse should be in the // current coordinate system (i.e. any necessary transformation should be // applied to the point prior to calling this). - void UpdateCursor(const MouseEvent& e); + void UpdateCursor(const MouseEvent& event); // Updates the last_mouse_* fields from e. The location of the mouse should be // in the current coordinate system (i.e. any necessary transformation should // be applied to the point prior to calling this). - void SetMouseLocationAndFlags(const MouseEvent& e); + void SetMouseLocationAndFlags(const MouseEvent& event); ////////////////////////////////////////////////////////////////////////////// diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index ec9ef0c..d60a0c9 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1074,8 +1074,10 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { last_mouse_event_was_move_ = false; - if (!has_capture_ && !is_mouse_down_) - GetRootView()->ProcessOnMouseExited(); + if (!has_capture_ && !is_mouse_down_) { + MouseEvent mouse_event(reinterpret_cast<GdkEvent*>(event)); + GetRootView()->OnMouseExited(mouse_event); + } return false; } diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 783c5ca..badb66f 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -675,7 +675,7 @@ LRESULT WidgetWin::OnMouseActivate(UINT message, LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { tooltip_manager_->OnMouseLeave(); - ProcessMouseExited(); + ProcessMouseExited(message, w_param, l_param); return 0; } @@ -747,7 +747,7 @@ LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { LRESULT WidgetWin::OnNCMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { - ProcessMouseExited(); + ProcessMouseExited(message, w_param, l_param); return 0; } @@ -977,9 +977,14 @@ bool WidgetWin::ProcessMouseMoved(UINT message, return true; } -void WidgetWin::ProcessMouseExited() { +void WidgetWin::ProcessMouseExited(UINT message, + WPARAM w_param, + LPARAM l_param) { last_mouse_event_was_move_ = false; - GetRootView()->ProcessOnMouseExited(); + MSG msg; + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), + GET_Y_LPARAM(l_param)); + GetRootView()->OnMouseExited(MouseEvent(msg)); // Reset our tracking flag so that future mouse movement over this WidgetWin // results in a new tracking session. active_mouse_tracking_flags_ = 0; diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 67816e0..ba78268 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -400,7 +400,7 @@ class WidgetWin : public ui::WindowImpl, bool ProcessMousePressed(UINT message, WPARAM w_param, LPARAM l_param); bool ProcessMouseReleased(UINT message, WPARAM w_param, LPARAM l_param); bool ProcessMouseMoved(UINT message, WPARAM w_param, LPARAM l_param); - void ProcessMouseExited(); + void ProcessMouseExited(UINT message, WPARAM w_param, LPARAM l_param); // Called when a MSAA screen reader client is detected. virtual void OnScreenReaderDetected(); |