/** * Copyright 2010 The ForPlay Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package forplay.core; /** * Input-device interface for pointer events. This is a generic interface that * works for both mouse and touch events, but only handles the basic * touch-drag-release case. */ public interface Pointer { /** The event dispatched to pointer listeners. */ interface Event extends Events.Position { // nothing currently here, for future compatibility class Impl extends Events.Position.Impl implements Event { public Impl(double time, float x, float y) { super(time, x, y); } } } interface Listener { /** * Called when the pointer event starts. */ void onPointerStart(Event event); /** * Called when the pointer event ends. */ void onPointerEnd(Event event); /** * Called when the pointer drags (always between start/end events). */ void onPointerDrag(Event event); } /** A {@link Listener} implementation with NOOP stubs provided for each method. */ class Adapter implements Listener { public void onPointerStart(Event event) { /* NOOP! */ } public void onPointerEnd(Event event) { /* NOOP! */ } public void onPointerDrag(Event event) { /* NOOP! */ } } /** * Sets the listener that will receive pointer events. Setting the listener to * <code>null</code> will cause pointer events to stop being fired. */ void setListener(Listener listener); }