1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.editors.layout.gscripts; 18 19 import groovy.lang.Closure; 20 21 /** 22 * Returned by onDropEnter/Move and passed to over onDropXyz methods. 23 */ 24 public class DropFeedback { 25 /** 26 * User data that the rule can use in any way it wants to carry state from one 27 * operation to another. 28 */ 29 public Object userData; 30 31 /** 32 * If true the next screen update will invoke the paint closure. 33 */ 34 public boolean requestPaint; 35 36 /** 37 * Closure invoked by the canvas to paint the feedback. 38 * The closure will receive 3 arguments: <br/> 39 * - The {@link IGraphics} context to use for painting. Must not be cached. <br/> 40 * - The {@link INode} target node last used in a onDropEnter or onDropMove call. <br/> 41 * - The {@link DropFeedback} returned by the last onDropEnter or onDropMove call. <br/> 42 */ 43 public Closure paintClosure; 44 45 /** 46 * When set to a non-null valid rectangle, this informs the engine that a drag'n'drop 47 * feedback wants to capture the mouse as long as it stays in the given area. 48 * <p/> 49 * When the mouse is captured, drop events will keep going to the rule that started the 50 * capture and the current INode proxy will not change. 51 */ 52 public Rect captureArea; 53 54 /** 55 * Set to true by the drag'n'drop engine when the current drag operation is a copy. 56 * When false the operation is a move and <em>after</em> a successful drop the source 57 * elements will be deleted. 58 */ 59 public boolean isCopy; 60 61 /** 62 * Set to true when the drag'n'drop starts and ends in the same canvas of the 63 * same Eclipse instance. 64 */ 65 public boolean sameCanvas; 66 67 /** 68 * Initializes the drop feedback with the given user data and paint closure. 69 * A paint is requested if the paint closure is non-null. 70 */ 71 public DropFeedback(Object userData, Closure paintClosure) { 72 this.userData = userData; 73 this.paintClosure = paintClosure; 74 this.requestPaint = paintClosure != null; 75 this.captureArea = null; 76 } 77 } 78