aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-04-01 21:00:24 -0700
committerTor Norbye <tnorbye@google.com>2011-04-01 21:00:24 -0700
commit50c6e4e3a17a7a562f45c71f826abca2a4b8740f (patch)
tree52cb49305166bec3c61ac1857215cebea8935858 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android
parentece8cb547d7d041e8525f033f8d83d6af3a4c954 (diff)
downloadsdk-50c6e4e3a17a7a562f45c71f826abca2a4b8740f.zip
sdk-50c6e4e3a17a7a562f45c71f826abca2a4b8740f.tar.gz
sdk-50c6e4e3a17a7a562f45c71f826abca2a4b8740f.tar.bz2
Improve painting of combined selection and hover
When the mouse is over a rectangle, we highlight this "hover" rectangle by painting a semitranslucent white rectangle on top of it. When a view is selected, we highlight it by painting a semitranslucent blue rectangle over it. This means that if you move the mouse over the selection, you get both of these effects added together, which dilutes the underlying selected widget too much. This changeset tries to improve this situation by defining a different visual style to be used for the combination of hover and selection, where the opacity is much lower for the hover in this case. This changeset also reduces the existing hover by about 30% opacity. Change-Id: I63ffe8a9d756dcae29b2009a1a1cd6b9ffb6fbe7
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/DrawingStyle.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/HoverOverlay.java67
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SwtDrawingStyle.java9
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: