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

Unified Diff: ui/views/controls/resize_area.cc

Issue 2796303006: Add gesture support in views::ResizeArea (Closed)
Patch Set: skip OSX Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/resize_area.h ('k') | ui/views/controls/resize_area_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/resize_area.cc
diff --git a/ui/views/controls/resize_area.cc b/ui/views/controls/resize_area.cc
index 3698078d709d6986907ef91eabafdb0e110cc3e2..06c0325fea38f89ea9da767478384578afb8c526 100644
--- a/ui/views/controls/resize_area.cc
+++ b/ui/views/controls/resize_area.cc
@@ -14,9 +14,6 @@ namespace views {
const char ResizeArea::kViewClassName[] = "ResizeArea";
-////////////////////////////////////////////////////////////////////////////////
-// ResizeArea
-
ResizeArea::ResizeArea(ResizeAreaDelegate* delegate)
: delegate_(delegate),
initial_position_(0) {
@@ -34,17 +31,25 @@ gfx::NativeCursor ResizeArea::GetCursor(const ui::MouseEvent& event) {
: gfx::kNullCursor;
}
+void ResizeArea::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
+ SetInitialPosition(event->x());
+ event->SetHandled();
+ } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
+ event->type() == ui::ET_GESTURE_SCROLL_UPDATE) {
+ ReportResizeAmount(event->x(), false);
+ event->SetHandled();
+ } else if (event->type() == ui::ET_GESTURE_END) {
+ ReportResizeAmount(event->x(), true);
+ event->SetHandled();
+ }
+}
+
bool ResizeArea::OnMousePressed(const ui::MouseEvent& event) {
if (!event.IsOnlyLeftMouseButton())
return false;
- // The resize area obviously will move once you start dragging so we need to
- // convert coordinates to screen coordinates so that we don't lose our
- // bearings.
- gfx::Point point(event.x(), 0);
- View::ConvertPointToScreen(this, &point);
- initial_position_ = point.x();
-
+ SetInitialPosition(event.x());
return true;
}
@@ -76,4 +81,10 @@ void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) {
last_update);
}
+void ResizeArea::SetInitialPosition(int event_x) {
+ gfx::Point point(event_x, 0);
+ View::ConvertPointToScreen(this, &point);
+ initial_position_ = point.x();
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/resize_area.h ('k') | ui/views/controls/resize_area_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698