summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 04:31:58 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 04:31:58 +0000
commit3630942bd18a8f06d67412b737340a2eaa845753 (patch)
treefc9a5be75d6b2aa223e3c901bea2b3eb6a2be4da /ash
parentcba02a81e3e7a84663975d741276a842794ad95f (diff)
downloadchromium_src-3630942bd18a8f06d67412b737340a2eaa845753.zip
chromium_src-3630942bd18a8f06d67412b737340a2eaa845753.tar.gz
chromium_src-3630942bd18a8f06d67412b737340a2eaa845753.tar.bz2
views: Start converting View into an EventTarget.
The EventDispatcher interface is not acually used for dispatching events yet. That will happen once RootView is turned into an EventDispatcher. But this first step prepares scroll, touch, and gesture event dispatching in views so that it is compatible with the EventDispatcher interface. BUG=none Review URL: https://codereview.chromium.org/11364015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/launcher/launcher_button.cc47
-rw-r--r--ash/launcher/launcher_button.h5
-rw-r--r--ash/launcher/launcher_view.cc10
-rw-r--r--ash/launcher/launcher_view.h5
-rw-r--r--ash/launcher/overflow_bubble.cc12
-rw-r--r--ash/system/status_area_widget_delegate.cc4
-rw-r--r--ash/system/status_area_widget_delegate.h5
-rw-r--r--ash/system/tray/tray_notification_view.cc5
-rw-r--r--ash/system/tray/tray_notification_view.h5
-rw-r--r--ash/system/tray/tray_views.cc7
-rw-r--r--ash/system/tray/tray_views.h5
-rw-r--r--ash/wm/workspace/frame_maximize_button.cc35
-rw-r--r--ash/wm/workspace/frame_maximize_button.h5
13 files changed, 77 insertions, 73 deletions
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index aed69eb..eacd850 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -259,30 +259,6 @@ void LauncherButton::OnMouseExited(const ui::MouseEvent& event) {
host_->MouseExitedButton(this);
}
-ui::EventResult LauncherButton::OnGestureEvent(
- const ui::GestureEvent& event) {
- switch (event.type()) {
- case ui::ET_GESTURE_TAP_DOWN:
- AddState(STATE_HOVERED);
- return CustomButton::OnGestureEvent(event);
- case ui::ET_GESTURE_END:
- ClearState(STATE_HOVERED);
- return CustomButton::OnGestureEvent(event);
- case ui::ET_GESTURE_SCROLL_BEGIN:
- host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, event);
- return ui::ER_CONSUMED;
- case ui::ET_GESTURE_SCROLL_UPDATE:
- host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, event);
- return ui::ER_CONSUMED;
- case ui::ET_GESTURE_SCROLL_END:
- case ui::ET_SCROLL_FLING_START:
- host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false);
- return ui::ER_CONSUMED;
- default:
- return CustomButton::OnGestureEvent(event);
- }
-}
-
void LauncherButton::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = host_->GetAccessibleName(this);
@@ -328,6 +304,29 @@ void LauncherButton::OnBlur() {
CustomButton::OnBlur();
}
+ui::EventResult LauncherButton::OnGestureEvent(ui::GestureEvent* event) {
+ switch (event->type()) {
+ case ui::ET_GESTURE_TAP_DOWN:
+ AddState(STATE_HOVERED);
+ return CustomButton::OnGestureEvent(event);
+ case ui::ET_GESTURE_END:
+ ClearState(STATE_HOVERED);
+ return CustomButton::OnGestureEvent(event);
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event);
+ return ui::ER_CONSUMED;
+ case ui::ET_GESTURE_SCROLL_UPDATE:
+ host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event);
+ return ui::ER_CONSUMED;
+ case ui::ET_GESTURE_SCROLL_END:
+ case ui::ET_SCROLL_FLING_START:
+ host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false);
+ return ui::ER_CONSUMED;
+ default:
+ return CustomButton::OnGestureEvent(event);
+ }
+}
+
void LauncherButton::Init() {
icon_view_ = CreateIconView();
diff --git a/ash/launcher/launcher_button.h b/ash/launcher/launcher_button.h
index 930bdc2..f4c0755 100644
--- a/ash/launcher/launcher_button.h
+++ b/ash/launcher/launcher_button.h
@@ -84,14 +84,15 @@ class LauncherButton : public views::CustomButton {
virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
- virtual ui::EventResult OnGestureEvent(const ui::GestureEvent& event)
- OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void Layout() OVERRIDE;
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
+ // ui::EventHandler overrides:
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+
// Sets the icon image with a shadow.
void SetShadowedImage(const gfx::ImageSkia& bitmap);
// Override for custom initialization.
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 1006993..47c23c5 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -775,11 +775,6 @@ gfx::Size LauncherView::GetPreferredSize() {
last_button_bounds.bottom() + leading_inset());
}
-ui::EventResult LauncherView::OnGestureEvent(const ui::GestureEvent& event) {
- return gesture_handler_.ProcessGestureEvent(event) ?
- ui::ER_CONSUMED : ui::ER_UNHANDLED;
-}
-
void LauncherView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
LayoutToIdealBounds();
FOR_EACH_OBSERVER(LauncherIconObserver, observers_,
@@ -793,6 +788,11 @@ views::FocusTraversable* LauncherView::GetPaneFocusTraversable() {
return this;
}
+ui::EventResult LauncherView::OnGestureEvent(ui::GestureEvent* event) {
+ return gesture_handler_.ProcessGestureEvent(*event) ?
+ ui::ER_CONSUMED : ui::ER_UNHANDLED;
+}
+
void LauncherView::LauncherItemAdded(int model_index) {
model_index = CancelDrag(model_index);
views::View* view = CreateViewForItem(model_->items()[model_index]);
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index 63528e8..ece7ba6 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -180,11 +180,12 @@ class ASH_EXPORT LauncherView : public views::View,
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual ui::EventResult OnGestureEvent(
- const ui::GestureEvent& event) OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
virtual FocusTraversable* GetPaneFocusTraversable() OVERRIDE;
+ // Overridden from ui::EventHandler:
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+
// Overridden from LauncherModelObserver:
virtual void LauncherItemAdded(int model_index) OVERRIDE;
virtual void LauncherItemRemoved(int model_index, LauncherID id) OVERRIDE;
diff --git a/ash/launcher/overflow_bubble.cc b/ash/launcher/overflow_bubble.cc
index e05d087..e5f78cd 100644
--- a/ash/launcher/overflow_bubble.cc
+++ b/ash/launcher/overflow_bubble.cc
@@ -78,7 +78,9 @@ class OverflowBubbleView : public views::BubbleDelegateView {
virtual void Layout() OVERRIDE;
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
- virtual bool OnScrollEvent(const ui::ScrollEvent& event) OVERRIDE;
+
+ // ui::EventHandler overrides:
+ virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
// views::BubbleDelegate overrides:
virtual gfx::Rect GetBubbleBounds() OVERRIDE;
@@ -190,11 +192,11 @@ bool OverflowBubbleView::OnMouseWheel(const ui::MouseWheelEvent& event) {
return true;
}
-bool OverflowBubbleView::OnScrollEvent(const ui::ScrollEvent& event) {
- ScrollByXOffset(-event.x_offset());
- ScrollByYOffset(-event.y_offset());
+ui::EventResult OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) {
+ ScrollByXOffset(-event->x_offset());
+ ScrollByYOffset(-event->y_offset());
Layout();
- return true;
+ return ui::ER_HANDLED;
}
gfx::Rect OverflowBubbleView::GetBubbleBounds() {
diff --git a/ash/system/status_area_widget_delegate.cc b/ash/system/status_area_widget_delegate.cc
index 13b84842..94d6ea5 100644
--- a/ash/system/status_area_widget_delegate.cc
+++ b/ash/system/status_area_widget_delegate.cc
@@ -62,8 +62,8 @@ const views::Widget* StatusAreaWidgetDelegate::GetWidget() const {
}
ui::EventResult StatusAreaWidgetDelegate::OnGestureEvent(
- const ui::GestureEvent& event) {
- if (gesture_handler_.ProcessGestureEvent(event))
+ ui::GestureEvent* event) {
+ if (gesture_handler_.ProcessGestureEvent(*event))
return ui::ER_CONSUMED;
return views::AccessiblePaneView::OnGestureEvent(event);
diff --git a/ash/system/status_area_widget_delegate.h b/ash/system/status_area_widget_delegate.h
index 1d147bc..7c56ff3 100644
--- a/ash/system/status_area_widget_delegate.h
+++ b/ash/system/status_area_widget_delegate.h
@@ -41,8 +41,9 @@ class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual views::Widget* GetWidget() OVERRIDE;
virtual const views::Widget* GetWidget() const OVERRIDE;
- virtual ui::EventResult OnGestureEvent(
- const ui::GestureEvent& event) OVERRIDE;
+
+ // Overridden from ui::EventHandler:
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// views::WidgetDelegate overrides:
virtual bool CanActivate() const OVERRIDE;
diff --git a/ash/system/tray/tray_notification_view.cc b/ash/system/tray/tray_notification_view.cc
index 3281d62..85657c5 100644
--- a/ash/system/tray/tray_notification_view.cc
+++ b/ash/system/tray/tray_notification_view.cc
@@ -124,9 +124,8 @@ bool TrayNotificationView::OnMousePressed(const ui::MouseEvent& event) {
return true;
}
-ui::EventResult TrayNotificationView::OnGestureEvent(
- const ui::GestureEvent& event) {
- if (event.type() != ui::ET_GESTURE_TAP)
+ui::EventResult TrayNotificationView::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() != ui::ET_GESTURE_TAP)
return ui::ER_UNHANDLED;
HandleClickAction();
return ui::ER_CONSUMED;
diff --git a/ash/system/tray/tray_notification_view.h b/ash/system/tray/tray_notification_view.h
index 9be7f3b..ee604fc 100644
--- a/ash/system/tray/tray_notification_view.h
+++ b/ash/system/tray/tray_notification_view.h
@@ -57,8 +57,9 @@ class TrayNotificationView : public views::View,
// Overridden from views::View.
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
- virtual ui::EventResult OnGestureEvent(
- const ui::GestureEvent& event) OVERRIDE;
+
+ // Overridden from ui::EventHandler.
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
protected:
// Called when the close button is pressed. Does nothing by default.
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
index ca3cce7..99e6647 100644
--- a/ash/system/tray/tray_views.cc
+++ b/ash/system/tray/tray_views.cc
@@ -152,10 +152,9 @@ void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) {
DrawBorder(canvas, GetLocalBounds());
}
-ui::EventResult ActionableView::OnGestureEvent(
- const ui::GestureEvent& event) {
- if (event.type() == ui::ET_GESTURE_TAP) {
- return PerformAction(event) ? ui::ER_CONSUMED :
+ui::EventResult ActionableView::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_TAP) {
+ return PerformAction(*event) ? ui::ER_CONSUMED :
ui::ER_UNHANDLED;
}
return ui::ER_UNHANDLED;
diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h
index 3242b6a..5cf50c3 100644
--- a/ash/system/tray/tray_views.h
+++ b/ash/system/tray/tray_views.h
@@ -78,11 +78,12 @@ class ASH_EXPORT ActionableView : public views::View {
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
- virtual ui::EventResult OnGestureEvent(
- const ui::GestureEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
+ // Overridden from ui::EventHandler.
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+
private:
string16 accessible_name_;
bool has_capture_;
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index edb0a11..9334a8e 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -270,40 +270,39 @@ void FrameMaximizeButton::OnMouseCaptureLost() {
ImageButton::OnMouseCaptureLost();
}
-ui::EventResult FrameMaximizeButton::OnGestureEvent(
- const ui::GestureEvent& event) {
- if (event.type() == ui::ET_GESTURE_TAP_DOWN) {
+ui::EventResult FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
is_snap_enabled_ = true;
- ProcessStartEvent(event);
+ ProcessStartEvent(*event);
return ui::ER_CONSUMED;
}
- if (event.type() == ui::ET_GESTURE_TAP ||
- event.type() == ui::ET_GESTURE_SCROLL_END) {
+ if (event->type() == ui::ET_GESTURE_TAP ||
+ event->type() == ui::ET_GESTURE_SCROLL_END) {
// The position of the event may have changed from the previous event (both
// for TAP and SCROLL_END). So it is necessary to update the snap-state for
// the current event.
- ProcessUpdateEvent(event);
- if (event.type() == ui::ET_GESTURE_TAP)
- snap_type_ = SnapTypeForLocation(event.location());
- ProcessEndEvent(event);
+ ProcessUpdateEvent(*event);
+ if (event->type() == ui::ET_GESTURE_TAP)
+ snap_type_ = SnapTypeForLocation(event->location());
+ ProcessEndEvent(*event);
return ui::ER_CONSUMED;
}
if (is_snap_enabled_) {
- if (event.type() == ui::ET_GESTURE_END &&
- event.details().touch_points() == 1) {
+ if (event->type() == ui::ET_GESTURE_END &&
+ event->details().touch_points() == 1) {
// The position of the event may have changed from the previous event. So
// it is necessary to update the snap-state for the current event.
- ProcessUpdateEvent(event);
- snap_type_ = SnapTypeForLocation(event.location());
- ProcessEndEvent(event);
+ ProcessUpdateEvent(*event);
+ snap_type_ = SnapTypeForLocation(event->location());
+ ProcessEndEvent(*event);
return ui::ER_CONSUMED;
}
- if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE ||
- event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
- ProcessUpdateEvent(event);
+ if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
+ event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
+ ProcessUpdateEvent(*event);
return ui::ER_CONSUMED;
}
}
diff --git a/ash/wm/workspace/frame_maximize_button.h b/ash/wm/workspace/frame_maximize_button.h
index 819adc5..45c1b32 100644
--- a/ash/wm/workspace/frame_maximize_button.h
+++ b/ash/wm/workspace/frame_maximize_button.h
@@ -64,8 +64,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton,
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
- virtual ui::EventResult OnGestureEvent(
- const ui::GestureEvent& event) OVERRIDE;
+
+ // ui::EventHandler overrides:
+ virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// Unit test overwrite: Change the UI delay used for the bubble show up.
void set_bubble_appearance_delay_ms(int bubble_appearance_delay_ms) {