diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src')
4 files changed, 73 insertions, 11 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/DrawingStyle.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/DrawingStyle.java index 0938afa..7317ebc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/DrawingStyle.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/DrawingStyle.java @@ -44,6 +44,12 @@ public enum DrawingStyle { HOVER, /** + * The style used for hovered views (e.g. when the mouse is directly on top + * of the view), when the hover happens to be the same object as the selection + */ + HOVER_SELECTION, + + /** * The style used to draw anchors (lines to the other views the given view * is anchored to) */ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/HoverOverlay.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/HoverOverlay.java index 27a6024..2f46921 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/HoverOverlay.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/HoverOverlay.java @@ -16,22 +16,35 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import static com.android.ide.eclipse.adt.internal.editors.layout.gle2.SwtDrawingStyle.HOVER; +import static com.android.ide.eclipse.adt.internal.editors.layout.gle2.SwtDrawingStyle.HOVER_SELECTION; + import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; +import java.util.List; + /** * The {@link HoverOverlay} paints an optional hover on top of the layout, * highlighting the currently hovered view. */ public class HoverOverlay extends Overlay { + private final LayoutCanvas mCanvas; + /** Hover border color. Must be disposed, it's NOT a system color. */ private Color mHoverStrokeColor; /** Hover fill color. Must be disposed, it's NOT a system color. */ private Color mHoverFillColor; + /** Hover border select color. Must be disposed, it's NOT a system color. */ + private Color mHoverSelectStrokeColor; + + /** Hover fill select color. Must be disposed, it's NOT a system color. */ + private Color mHoverSelectFillColor; + /** Vertical scaling & scrollbar information. */ private CanvasTransform mVScale; @@ -48,13 +61,14 @@ public class HoverOverlay extends Overlay { /** * Constructs a new {@link HoverOverlay} linked to the given view hierarchy. * + * @param canvas the associated canvas * @param hScale The {@link CanvasTransform} to use to transfer horizontal layout * coordinates to screen coordinates. * @param vScale The {@link CanvasTransform} to use to transfer vertical layout * coordinates to screen coordinates. */ - public HoverOverlay(CanvasTransform hScale, CanvasTransform vScale) { - super(); + public HoverOverlay(LayoutCanvas canvas, CanvasTransform hScale, CanvasTransform vScale) { + mCanvas = canvas; this.mHScale = hScale; this.mVScale = vScale; } @@ -67,6 +81,15 @@ public class HoverOverlay extends Overlay { if (SwtDrawingStyle.HOVER.getFillColor() != null) { mHoverFillColor = new Color(device, SwtDrawingStyle.HOVER.getFillColor()); } + + if (SwtDrawingStyle.HOVER_SELECTION.getStrokeColor() != null) { + mHoverSelectStrokeColor = new Color(device, + SwtDrawingStyle.HOVER_SELECTION.getStrokeColor()); + } + if (SwtDrawingStyle.HOVER_SELECTION.getFillColor() != null) { + mHoverSelectFillColor = new Color(device, + SwtDrawingStyle.HOVER_SELECTION.getFillColor()); + } } @Override @@ -80,6 +103,16 @@ public class HoverOverlay extends Overlay { mHoverFillColor.dispose(); mHoverFillColor = null; } + + if (mHoverSelectStrokeColor != null) { + mHoverSelectStrokeColor.dispose(); + mHoverSelectStrokeColor = null; + } + + if (mHoverSelectFillColor != null) { + mHoverSelectFillColor.dispose(); + mHoverSelectFillColor = null; + } } /** @@ -117,19 +150,35 @@ public class HoverOverlay extends Overlay { int w = mHScale.scale(mHoverRect.width); int h = mVScale.scale(mHoverRect.height); - if (mHoverStrokeColor != null) { + + boolean hoverIsSelected = false; + List<SelectionItem> selections = mCanvas.getSelectionManager().getSelections(); + for (SelectionItem item : selections) { + if (mHoverRect.equals(item.getViewInfo().getSelectionRect())) { + hoverIsSelected = true; + break; + } + } + + Color stroke = hoverIsSelected ? mHoverSelectStrokeColor : mHoverStrokeColor; + Color fill = hoverIsSelected ? mHoverSelectFillColor : mHoverFillColor; + + if (stroke != null) { int oldAlpha = gc.getAlpha(); - gc.setForeground(mHoverStrokeColor); - gc.setLineStyle(SwtDrawingStyle.HOVER.getLineStyle()); - gc.setAlpha(SwtDrawingStyle.HOVER.getStrokeAlpha()); + gc.setForeground(stroke); + gc.setLineStyle(hoverIsSelected ? + HOVER_SELECTION.getLineStyle() : HOVER.getLineStyle()); + gc.setAlpha(hoverIsSelected ? + HOVER_SELECTION.getStrokeAlpha() : HOVER.getStrokeAlpha()); gc.drawRectangle(x, y, w, h); gc.setAlpha(oldAlpha); } - if (mHoverFillColor != null) { + if (fill != null) { int oldAlpha = gc.getAlpha(); - gc.setAlpha(SwtDrawingStyle.HOVER.getFillAlpha()); - gc.setBackground(mHoverFillColor); + gc.setAlpha(hoverIsSelected ? + HOVER_SELECTION.getFillAlpha() : HOVER.getFillAlpha()); + gc.setBackground(fill); gc.fillRectangle(x, y, w, h); gc.setAlpha(oldAlpha); } 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 b54e3d1..719fdbf 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 @@ -261,7 +261,7 @@ public class LayoutCanvas extends Canvas { // --- Set up graphic overlays // mOutlineOverlay and mEmptyOverlay are initialized lazily - mHoverOverlay = new HoverOverlay(mHScale, mVScale); + mHoverOverlay = new HoverOverlay(this, mHScale, mVScale); mHoverOverlay.create(display); mSelectionOverlay = new SelectionOverlay(this); mSelectionOverlay.create(display); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SwtDrawingStyle.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SwtDrawingStyle.java index 2748297..268fce6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SwtDrawingStyle.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SwtDrawingStyle.java @@ -44,7 +44,12 @@ public enum SwtDrawingStyle { /** * The style definition corresponding to {@link DrawingStyle#HOVER} */ - HOVER(null, 0, new RGB(0xFF, 0xFF, 0xFF), 64, 1, SWT.LINE_DOT), + HOVER(null, 0, new RGB(0xFF, 0xFF, 0xFF), 40, 1, SWT.LINE_DOT), + + /** + * The style definition corresponding to {@link DrawingStyle#HOVER} + */ + HOVER_SELECTION(null, 0, new RGB(0xFF, 0xFF, 0xFF), 10, 1, SWT.LINE_DOT), /** * The style definition corresponding to {@link DrawingStyle#ANCHOR} @@ -199,6 +204,8 @@ public enum SwtDrawingStyle { return GUIDELINE; case HOVER: return HOVER; + case HOVER_SELECTION: + return HOVER_SELECTION; case ANCHOR: return ANCHOR; case OUTLINE: |