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

Unified Diff: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/internal/ui/panels/MoveTracker.java

Issue 17431004: New UI for Find command: find-as-you-type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
Index: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/internal/ui/panels/MoveTracker.java
===================================================================
--- editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/internal/ui/panels/MoveTracker.java (revision 0)
+++ editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/internal/ui/panels/MoveTracker.java (revision 0)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008 xored software, Inc. All rights reserved. This program and the accompanying
+ * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies
+ * this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors:
+ * xored software, Inc. - initial API and Implementation (Yuri Strot)
+ *******************************************************************************/
+package com.xored.glance.internal.ui.panels;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * @author Yuri Strot
+ */
+public class MoveTracker implements Listener {
+
+ public MoveTracker(Control control) {
+ this.control = control;
+ cursor = new Cursor(control.getDisplay(), SWT.CURSOR_SIZEALL);
+ control.setCursor(cursor);
+ control.addListener(SWT.MouseDown, this);
+ control.addListener(SWT.Dispose, this);
+ }
+
+ public void handleEvent(Event event) {
+ if (control != null && !control.isDisposed()) {
+ switch (event.type) {
+ case SWT.MouseDown:
+ Point point = control.getDisplay().getCursorLocation();
+ handleClick(point.x, point.y);
+ break;
+ case SWT.MouseMove:
+ point = control.getDisplay().getCursorLocation();
+ handleDrag(point.x - iLocation.x, point.y - iLocation.y);
+ break;
+ case SWT.Dispose:
+ cursor.dispose();
+ cursor = null;
+ case SWT.MouseUp:
+ control.getDisplay().removeFilter(SWT.MouseMove, this);
+ control.getDisplay().removeFilter(SWT.MouseUp, this);
+ }
+
+ }
+ }
+
+ protected void handleClick(int x, int y) {
+ iLocation = new Point(x, y);
+ control.getDisplay().addFilter(SWT.MouseMove, this);
+ control.getDisplay().addFilter(SWT.MouseUp, this);
+ }
+
+ protected void handleDrag(int dx, int dy) {
+ }
+
+ private Cursor cursor;
+ private Point iLocation;
+ private Control control;
+
+}

Powered by Google App Engine
This is Rietveld 408576698