aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2010-02-08 15:26:41 -0800
committerRaphael <raphael@google.com>2010-02-08 15:26:41 -0800
commit8d4922b07d0c4dff56e4d2fda919d7bc0418495d (patch)
treec5d2586e0990340f615a0c4716ac4239ff074c8f /eclipse
parent85008a1fe95c7f1f8572b4f70a9b37546b1197c9 (diff)
downloadsdk-8d4922b07d0c4dff56e4d2fda919d7bc0418495d.zip
sdk-8d4922b07d0c4dff56e4d2fda919d7bc0418495d.tar.gz
sdk-8d4922b07d0c4dff56e4d2fda919d7bc0418495d.tar.bz2
ADT GLE2: support isMultipleSelection.
Problem is easily solved by making this a parameter in the closure, so we don't need to ask rules to give us a different closure, they just need to redraw. Change-Id: I4445c826b03bbb978bf085905ccd67d5e03b0356
Diffstat (limited to 'eclipse')
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.view.View.groovy5
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/editors/layout/gscripts/IViewRule.java12
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasSelection.java29
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java3
4 files changed, 34 insertions, 15 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.view.View.groovy b/eclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.view.View.groovy
index 3dba8d3..2171cf3 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.view.View.groovy
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.view.View.groovy
@@ -38,8 +38,9 @@ public class AndroidViewViewRule extends BaseViewRule {
// Before that, make sure the engine can deal with the lack of a base class
// fallback when navigating the hierarchy.
+ // TODO move all this to BaseViewRule
Closure onSelected(INode node) {
- def drawSelection = { gc, name, currentNode ->
+ def drawSelection = { gc, name, currentNode, isMultipleSelection ->
Rect r = currentNode.getBounds();
if (!r.isValid()) {
@@ -50,7 +51,7 @@ public class AndroidViewViewRule extends BaseViewRule {
gc.setLineStyle(IGraphics.LineStyle.LINE_SOLID);
gc.drawRect(r);
- if (name == null) {
+ if (name == null || isMultipleSelection) {
return;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/editors/layout/gscripts/IViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/editors/layout/gscripts/IViewRule.java
index 68306e7..33ea938 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/editors/layout/gscripts/IViewRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/editors/layout/gscripts/IViewRule.java
@@ -72,11 +72,19 @@ public interface IViewRule {
/**
+ * Called by the canvas when a view is being selected.
+ * The callback must return a closure that is used to draw the actual selection.
+ * <p/>
+ * The closure takes 4 arguments: <br/>
+ * - An {@link IGraphics} instance, to perform drawing operations. <br/>
+ * - The name to display, as returned by {@link #getDisplayName()}. <br/>
+ * - The selected {@link INode}. <br/>
+ * - A boolean set to true if more than one element is selected.
+ * <p/>
* Context: foreground color already set to selection color, full opaque.
- * Returns: a closure that takes gc, display_name and node as arguments.
*
* @param selectedNode The node selected. Never null.
- * @return Null or a closure that expects gc, name, currentNode as input arguments.
+ * @return Null or a closure that expects graphics, name, currentNode as input arguments.
*/
Closure onSelected(INode selectedNode);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasSelection.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasSelection.java
index c6766c4..2ba8e3f 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasSelection.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasSelection.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
+import com.android.ide.eclipse.adt.editors.layout.gscripts.IViewRule;
import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeProxy;
import com.android.ide.eclipse.adt.internal.editors.layout.gre.RulesEngine;
@@ -95,6 +96,24 @@ import groovy.lang.Closure;
return mName;
}
+ /**
+ * Calls the closure returned by
+ * {@link IViewRule#onSelected(com.android.ide.eclipse.adt.editors.layout.gscripts.INode)}.
+ *
+ * @param gcWrapper The GC to use for drawing.
+ * @param isMultipleSelection True if more than one view is selected.
+ */
+ /*package*/ void paint(GCWrapper gcWrapper, boolean isMultipleSelection) {
+ if (mPaintClosure != null) {
+ try {
+ mPaintClosure.call(
+ new Object[] { gcWrapper, mName, mNodeProxy, isMultipleSelection });
+ } catch (Exception e) {
+ mNodeProxy.debugPrintf("Selection Paint Closure: %s", e.toString());
+ }
+ }
+ }
+
//----
private String initDisplayName(CanvasViewInfo canvasViewInfo, RulesEngine gre) {
@@ -143,14 +162,4 @@ import groovy.lang.Closure;
mNodeProxy = proxy;
mPaintClosure = result;
}
-
- public void paint(GCWrapper gcWrapper) {
- if (mPaintClosure != null) {
- try {
- mPaintClosure.call(new Object[] { gcWrapper, mName, mNodeProxy });
- } catch (Exception e) {
- mNodeProxy.debugPrintf("Selection Paint Closure: %s", e.toString());
- }
- }
- }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
index e338864..8bb38eb 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
@@ -430,8 +430,9 @@ import java.util.ListIterator;
}
gc.setForeground(mSelectionFgColor);
+ boolean isMultipleSelection = mSelections.size() > 1;
for (CanvasSelection s : mSelections) {
- s.paint(mGCWrapper);
+ s.paint(mGCWrapper, isMultipleSelection);
}
drawDropZones(gc);