summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-02-07 09:04:47 -0800
committerTor Norbye <tnorbye@google.com>2013-02-20 18:29:25 -0800
commit2ca0d0dedaa62fefa1e67b086cf13abe891b9f58 (patch)
tree50bc8b77000815a65462c266e1cba1d3325cd46d
parent2296cd32120239ee684760643945f1a9a2bb79b5 (diff)
downloadidea-2ca0d0dedaa62fefa1e67b086cf13abe891b9f58.tar.gz
Add drawing styles abstraction
This adds a DrawingStyle enumerated type which captures the different types of visual feedback used by the layout editor, and then individual feedback and decorator code refers to these styles rather than specific colors and strokes when painting. This also changes the visual style to the ADT layout editor style. Change-Id: I1c7d00f778af6d6ffb4773121820fc6779af4b59
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java7
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/RootView.java12
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/DesignerGraphics.java222
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/DirectionResizePoint.java65
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/DrawingStyle.java294
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/InsertFeedback.java57
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/LineFeedback.java40
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/LineInsertFeedback.java41
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/NonResizeSelectionDecorator.java36
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/RectangleFeedback.java34
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/graphics/ResizeSelectionDecorator.java36
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/BorderStaticDecorator.java8
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/FrameLayoutOperation.java36
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/LinearLayoutOperation.java81
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/GridLayoutSpanOperation.java16
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutMarginOperation.java41
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutSpanOperation.java17
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutWeightOperation.java15
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/RelativeLayoutResizeOperation.java30
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/ResizeOperation.java23
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/actions/TableLayoutSpanOperation.java8
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowBaseOperation.java15
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowStaticDecorator.java9
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridDecorator.java37
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridOperation.java18
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridSelectionDecorator.java9
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/relative/RelativeDecorator.java18
-rw-r--r--android-designer/src/com/intellij/android/designer/designSurface/layout/relative/SnapPointFeedbackHost.java34
-rw-r--r--android-designer/src/com/intellij/android/designer/model/ModelParser.java5
-rw-r--r--android-designer/src/com/intellij/android/designer/model/RadViewLayout.java12
-rw-r--r--android-designer/src/com/intellij/android/designer/model/RadViewLayoutWithData.java7
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/RadAbsoluteLayout.java8
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/RadFrameLayout.java10
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/RadLinearLayout.java18
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/grid/RadGridLayout.java4
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/relative/RadRelativeLayout.java8
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/table/RadTableLayout.java8
-rw-r--r--android-designer/src/com/intellij/android/designer/model/layout/table/RadTableRowLayout.java4
38 files changed, 1097 insertions, 246 deletions
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java
index bdaeae01c1a..ffff706de6c 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java
@@ -25,6 +25,7 @@ import com.google.common.primitives.Ints;
import com.intellij.android.designer.ShadowPainter;
import com.intellij.android.designer.actions.ProfileAction;
import com.intellij.android.designer.componentTree.AndroidTreeDecorator;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.inspection.ErrorAnalyzer;
import com.intellij.android.designer.model.*;
import com.intellij.android.designer.profile.ProfileManager;
@@ -32,7 +33,7 @@ import com.intellij.designer.DesignerEditor;
import com.intellij.designer.DesignerToolWindowManager;
import com.intellij.designer.componentTree.TreeComponentDecorator;
import com.intellij.designer.designSurface.*;
-import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.NonResizeSelectionDecorator;
import com.intellij.designer.designSurface.tools.ComponentCreationFactory;
import com.intellij.designer.designSurface.tools.ComponentPasteFactory;
import com.intellij.designer.model.RadComponent;
@@ -756,11 +757,9 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
return myWrapInProvider;
}
- private static final ComponentDecorator NON_RESIZE_DECORATOR = new NonResizeSelectionDecorator(Color.RED, 2);
-
@Override
protected ComponentDecorator getRootSelectionDecorator() {
- return NON_RESIZE_DECORATOR;
+ return EmptyComponentDecorator.INSTANCE;
}
@Override
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/RootView.java b/android-designer/src/com/intellij/android/designer/designSurface/RootView.java
index d872f948a40..2ec046673a7 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/RootView.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/RootView.java
@@ -17,6 +17,8 @@ package com.intellij.android.designer.designSurface;
import com.intellij.android.designer.ImageUtils;
import com.intellij.android.designer.ShadowPainter;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.designer.designSurface.ScalableComponent;
import org.jetbrains.annotations.Nullable;
@@ -154,16 +156,12 @@ public class RootView extends com.intellij.designer.designSurface.RootView imple
if (!myEmptyRegions.isEmpty()) {
if (scale == 1) {
for (EmptyRegion r : myEmptyRegions) {
- g.setColor(r.myColor);
- g.fillRect(r.myX, r.myY, r.myWidth, r.myHeight);
+ DesignerGraphics.drawFilledRect(DrawingStyle.EMPTY, g, r.myX, r.myY, r.myWidth, r.myHeight);
}
} else {
for (EmptyRegion r : myEmptyRegions) {
- g.setColor(r.myColor);
- g.fillRect((int)(scale * r.myX),
- (int)(scale * r.myY),
- (int)(scale * r.myWidth),
- (int)(scale * r.myHeight));
+ DesignerGraphics.drawFilledRect(DrawingStyle.EMPTY, g, (int)(scale * r.myX), (int)(scale * r.myY),
+ (int)(scale * r.myWidth), (int)(scale * r.myHeight));
}
}
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/DesignerGraphics.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DesignerGraphics.java
new file mode 100644
index 00000000000..518e825e9d6
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DesignerGraphics.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class DesignerGraphics {
+ private final Graphics myGraphics;
+ private final JComponent myTarget;
+
+ public DesignerGraphics(Graphics graphics, JComponent target) {
+ myGraphics = graphics;
+ myTarget = target;
+ }
+
+ public Graphics getGraphics() {
+ return myGraphics;
+ }
+
+ /**
+ * Current style being used for drawing.
+ */
+ @NotNull
+ private DrawingStyle myStyle = DrawingStyle.INVALID;
+
+ /** Use the given style for subsequent drawing operations */
+ public void useStyle(@NotNull DrawingStyle style) {
+ myStyle = style;
+ }
+
+ public static void useStroke(DrawingStyle style, Graphics gc) {
+ Color strokeColor = style.getStrokeColor();
+ if (strokeColor != gc.getColor()) {
+ gc.setColor(strokeColor);
+ }
+ if (gc instanceof Graphics2D) {
+ Graphics2D gc2 = (Graphics2D)gc;
+ Stroke stroke = style.getStroke();
+ if (gc2.getStroke() != stroke) {
+ gc2.setStroke(stroke);
+ }
+ }
+ }
+
+ public static void useFill(DrawingStyle style, Graphics gc) {
+ Color fillColor = style.getFillColor();
+ if (fillColor != null) {
+ if (fillColor != gc.getColor()) {
+ gc.setColor(fillColor);
+ }
+ }
+ }
+
+ public void fillRect(int x, int y, int width, int height) {
+ fillRect(myStyle, myGraphics, x, y, width, height);
+ }
+
+ public static void fillRect(DrawingStyle style, Graphics gc, int x, int y, int width, int height) {
+ Color fillColor = style.getFillColor();
+ if (fillColor != null) {
+ useFill(style, gc);
+ gc.fillRect(x + 1, y + 1, width - 1, height - 1);
+ }
+ }
+
+ public static void drawFilledRect(DrawingStyle style, Graphics gc, int x, int y, int width, int height) {
+ Color fillColor = style.getFillColor();
+ if (fillColor != null) {
+ useFill(style, gc);
+ gc.fillRect(x + 1, y + 1, width - 2, height - 2);
+ }
+ useStroke(style, gc);
+ if (style.getStrokeColor() != null) {
+ gc.drawRect(x, y, width - 1, height - 1);
+ }
+ }
+
+ public void drawRect(int x, int y, int width, int height) {
+ drawRect(myStyle, myGraphics, x, y, width, height);
+ }
+
+ public static void drawRect(DrawingStyle style, Graphics gc, int x, int y, int width, int height) {
+ useStroke(style, gc);
+ gc.drawRect(x, y, width - 1, height - 1);
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2) {
+ drawLine(myStyle, myGraphics, x1, y1, x2, y2);
+ }
+
+ public static void drawLine(DrawingStyle style, Graphics gc, int x1, int y1, int x2, int y2) {
+ useStroke(style, gc);
+ gc.drawLine(x1, y1, x2, y2);
+ }
+
+
+ // arrows
+
+ private static final int MIN_LENGTH = 10;
+ private static final int ARROW_SIZE = 5;
+
+ public void drawArrow(int x1, int y1, int x2, int y2) {
+ drawArrow(myStyle, myGraphics, x1, y1, x2, y2);
+ }
+
+ public static void drawArrow(DrawingStyle style, Graphics graphics, int x1, int y1, int x2, int y2) {
+ Color strokeColor = style.getStrokeColor();
+ if (strokeColor != graphics.getColor()) {
+ graphics.setColor(strokeColor);
+ }
+ if (graphics instanceof Graphics2D) {
+ Graphics2D gc2 = (Graphics2D)graphics;
+ Stroke stroke = style.getStroke();
+ if (gc2.getStroke() != stroke) {
+ gc2.setStroke(stroke);
+ }
+ }
+
+ int arrowWidth = ARROW_SIZE;
+ int arrowHeight = ARROW_SIZE;
+
+ // Make ARROW_SIZE adjustments to ensure that the arrow has enough width to be visible
+ if (x1 == x2 && Math.abs(y1 - y2) < MIN_LENGTH) {
+ int delta = (MIN_LENGTH - Math.abs(y1 - y2)) / 2;
+ if (y1 < y2) {
+ y1 -= delta;
+ y2 += delta;
+ } else {
+ y1 += delta;
+ y2-= delta;
+ }
+
+ } else if (y1 == y2 && Math.abs(x1 - x2) < MIN_LENGTH) {
+ int delta = (MIN_LENGTH - Math.abs(x1 - x2)) / 2;
+ if (x1 < x2) {
+ x1 -= delta;
+ x2 += delta;
+ } else {
+ x1 += delta;
+ x2-= delta;
+ }
+ }
+
+ graphics.drawLine(x1, y1, x2, y2);
+
+ // Arrowhead:
+
+ if (x1 == x2) {
+ // Vertical
+ if (y2 > y1) {
+ graphics.drawLine(x2 - arrowWidth, y2 - arrowHeight, x2, y2);
+ graphics.drawLine(x2 + arrowWidth, y2 - arrowHeight, x2, y2);
+ } else {
+ graphics.drawLine(x2 - arrowWidth, y2 + arrowHeight, x2, y2);
+ graphics.drawLine(x2 + arrowWidth, y2 + arrowHeight, x2, y2);
+ }
+ } else if (y1 == y2) {
+ // Horizontal
+ if (x2 > x1) {
+ graphics.drawLine(x2 - arrowHeight, y2 - arrowWidth, x2, y2);
+ graphics.drawLine(x2 - arrowHeight, y2 + arrowWidth, x2, y2);
+ } else {
+ graphics.drawLine(x2 + arrowHeight, y2 - arrowWidth, x2, y2);
+ graphics.drawLine(x2 + arrowHeight, y2 + arrowWidth, x2, y2);
+ }
+ } else {
+ // Compute angle:
+ int dy = y2 - y1;
+ int dx = x2 - x1;
+ double angle = Math.atan2(dy, dx);
+ double lineLength = Math.sqrt(dy * dy + dx * dx);
+
+ // Imagine a line of the same length as the arrow, but with angle 0.
+ // Its two arrow lines are at (-arrowWidth, -arrowHeight) relative
+ // to the endpoint (x1 + lineLength, y1) stretching up to (x2,y2).
+ // We compute the positions of (ax,ay) for the point above and
+ // below this line and paint the lines to it:
+ double ax = x1 + lineLength - arrowHeight;
+ double ay = y1 - arrowWidth;
+ int rx = (int) (Math.cos(angle) * (ax-x1) - Math.sin(angle) * (ay-y1) + x1);
+ int ry = (int) (Math.sin(angle) * (ax-x1) + Math.cos(angle) * (ay-y1) + y1);
+ graphics.drawLine(x2, y2, rx, ry);
+
+ ay = y1 + arrowWidth;
+ rx = (int) (Math.cos(angle) * (ax-x1) - Math.sin(angle) * (ay-y1) + x1);
+ ry = (int) (Math.sin(angle) * (ax-x1) + Math.cos(angle) * (ay-y1) + y1);
+ graphics.drawLine(x2, y2, rx, ry);
+ }
+ }
+
+ public static void drawCross(DrawingStyle style, Graphics g, int radius) {
+ int size2 = (radius - 3) / 2;
+ Color fillColor = style.getFillColor();
+ if (fillColor != null) {
+ fillRect(style, g, 0, size2, radius, 3);
+ fillRect(style, g, size2, 0, 3, radius);
+ } else {
+ drawLine(style, g, 0, size2 + 1, radius, size2 + 1);
+ drawLine(style, g, size2 + 1, 0, size2 + 1, radius);
+ }
+ }
+
+ public JComponent getTarget() {
+ return myTarget;
+ }
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/DirectionResizePoint.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DirectionResizePoint.java
new file mode 100644
index 00000000000..fcc26a0541a
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DirectionResizePoint.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import com.intellij.designer.designSurface.DecorationLayer;
+import com.intellij.designer.model.RadComponent;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+/**
+ * A replacement of the ui-core DirectionResizePoint which uses a logical drawing style instead of
+ * a hardcoded color.
+ */
+public class DirectionResizePoint extends com.intellij.designer.designSurface.selection.DirectionResizePoint {
+ private final DrawingStyle myStyle;
+
+ public DirectionResizePoint(DrawingStyle style, int direction, Object type, @Nullable String description) {
+ super(Color.RED /* should not be used */, Color.RED /* should not be used */, direction, type, description);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
+ Point location = getLocation(layer, component);
+ int size = getSize();
+ DesignerGraphics.drawFilledRect(myStyle, g, location.x, location.y, size, size);
+ }
+
+ @Override
+ protected int getSize() {
+ return 7;
+ }
+
+ @Override
+ protected int getNeighborhoodSize() {
+ return 2;
+ }
+
+ @Override
+ protected Point getLocation(DecorationLayer layer, RadComponent component) {
+ Point location = super.getLocation(layer, component);
+ if (myXSeparator == 0) {
+ location.x++;
+ }
+ if (myYSeparator == 0) {
+ location.y++;
+ }
+
+ return location;
+ }
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/DrawingStyle.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DrawingStyle.java
new file mode 100644
index 00000000000..a421e710fd8
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/DrawingStyle.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+/**
+ * Drawing styles are used to distinguish the visual appearance of selection,
+ * hovers, anchors, etc. Each style may have different colors, line thickness,
+ * dashing style, transparency, etc.
+ */
+public class DrawingStyle {
+ /** Whether we should show a static grid of all the linear layout insert positions or not
+ * (if false, it is shown only during an active drag) */
+ public static final boolean SHOW_STATIC_GRID = false;
+
+ /** Whether we should show a static border around selected views */
+ public static final boolean SHOW_STATIC_BORDERS = false;
+
+ private static final BasicStroke SOLID_STROKE = new BasicStroke(1.0f);
+ private static final BasicStroke THICK_SOLID_STROKE = new BasicStroke(2.0f);
+ private static final BasicStroke DOTTED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
+ new float[] { 2, 2 }, 0.0f);
+ private static final BasicStroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
+ new float[] { 4, 4 }, 0.0f);
+ private static final BasicStroke PATTERN_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
+ new float[] { 8, 4 }, 0.0f);
+ private static final BasicStroke THICK_PATTERN_STROKE = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
+ new float[] { 8, 4 }, 0.0f);
+
+ /**
+ * The style used to draw the selected views
+ */
+ public static final DrawingStyle SELECTION = new DrawingStyle(new Color(0x00, 0x99, 0xFF, 192),
+ new Color(0x00, 0x99, 0xFF, 192), SOLID_STROKE);
+
+ /**
+ * The style used to draw guidelines - overlay lines which indicate
+ * significant geometric positions.
+ */
+ public static final DrawingStyle GUIDELINE = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), SOLID_STROKE);
+
+ /**
+ * The style used to guideline shadows
+ */
+ public static final DrawingStyle GUIDELINE_SHADOW = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), SOLID_STROKE);
+
+ /**
+ * The style used to draw guidelines, in particular shared edges and center lines; this
+ * is a dashed edge.
+ */
+ public static final DrawingStyle GUIDELINE_DASHED = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), PATTERN_STROKE);
+
+ /**
+ * The style used to draw distance annotations
+ */
+ public static final DrawingStyle DISTANCE = new DrawingStyle(new Color(0xFF, 0x00, 0x00, 192 - 32), SOLID_STROKE);
+
+ /**
+ * The style used to draw grids
+ */
+ public static final DrawingStyle GRID = new DrawingStyle(new Color(0xAA, 0xAA, 0xAA, 128), DOTTED_STROKE);
+
+ /**
+ * The style used for hovered views (e.g. when the mouse is directly on top
+ * of the view)
+ */
+ public static final DrawingStyle HOVER = new DrawingStyle(null, new Color(0xFF, 0xFF, 0xFF, 40), DOTTED_STROKE);
+
+ /**
+ * 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
+ */
+ public static final DrawingStyle HOVER_SELECTION = new DrawingStyle(null, new Color(0xFF, 0xFF, 0xFF, 10), DOTTED_STROKE);
+
+ /**
+ * The style used to draw anchors (lines to the other views the given view
+ * is anchored to)
+ */
+ public static final DrawingStyle ANCHOR = new DrawingStyle(new Color(0x00, 0x99, 0xFF, 96), SOLID_STROKE);
+
+ /**
+ * The style used to draw outlines (the structure of views)
+ */
+ public static final DrawingStyle OUTLINE = new DrawingStyle(new Color(0x88, 0xFF, 0x88, 160), SOLID_STROKE);
+
+ /**
+ * The style used to draw the recipient/target View of a drop. This is
+ * typically going to be the bounding-box of the view into which you are
+ * adding a new child.
+ */
+ public static final DrawingStyle DROP_RECIPIENT = new DrawingStyle(new Color(0xFF, 0x99, 0x00, 255),
+ new Color(0xFF, 0x99, 0x00, 160), THICK_SOLID_STROKE);
+
+ /**
+ * The style used to draw a potential drop area <b>within</b> a
+ * {@link #DROP_RECIPIENT}. For example, if you are dragging into a view
+ * with a LinearLayout, the {@link #DROP_RECIPIENT} will be the view itself,
+ * whereas each possible insert position between two children will be a
+ * {@link #DROP_ZONE}. If the mouse is over a {@link #DROP_ZONE} it should
+ * be drawn using the style {@link #DROP_ZONE_ACTIVE}.
+ */
+ public static final DrawingStyle DROP_ZONE = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 220),
+ new Color(0x55, 0xAA, 0x00, 64), SOLID_STROKE);
+
+ /**
+ * The style used to draw a currently active drop zone within a drop
+ * recipient. See the documentation for {@link #DROP_ZONE} for details on
+ * the distinction between {@link #DROP_RECIPIENT}, {@link #DROP_ZONE} and
+ * {@link #DROP_ZONE_ACTIVE}.
+ */
+ public static final DrawingStyle DROP_ZONE_ACTIVE = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 220),
+ new Color(0x00, 0xAA, 0x00, 64), THICK_SOLID_STROKE);
+
+ /**
+ * The style used to draw a preview of where a dropped view would appear if
+ * it were to be dropped at a given location.
+ */
+ public static final DrawingStyle DROP_PREVIEW = new DrawingStyle(new Color(0xFF, 0x99, 0x00, 255), null, THICK_PATTERN_STROKE);
+
+ /**
+ * The style used to preview a resize operation. Similar to {@link #DROP_PREVIEW}
+ * but usually fainter to work better in combination with guidelines which
+ * are often overlaid during resize.
+ */
+ public static final DrawingStyle RESIZE_PREVIEW = new DrawingStyle(new Color(0xFF, 0x99, 0x00, 255), null, THICK_SOLID_STROKE);
+
+ /**
+ * The style used to show a proposed resize bound which is being rejected (for example,
+ * because there is no near edge to attach to in a RelativeLayout).
+ */
+ public static final DrawingStyle RESIZE_FAIL = new DrawingStyle(new Color(0xFF, 0x99, 0x00, 255), null, THICK_PATTERN_STROKE);
+
+ /**
+ * The style used to draw help/hint text.
+ */
+ public static final DrawingStyle HELP = new DrawingStyle(new Color(0xFF, 0xFF, 0xFF, 255),
+ new Color(0x00, 0x00, 0x00, 128), SOLID_STROKE);
+
+ /**
+ * The style used to draw illegal/error/invalid markers
+ */
+ public static final DrawingStyle INVALID = new DrawingStyle(new Color(0xFF, 0xFF, 0xFF, 192),
+ new Color(0xFF, 0x00, 0x00, 64), THICK_SOLID_STROKE);
+
+ /**
+ * The style used to highlight dependencies
+ */
+ public static final DrawingStyle DEPENDENCY = new DrawingStyle(new Color(0xFF, 0xFF, 0xFF, 255),
+ new Color(0xFF, 0xFF, 0x00, 24), THICK_SOLID_STROKE);
+
+ /**
+ * The style used to draw an invalid cycle
+ */
+ public static final DrawingStyle CYCLE = new DrawingStyle(new Color(0xFF, 0x00, 0x00, 192), null, SOLID_STROKE);
+
+ /**
+ * The style used to highlight the currently dragged views during a layout
+ * move (if they are not hidden)
+ */
+ public static final DrawingStyle DRAGGED = new DrawingStyle(new Color(0xFF, 0xFF, 0xFF, 255),
+ new Color(0x00, 0xFF, 0x00, 16), THICK_SOLID_STROKE);
+
+ /**
+ * The style used to draw empty containers of zero bounds (which are padded
+ * a bit to make them visible during a drag or selection).
+ */
+ public static final DrawingStyle EMPTY = new DrawingStyle(new Color(0x00, 0x00, 0x00, 128),
+ new Color(0xFF, 0xFF, 0x55, 255), DASHED_STROKE);
+
+ /**
+ * A style used for unspecified purposes; can be used by a client to have
+ * yet another color that is domain specific; using this color constant
+ * rather than your own hardcoded value means that you will be guaranteed to
+ * pick up a color that is themed properly and will look decent with the
+ * rest of the colors
+ */
+ public static final DrawingStyle CUSTOM1 = new DrawingStyle(new Color(0xFF, 0x00, 0xFF, 255), null, SOLID_STROKE);
+
+ /**
+ * A second styled used for unspecified purposes; see {@link #CUSTOM1} for
+ * details.
+ */
+ public static final DrawingStyle CUSTOM2 = new DrawingStyle(new Color(0x00, 0xFF, 0xFF, 255), null, DOTTED_STROKE);
+
+ /** Style used to draw wrap_content resize feedback */
+ public static final DrawingStyle RESIZE_WRAP = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), DASHED_STROKE);
+
+ /** Style used to edit margins bounds */
+ public static final DrawingStyle MARGIN_BOUNDS = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), new Color(0x00, 0xAA, 0x00, 64),
+ DASHED_STROKE);
+
+ /** Style used to edit margin resizing bars */
+ public static final DrawingStyle MARGIN_HANDLE = new DrawingStyle(new Color(0x00, 0xAA, 0x00, 192), new Color(0x00, 0xAA, 0x00, 64),
+ SOLID_STROKE);
+
+ /** Style used to show gravity locations */
+ public static final DrawingStyle GRAVITY = new DrawingStyle(new Color(0xFF, 0x00, 0x00, 192), null, THICK_PATTERN_STROKE);
+
+ /** Resizing by weights */
+ public static final DrawingStyle RESIZE_WEIGHTS = new DrawingStyle(new Color(0x00, 0xFF, 0xFF, 192), new Color(0x00, 0xFF, 0xFF, 64),
+ SOLID_STROKE);
+
+ /** Resizing by spans (column span, row span) */
+ public static final DrawingStyle RESIZE_SPAN = new DrawingStyle(new Color(0x00, 0xFF, 0xFF, 192), new Color(0x00, 0xFF, 0xFF, 64),
+ SOLID_STROKE);
+
+ /**
+ * Construct a new style value with the given foreground, background, width,
+ * line style and transparency.
+ *
+ * @param stroke A color descriptor for the foreground color, or null if no
+ * foreground color should be set
+ * @param fill A color descriptor for the background color, or null if no
+ * foreground color should be set
+ * @param stroke The line style - such as {@link #SOLID_STROKE}.
+ */
+ public DrawingStyle(@Nullable Color strokeColor, @Nullable Color fill, @NotNull BasicStroke stroke) {
+ myStrokeColor = strokeColor;
+ myStroke = stroke;
+ myFillColor = fill;
+ myLineWidth = (int)stroke.getLineWidth();
+ }
+
+ /**
+ * Convenience constructor for typical drawing styles, which do not specify
+ * a fill and use a standard thickness line
+ *
+ * @param strokeColor Stroke color to be used (e.g. for the border/foreground)
+ * @param stroke The line style - such as {@link #SOLID_STROKE}.
+ */
+ public DrawingStyle(@Nullable Color strokeColor, @NotNull BasicStroke stroke) {
+ this(strokeColor, null, stroke);
+ }
+
+ /**
+ * Returns the thickness of the line as an integer
+ * @return the line thickness
+ */
+ public int getLineWidth() {
+ return myLineWidth;
+ }
+
+ /**
+ * Return the stroke/foreground/border color to be used for
+ * this style, or null if none
+ */
+ @Nullable
+ public Color getStrokeColor() {
+ return myStrokeColor;
+ }
+
+ /** Return the line stroke style */
+ @NotNull
+ public Stroke getStroke() {
+ return myStroke;
+ }
+
+ /**
+ * Return the fill/background/interior color to be used for
+ * this style, or null if none
+ */
+ @Nullable
+ public Color getFillColor() {
+ return myFillColor;
+ }
+
+ private final int myLineWidth;
+
+ /** Stroke/foreground/border color */
+ private final Color myStrokeColor;
+
+ /** Stroke type */
+ private final Stroke myStroke;
+
+ /** Fill/foreground/interior color */
+ private final Color myFillColor;
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/InsertFeedback.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/InsertFeedback.java
new file mode 100644
index 00000000000..75b29ff4996
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/InsertFeedback.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import java.awt.*;
+
+public class InsertFeedback extends com.intellij.designer.designSurface.feedbacks.InsertFeedback {
+ private final DrawingStyle myStyle;
+
+ public InsertFeedback(DrawingStyle style) {
+ super(Color.RED /* should not be used */);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paintLines(Graphics g) {
+ if (myCross) {
+ int size = getWidth();
+ DesignerGraphics.drawCross(myStyle, g, size);
+ }
+ else {
+ Dimension size = getSize();
+ if (myHorizontal) {
+ paintHorizontal(g, size);
+ }
+ else {
+ paintVertical(g, size);
+ }
+ }
+ }
+
+ @Override
+ protected void paintHorizontal(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, 0, middle, size.width, middle);
+ }
+
+ @Override
+ protected void paintVertical(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, middle, 0, middle, size.height);
+ }}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineFeedback.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineFeedback.java
new file mode 100644
index 00000000000..fc06dc0581c
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineFeedback.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class LineFeedback extends com.intellij.designer.designSurface.feedbacks.LineFeedback {
+ private final DrawingStyle myStyle;
+
+ public LineFeedback(DrawingStyle style, boolean horizontal) {
+ super(Color.RED /* should not be used */, 1 /* should not be used */, horizontal);
+ myStyle = style;
+ }
+
+ protected void paintHorizontal(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, 0, middle, size.width, middle);
+ }
+
+ protected void paintVertical(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, middle, 0, middle, size.height);
+ }
+} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineInsertFeedback.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineInsertFeedback.java
new file mode 100644
index 00000000000..790c2533535
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/LineInsertFeedback.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import java.awt.*;
+
+public class LineInsertFeedback extends com.intellij.designer.designSurface.feedbacks.LineInsertFeedback {
+ private final DrawingStyle myStyle;
+
+ public LineInsertFeedback(DrawingStyle style, boolean horizontal) {
+ super(Color.RED /* should not be used */, horizontal);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paintHorizontal(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, 0, middle, size.width, middle);
+ }
+
+ @Override
+ protected void paintVertical(Graphics g, Dimension size) {
+ int lineWidth = myStyle.getLineWidth();
+ int middle = lineWidth / 2;
+ DesignerGraphics.drawLine(myStyle, g, middle, 0, middle, size.height);
+ }
+} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/NonResizeSelectionDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/NonResizeSelectionDecorator.java
new file mode 100644
index 00000000000..cc6e6a5decb
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/NonResizeSelectionDecorator.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import com.intellij.designer.designSurface.DecorationLayer;
+import com.intellij.designer.model.RadComponent;
+
+import java.awt.*;
+
+public class NonResizeSelectionDecorator extends com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator {
+ private final DrawingStyle myStyle;
+
+ public NonResizeSelectionDecorator(DrawingStyle style) {
+ super(Color.RED /* should not be used */, 1 /* should not be used */);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
+ Rectangle bounds = getBounds(layer, component);
+ DesignerGraphics.drawRect(myStyle, g, bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/RectangleFeedback.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/RectangleFeedback.java
new file mode 100644
index 00000000000..f81b738d4cb
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/RectangleFeedback.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class RectangleFeedback extends com.intellij.designer.designSurface.feedbacks.RectangleFeedback {
+ private final DrawingStyle myStyle;
+
+ public RectangleFeedback(DrawingStyle style) {
+ super(Color.RED /* should not be used */, 1 /* should not be used */);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paintFeedback(Graphics g) {
+ Dimension size = getSize();
+ DesignerGraphics.drawRect(myStyle, g, 0, 0, size.width, size.height);
+ }
+} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/graphics/ResizeSelectionDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/graphics/ResizeSelectionDecorator.java
new file mode 100644
index 00000000000..c72174322ef
--- /dev/null
+++ b/android-designer/src/com/intellij/android/designer/designSurface/graphics/ResizeSelectionDecorator.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.intellij.android.designer.designSurface.graphics;
+
+import com.intellij.designer.designSurface.DecorationLayer;
+import com.intellij.designer.model.RadComponent;
+
+import java.awt.*;
+
+public class ResizeSelectionDecorator extends com.intellij.designer.designSurface.selection.ResizeSelectionDecorator {
+ private final DrawingStyle myStyle;
+
+ public ResizeSelectionDecorator(DrawingStyle style) {
+ super(Color.RED /* should not be used */, 1 /* should not be used */);
+ myStyle = style;
+ }
+
+ @Override
+ protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
+ Rectangle bounds = getBounds(layer, component);
+ DesignerGraphics.drawRect(myStyle, g, bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/BorderStaticDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/BorderStaticDecorator.java
index b5e20fc04e1..f935cb18f28 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/BorderStaticDecorator.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/BorderStaticDecorator.java
@@ -15,6 +15,8 @@
*/
package com.intellij.android.designer.designSurface.layout;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.designer.designSurface.DecorationLayer;
import com.intellij.designer.designSurface.StaticDecorator;
import com.intellij.designer.model.RadComponent;
@@ -25,8 +27,6 @@ import java.awt.*;
* @author Alexander Lobas
*/
public class BorderStaticDecorator extends StaticDecorator {
- public static final Color COLOR = new Color(47, 67, 96);
-
public BorderStaticDecorator(RadComponent component) {
super(component);
}
@@ -34,8 +34,6 @@ public class BorderStaticDecorator extends StaticDecorator {
@Override
protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
Rectangle bounds = component.getBounds(layer);
-
- g.setColor(COLOR);
- g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ DesignerGraphics.drawRect(DrawingStyle.DROP_RECIPIENT, g, bounds.x, bounds.y, bounds.width, bounds.height);
}
} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/FrameLayoutOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/FrameLayoutOperation.java
index 33f33f87db0..eb79a36f2f3 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/FrameLayoutOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/FrameLayoutOperation.java
@@ -17,21 +17,21 @@ package com.intellij.android.designer.designSurface.layout;
import com.android.SdkConstants;
import com.intellij.android.designer.designSurface.AbstractEditOperation;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.model.layout.Gravity;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.feedbacks.AlphaFeedback;
import com.intellij.designer.designSurface.feedbacks.TextFeedback;
import com.intellij.designer.model.RadComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.JBColor;
-import com.intellij.ui.LightColors;
import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.awt.*;
import java.util.Collections;
import java.util.Set;
@@ -195,12 +195,11 @@ public class FrameLayoutOperation extends AbstractEditOperation {
private static final Gravity[] HORIZONTALS = {Gravity.left, Gravity.center, Gravity.right};
private static final Gravity[] VERTICALS = {Gravity.top, Gravity.center, Gravity.bottom};
- private class GravityFeedback extends AlphaFeedback {
+ private class GravityFeedback extends JComponent {
private Gravity myHorizontal;
private Gravity myVertical;
public GravityFeedback() {
- super(JBColor.GREEN);
}
public void setGravity(Gravity horizontal, Gravity vertical) {
@@ -210,28 +209,20 @@ public class FrameLayoutOperation extends AbstractEditOperation {
}
@Override
- protected void paintOther1(Graphics2D g2d) {
- for (Gravity h : HORIZONTALS) {
- for (Gravity v : VERTICALS) {
- if (!exclude(h, v)) {
- paintCell(g2d, h, v, false);
- }
- }
- }
- }
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
- @Override
- protected void paintOther2(Graphics2D g2d) {
for (Gravity h : HORIZONTALS) {
for (Gravity v : VERTICALS) {
- if (paintCell(g2d, h, v, true)) {
- break;
+ boolean selection = (myHorizontal == h && myVertical == v);
+ if (selection || !exclude(h, v)) {
+ paintCell(g, h, v, selection);
}
}
}
}
- private boolean paintCell(Graphics2D g2d, Gravity horizontal, Gravity vertical, boolean selection) {
+ private boolean paintCell(Graphics g, Gravity horizontal, Gravity vertical, boolean selection) {
int x = 0;
int width = (getWidth() - 2) / 3;
if (horizontal == Gravity.center) {
@@ -264,16 +255,13 @@ public class FrameLayoutOperation extends AbstractEditOperation {
if (selection) {
if (myHorizontal == horizontal && myVertical == vertical) {
- Color oldColor = g2d.getColor();
- g2d.setColor(LightColors.YELLOW);
- g2d.fillRect(x, y, width, height);
- g2d.setColor(oldColor);
+ DesignerGraphics.drawFilledRect(DrawingStyle.DROP_ZONE_ACTIVE, g, x, y, width, height);
return true;
}
}
else {
- g2d.fillRect(x, y, width, height);
+ DesignerGraphics.drawFilledRect(DrawingStyle.DROP_ZONE, g, x, y, width, height);
}
return false;
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/LinearLayoutOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/LinearLayoutOperation.java
index 4aef0d13b75..b88f5e8807b 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/LinearLayoutOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/LinearLayoutOperation.java
@@ -16,6 +16,8 @@
package com.intellij.android.designer.designSurface.layout;
import com.android.SdkConstants;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
import com.intellij.android.designer.designSurface.layout.flow.FlowBaseOperation;
import com.intellij.android.designer.model.ModelParser;
@@ -30,19 +32,21 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.List;
+import static com.intellij.android.designer.designSurface.graphics.DrawingStyle.SHOW_STATIC_GRID;
+
/**
* @author Alexander Lobas
*/
public class LinearLayoutOperation extends FlowBaseOperation {
private GravityFeedback myFeedback;
private TextFeedback myTextFeedback;
+ private FlowPositionFeedback myFlowFeedback;
private Gravity myExclude;
private Gravity myGravity;
@@ -67,6 +71,13 @@ public class LinearLayoutOperation extends FlowBaseOperation {
}
layer.add(myFeedback, 0);
+ //noinspection ConstantConditions
+ if (!SHOW_STATIC_GRID) {
+ myFlowFeedback = new FlowPositionFeedback();
+ myFlowFeedback.setBounds(myBounds);
+ layer.add(myFlowFeedback, 0);
+ }
+
myTextFeedback = new TextFeedback();
myTextFeedback.setBorder(IdeBorderFactory.createEmptyBorder(0, 3, 2, 0));
layer.add(myTextFeedback);
@@ -88,6 +99,11 @@ public class LinearLayoutOperation extends FlowBaseOperation {
myFeedback.setGravity(gravity);
+ //noinspection ConstantConditions
+ if (!SHOW_STATIC_GRID) {
+ myFlowFeedback.repaint();
+ }
+
myTextFeedback.clear();
myTextFeedback.bold(gravity == null ? "fill_parent" : gravity.name());
myTextFeedback.centerTop(myBounds);
@@ -102,6 +118,12 @@ public class LinearLayoutOperation extends FlowBaseOperation {
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
layer.remove(myFeedback);
layer.remove(myTextFeedback);
+
+ //noinspection ConstantConditions
+ if (!SHOW_STATIC_GRID) {
+ layer.remove(myFlowFeedback);
+ }
+
layer.repaint();
myFeedback = null;
myTextFeedback = null;
@@ -212,7 +234,45 @@ public class LinearLayoutOperation extends FlowBaseOperation {
//
//////////////////////////////////////////////////////////////////////////////////////////
- private static final int SIZE = 2;
+ private class FlowPositionFeedback extends JComponent {
+ @Override
+ public void paint(Graphics graphics) {
+ super.paint(graphics);
+ }
+
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ Rectangle bounds = myContainer.getBounds(this);
+ RadComponent component = myContainer;
+ DesignerGraphics.drawRect(DrawingStyle.DROP_RECIPIENT, g, bounds.x, bounds.y, bounds.width, bounds.height);
+
+ if (myHorizontal) {
+ for (RadComponent child : component.getChildren()) {
+ Rectangle childBounds = child.getBounds(this);
+ int marginWidth = ((RadViewComponent)child).getMargins().width;
+ if (marginWidth != 0) {
+ marginWidth = child.fromModel(this, new Dimension(marginWidth, 0)).width;
+ }
+ int x = childBounds.x + childBounds.width + marginWidth;
+ DesignerGraphics.drawLine(DrawingStyle.DROP_ZONE, g, x, bounds.y, x, bounds.y + bounds.height);
+ }
+ }
+ else {
+ for (RadComponent child : component.getChildren()) {
+ Rectangle childBounds = child.getBounds(this);
+ int marginHeight = ((RadViewComponent)child).getMargins().height;
+ if (marginHeight != 0) {
+ marginHeight = child.fromModel(this, new Dimension(0, marginHeight)).height;
+ }
+ int y = childBounds.y + childBounds.height + marginHeight;
+ DesignerGraphics.drawLine(DrawingStyle.DROP_ZONE, g, bounds.x, y, bounds.x + bounds.width, y);
+ }
+ }
+ }
+ }
private class GravityFeedback extends JComponent {
private Gravity myGravity;
@@ -222,9 +282,9 @@ public class LinearLayoutOperation extends FlowBaseOperation {
repaint();
}
+ @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
- g.setColor(JBColor.MAGENTA);
if (myHorizontal) {
paintHorizontalCell(g);
@@ -253,12 +313,13 @@ public class LinearLayoutOperation extends FlowBaseOperation {
height -= 2 * vSpace;
}
+ int thickness = DrawingStyle.GRAVITY.getLineWidth();
if (myContainer.getChildren().isEmpty()) {
- g.fillRect(0, y, 2, height);
- g.fillRect(myBounds.width - SIZE, y, SIZE, height);
+ DesignerGraphics.drawFilledRect(DrawingStyle.GRAVITY, g, 0, y, thickness, height);
+ DesignerGraphics.drawFilledRect(DrawingStyle.GRAVITY, g, myBounds.width - thickness, y, thickness, height);
}
else {
- g.fillRect(SIZE, y, SIZE, height);
+ DesignerGraphics.drawLine(DrawingStyle.GRAVITY, g, thickness / 2, y, thickness / 2, y + height);
}
}
@@ -281,12 +342,14 @@ public class LinearLayoutOperation extends FlowBaseOperation {
width -= 2 * hSpace;
}
+ int thickness = DrawingStyle.GRAVITY.getLineWidth();
if (myContainer.getChildren().isEmpty()) {
- g.fillRect(x, 0, width, SIZE);
- g.fillRect(x, myBounds.height - SIZE, width, SIZE);
+ DesignerGraphics.drawFilledRect(DrawingStyle.GRAVITY, g, x, 0, width, thickness);
+ DesignerGraphics.drawFilledRect(DrawingStyle.GRAVITY, g, x, myBounds.height - thickness, width, thickness);
+
}
else {
- g.fillRect(x, SIZE, width, SIZE);
+ DesignerGraphics.drawLine(DrawingStyle.GRAVITY, g, x, thickness / 2, x + width, thickness / 2);
}
}
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/GridLayoutSpanOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/GridLayoutSpanOperation.java
index e3b049fb414..9229819967f 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/GridLayoutSpanOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/GridLayoutSpanOperation.java
@@ -70,30 +70,22 @@ public class GridLayoutSpanOperation extends LayoutSpanOperation {
//////////////////////////////////////////////////////////////////////////////////////////
public static void points(GridSelectionDecorator decorator) {
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.WEST,
+ decorator.addPoint(new SpanPoint(Position.WEST,
TYPE,
"Change layout:column x layout:columnSpan",
decorator)); // left
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.EAST,
+ decorator.addPoint(new SpanPoint(Position.EAST,
TYPE,
"Change layout:columnSpan",
decorator).move(1, 0.75)); // right
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.NORTH,
+ decorator.addPoint(new SpanPoint(Position.NORTH,
TYPE,
"Change layout:row x layout:rowSpan",
decorator)); // top
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.SOUTH,
+ decorator.addPoint(new SpanPoint(Position.SOUTH,
TYPE,
"Change layout:rowSpan",
decorator).move(0.75, 1)); // bottom
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutMarginOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutMarginOperation.java
index db1a98bc049..cce0b497bc6 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutMarginOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutMarginOperation.java
@@ -17,22 +17,19 @@ package com.intellij.android.designer.designSurface.layout.actions;
import com.android.SdkConstants;
import com.intellij.android.designer.AndroidDesignerUtils;
+import com.intellij.android.designer.designSurface.graphics.*;
import com.intellij.android.designer.model.ModelParser;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.designSurface.*;
import com.intellij.designer.designSurface.feedbacks.LineMarginBorder;
-import com.intellij.designer.designSurface.feedbacks.RectangleFeedback;
import com.intellij.designer.designSurface.feedbacks.TextFeedback;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
import com.intellij.designer.designSurface.selection.EmptyPoint;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -74,17 +71,13 @@ public class LayoutMarginOperation implements EditOperation {
myTextFeedback.setBorder(new LineMarginBorder(0, 5, 3, 0));
layer.add(myTextFeedback);
- myFeedback = new RectangleFeedback(getFeedbackColor(), 2);
+ myFeedback = new RectangleFeedback(DrawingStyle.MARGIN_BOUNDS);
layer.add(myFeedback);
layer.repaint();
}
}
- protected Color getFeedbackColor() {
- return JBColor.ORANGE;
- }
-
@Override
public void showFeedback() {
createFeedback();
@@ -197,7 +190,7 @@ public class LayoutMarginOperation implements EditOperation {
public static void points(ResizeSelectionDecorator decorator) {
pointFeedback(decorator);
- decorator.addPoint(new DirectionResizePoint(JBColor.ORANGE, Color.black, Position.WEST, TYPE, "Change layout:margin.left") { // left
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.MARGIN_HANDLE, Position.WEST, TYPE, "Change layout:margin.left") { // left
@Override
protected Point getLocation(DecorationLayer layer, RadComponent component) {
Point location = super.getLocation(layer, component);
@@ -211,9 +204,9 @@ public class LayoutMarginOperation implements EditOperation {
}
});
- pointRight(decorator, JBColor.ORANGE, 0.25, TYPE, "Change layout:margin.right");
+ pointRight(decorator, DrawingStyle.MARGIN_HANDLE, 0.25, TYPE, "Change layout:margin.right");
- decorator.addPoint(new DirectionResizePoint(JBColor.ORANGE, Color.black, Position.NORTH, TYPE, "Change layout:margin.top") { // top
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.MARGIN_HANDLE, Position.NORTH, TYPE, "Change layout:margin.top") { // top
@Override
protected Point getLocation(DecorationLayer layer, RadComponent component) {
Point location = super.getLocation(layer, component);
@@ -227,31 +220,29 @@ public class LayoutMarginOperation implements EditOperation {
}
});
- pointBottom(decorator, JBColor.ORANGE, 0.25, TYPE, "Change layout:margin.bottom");
+ pointBottom(decorator, DrawingStyle.MARGIN_HANDLE, 0.25, TYPE, "Change layout:margin.bottom");
}
- public static final BasicStroke STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[]{1, 2}, 0);
-
protected static void pointFeedback(ResizeSelectionDecorator decorator) {
decorator.addPoint(new EmptyPoint() {
@Override
protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
Rectangle bounds = component.getBounds(layer);
- applyMargins(bounds, layer, component, ((RadViewComponent)component).getMargins());
-
- g.setStroke(STROKE);
- g.setColor(JBColor.RED);
- g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ Rectangle margins = ((RadViewComponent)component).getMargins();
+ if (margins.x != 0 || margins.y != 0 || margins.width != 0 || margins.height != 0) {
+ applyMargins(bounds, layer, component, margins);
+ DesignerGraphics.drawRect(DrawingStyle.MARGIN_BOUNDS, g, bounds.x, bounds.y, bounds.width, bounds.height);
+ }
}
});
}
protected static void pointRight(ResizeSelectionDecorator decorator,
- Color color,
+ DrawingStyle style,
double ySeparator,
Object type,
@Nullable String description) {
- decorator.addPoint(new DirectionResizePoint(color, Color.black, Position.EAST, type, description) {
+ decorator.addPoint(new DirectionResizePoint(style, Position.EAST, type, description) {
@Override
protected Point getLocation(DecorationLayer layer, RadComponent component) {
Point location = super.getLocation(layer, component);
@@ -267,11 +258,11 @@ public class LayoutMarginOperation implements EditOperation {
}
protected static void pointBottom(ResizeSelectionDecorator decorator,
- Color color,
+ DrawingStyle style,
double xSeparator,
Object type,
@Nullable String description) {
- decorator.addPoint(new DirectionResizePoint(color, Color.black, Position.SOUTH, type, description) {
+ decorator.addPoint(new DirectionResizePoint(style, Position.SOUTH, type, description) {
@Override
protected Point getLocation(DecorationLayer layer, RadComponent component) {
Point location = super.getLocation(layer, component);
@@ -306,4 +297,4 @@ public class LayoutMarginOperation implements EditOperation {
bounds.width += bottomRight.width;
bounds.height += bottomRight.height;
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutSpanOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutSpanOperation.java
index dc89500edf5..eaa24007b09 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutSpanOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutSpanOperation.java
@@ -16,6 +16,9 @@
package com.intellij.android.designer.designSurface.layout.actions;
import com.android.SdkConstants;
+import com.intellij.android.designer.designSurface.graphics.DirectionResizePoint;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
+import com.intellij.android.designer.designSurface.graphics.RectangleFeedback;
import com.intellij.android.designer.designSurface.layout.grid.GridSelectionDecorator;
import com.intellij.android.designer.model.ModelParser;
import com.intellij.android.designer.model.RadViewComponent;
@@ -25,11 +28,7 @@ import com.intellij.designer.designSurface.DecorationLayer;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.feedbacks.AlphaFeedback;
-import com.intellij.designer.designSurface.feedbacks.LineMarginBorder;
-import com.intellij.designer.designSurface.feedbacks.RectangleFeedback;
-import com.intellij.designer.designSurface.feedbacks.TextFeedback;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
+import com.intellij.designer.designSurface.feedbacks.*;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.application.ApplicationManager;
@@ -87,7 +86,7 @@ public abstract class LayoutSpanOperation implements EditOperation {
myTextFeedback.setBorder(new LineMarginBorder(0, 5, 3, 0));
layer.add(myTextFeedback);
- myFeedback = new RectangleFeedback(COLOR, 2);
+ myFeedback = new RectangleFeedback(DrawingStyle.RESIZE_PREVIEW);
layer.add(myFeedback);
myErrorFeedback = new ErrorFeedback();
@@ -447,13 +446,11 @@ public abstract class LayoutSpanOperation implements EditOperation {
protected static class SpanPoint extends DirectionResizePoint {
private final GridSelectionDecorator myDecorator;
- public SpanPoint(Color color,
- Color border,
- int direction,
+ public SpanPoint(int direction,
Object type,
@Nullable String description,
GridSelectionDecorator decorator) {
- super(color, border, direction, type, description);
+ super(DrawingStyle.RESIZE_SPAN, direction, type, description);
myDecorator = decorator;
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutWeightOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutWeightOperation.java
index 4b90e4d4b0f..9f466ad434d 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutWeightOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/LayoutWeightOperation.java
@@ -17,13 +17,13 @@ package com.intellij.android.designer.designSurface.layout.actions;
import com.android.SdkConstants;
import com.android.utils.XmlUtils;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.ModelParser;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.ui.JBColor;
import java.awt.*;
@@ -52,11 +52,6 @@ public class LayoutWeightOperation extends LayoutMarginOperation {
}
@Override
- protected Color getFeedbackColor() {
- return JBColor.CYAN;
- }
-
- @Override
protected void fillTextFeedback() {
Dimension sizeDelta = myContext.getSizeDelta();
int direction = myContext.getResizeDirection();
@@ -114,7 +109,7 @@ public class LayoutWeightOperation extends LayoutMarginOperation {
public static void point(ResizeSelectionDecorator decorator) {
pointFeedback(decorator);
- pointRight(decorator, JBColor.CYAN, 0.75, TYPE, "Change layout:weight");
- pointBottom(decorator, JBColor.CYAN, 0.75, TYPE, "Change layout:weight");
+ pointRight(decorator, DrawingStyle.RESIZE_WEIGHTS, 0.75, TYPE, "Change layout:weight");
+ pointBottom(decorator, DrawingStyle.RESIZE_WEIGHTS, 0.75, TYPE, "Change layout:weight");
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/RelativeLayoutResizeOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/RelativeLayoutResizeOperation.java
index 714c38bfc15..0aeede0214c 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/RelativeLayoutResizeOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/RelativeLayoutResizeOperation.java
@@ -16,21 +16,21 @@
package com.intellij.android.designer.designSurface.layout.actions;
import com.android.SdkConstants;
+import com.intellij.android.designer.designSurface.graphics.DirectionResizePoint;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.RelativeLayoutOperation;
import com.intellij.android.designer.designSurface.layout.relative.*;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.feedbacks.RectangleFeedback;
+import com.intellij.android.designer.designSurface.graphics.RectangleFeedback;
import com.intellij.designer.designSurface.feedbacks.TextFeedback;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.JBColor;
import java.awt.*;
import java.util.ArrayList;
@@ -96,7 +96,7 @@ public class RelativeLayoutResizeOperation implements EditOperation {
myVerticalTextFeedback.setBorder(IdeBorderFactory.createEmptyBorder(0, 3, 2, 0));
layer.add(myVerticalTextFeedback);
- myBoundsFeedback = new RectangleFeedback(JBColor.BLUE, 2);
+ myBoundsFeedback = new RectangleFeedback(DrawingStyle.RESIZE_PREVIEW);
layer.add(myBoundsFeedback);
int direction = myContext.getResizeDirection();
@@ -125,7 +125,7 @@ public class RelativeLayoutResizeOperation implements EditOperation {
wrapBounds = new Rectangle(bounds.getLocation(), myWrapSize);
}
- myWrapFeedback = new RectangleFeedback(JBColor.GREEN, 1);
+ myWrapFeedback = new RectangleFeedback(DrawingStyle.RESIZE_WRAP);
myWrapFeedback.setBounds(wrapBounds);
layer.add(myWrapFeedback);
}
@@ -265,21 +265,21 @@ public class RelativeLayoutResizeOperation implements EditOperation {
//////////////////////////////////////////////////////////////////////////////////////////
public static void points(ResizeSelectionDecorator decorator) {
- decorator.addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.NORTH_WEST, TYPE,
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.NORTH_WEST, TYPE,
"Change layout:width x layout:height, top x left alignment"));
decorator
- .addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.NORTH, TYPE, "Change layout:height, top alignment"));
- decorator.addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.NORTH_EAST, TYPE,
+ .addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.NORTH, TYPE, "Change layout:height, top alignment"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.NORTH_EAST, TYPE,
"Change layout:width x layout:height, top x right alignment"));
decorator
- .addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.EAST, TYPE, "Change layout:width, right alignment"));
- decorator.addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.SOUTH_EAST, TYPE,
+ .addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.EAST, TYPE, "Change layout:width, right alignment"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.SOUTH_EAST, TYPE,
"Change layout:width x layout:height, bottom x right alignment"));
decorator.addPoint(
- new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.SOUTH, TYPE, "Change layout:height, bottom alignment"));
- decorator.addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.SOUTH_WEST, TYPE,
+ new DirectionResizePoint(DrawingStyle.SELECTION, Position.SOUTH, TYPE, "Change layout:height, bottom alignment"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.SOUTH_WEST, TYPE,
"Change layout:width x layout:height, bottom x left alignment"));
decorator
- .addPoint(new DirectionResizePoint(ResizeOperation.blue, Color.black, Position.WEST, TYPE, "Change layout:width, left alignment"));
+ .addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.WEST, TYPE, "Change layout:width, left alignment"));
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/ResizeOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/ResizeOperation.java
index b3a580ce268..c240833567c 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/ResizeOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/ResizeOperation.java
@@ -17,21 +17,21 @@ package com.intellij.android.designer.designSurface.layout.actions;
import com.android.SdkConstants;
import com.intellij.android.designer.AndroidDesignerUtils;
+import com.intellij.android.designer.designSurface.graphics.DirectionResizePoint;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.propertyTable.renderers.ResourceRenderer;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
import com.intellij.designer.designSurface.feedbacks.LineMarginBorder;
-import com.intellij.designer.designSurface.feedbacks.RectangleFeedback;
+import com.intellij.android.designer.designSurface.graphics.RectangleFeedback;
import com.intellij.designer.designSurface.feedbacks.TextFeedback;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Pair;
-import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ArrayUtil;
@@ -44,7 +44,6 @@ import java.util.List;
public class ResizeOperation implements EditOperation {
public static final String TYPE = "resize_children";
- public final static Color blue = new JBColor(new Color(0, 50, 255), new Color(92, 132, 255));
private static final int SNAP_DELTA = 4;
private final OperationContext myContext;
@@ -163,10 +162,10 @@ public class ResizeOperation implements EditOperation {
fillBounds = new Rectangle(bounds.getLocation(), myFillSize);
}
- myWrapFeedback = new RectangleFeedback(Color.green, 1);
+ myWrapFeedback = new RectangleFeedback(DrawingStyle.RESIZE_WRAP);
myWrapFeedback.setBounds(wrapBounds);
- myFillFeedback = new RectangleFeedback(Color.green, 1);
+ myFillFeedback = new RectangleFeedback(DrawingStyle.GUIDELINE);
myFillFeedback.setBounds(fillBounds);
}
@@ -178,7 +177,7 @@ public class ResizeOperation implements EditOperation {
if (myFeedback == null) {
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
- myFeedback = new RectangleFeedback(Color.blue, 2);
+ myFeedback = new RectangleFeedback(DrawingStyle.RESIZE_PREVIEW);
layer.add(myFeedback);
myTextFeedback = new TextFeedback();
@@ -338,14 +337,14 @@ public class ResizeOperation implements EditOperation {
public static void points(ResizeSelectionDecorator decorator) {
width(decorator);
height(decorator);
- decorator.addPoint(new DirectionResizePoint(blue, Color.black, Position.SOUTH_EAST, TYPE, "Change layout:width x layout:height"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.SOUTH_EAST, TYPE, "Change layout:width x layout:height"));
}
public static void width(ResizeSelectionDecorator decorator) {
- decorator.addPoint(new DirectionResizePoint(blue, Color.black, Position.EAST, TYPE, "Change layout:width"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.EAST, TYPE, "Change layout:width"));
}
public static void height(ResizeSelectionDecorator decorator) {
- decorator.addPoint(new DirectionResizePoint(blue, Color.black, Position.SOUTH, TYPE, "Change layout:height"));
+ decorator.addPoint(new DirectionResizePoint(DrawingStyle.SELECTION, Position.SOUTH, TYPE, "Change layout:height"));
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/TableLayoutSpanOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/TableLayoutSpanOperation.java
index 5d3097cb526..bbdb56e687b 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/TableLayoutSpanOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/actions/TableLayoutSpanOperation.java
@@ -81,16 +81,12 @@ public class TableLayoutSpanOperation extends LayoutSpanOperation {
//////////////////////////////////////////////////////////////////////////////////////////
public static void points(GridSelectionDecorator decorator) {
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.WEST,
+ decorator.addPoint(new SpanPoint(Position.WEST,
TYPE,
"Change layout:column x layout:span",
decorator)); // left
- decorator.addPoint(new SpanPoint(COLOR,
- Color.black,
- Position.EAST,
+ decorator.addPoint(new SpanPoint(Position.EAST,
TYPE,
"Change layout:span",
decorator)); // right
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowBaseOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowBaseOperation.java
index a351c047173..dda907073df 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowBaseOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowBaseOperation.java
@@ -16,6 +16,9 @@
package com.intellij.android.designer.designSurface.layout.flow;
import com.intellij.android.designer.designSurface.AbstractEditOperation;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
+import com.intellij.android.designer.designSurface.graphics.LineInsertFeedback;
+import com.intellij.android.designer.designSurface.graphics.RectangleFeedback;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
@@ -61,6 +64,18 @@ public class FlowBaseOperation extends com.intellij.designer.designSurface.FlowB
}
@Override
+ protected void createInsertFeedback() {
+ myInsertFeedback = new LineInsertFeedback(DrawingStyle.DROP_ZONE_ACTIVE, !myHorizontal);
+ myInsertFeedback.size(myBounds.width, myBounds.height);
+ }
+
+ @Override
+ protected void createFirstInsertFeedback() {
+ myFirstInsertFeedback = new RectangleFeedback(DrawingStyle.DROP_ZONE_ACTIVE);
+ myFirstInsertFeedback.setBounds(myBounds);
+ }
+
+ @Override
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
AbstractEditOperation.execute(myContext, (RadViewComponent)myContainer, myComponents, (RadViewComponent)insertBefore);
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowStaticDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowStaticDecorator.java
index a9e74c8a979..8460d65473e 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowStaticDecorator.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/flow/FlowStaticDecorator.java
@@ -15,7 +15,8 @@
*/
package com.intellij.android.designer.designSurface.layout.flow;
-import com.intellij.android.designer.designSurface.layout.BorderStaticDecorator;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.designSurface.DecorationLayer;
import com.intellij.designer.designSurface.StaticDecorator;
@@ -27,8 +28,6 @@ import java.awt.*;
* @author Alexander Lobas
*/
public abstract class FlowStaticDecorator extends StaticDecorator {
- public static final BasicStroke STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[]{3, 1}, 0);
-
public FlowStaticDecorator(RadComponent component) {
super(component);
}
@@ -37,11 +36,9 @@ public abstract class FlowStaticDecorator extends StaticDecorator {
protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
Rectangle bounds = component.getBounds(layer);
- g.setColor(BorderStaticDecorator.COLOR);
+ DesignerGraphics.useStroke(DrawingStyle.GRID, g);
g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
- g.setStroke(STROKE);
-
if (isHorizontal()) {
for (RadComponent child : component.getChildren()) {
Rectangle childBounds = child.getBounds(layer);
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridDecorator.java
index 2da4c372384..902b05213c4 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridDecorator.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridDecorator.java
@@ -15,8 +15,8 @@
*/
package com.intellij.android.designer.designSurface.layout.grid;
-import com.intellij.android.designer.designSurface.layout.BorderStaticDecorator;
-import com.intellij.android.designer.designSurface.layout.flow.FlowStaticDecorator;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.grid.GridInfo;
import com.intellij.android.designer.model.grid.IGridProvider;
import com.intellij.designer.designSurface.DecorationLayer;
@@ -25,6 +25,8 @@ import com.intellij.designer.model.RadComponent;
import java.awt.*;
+import static com.intellij.android.designer.designSurface.graphics.DrawingStyle.SHOW_STATIC_GRID;
+
/**
* @author Alexander Lobas
*/
@@ -35,25 +37,22 @@ public class GridDecorator extends StaticDecorator {
@Override
protected void paint(DecorationLayer layer, Graphics2D g, RadComponent component) {
- Stroke stroke = g.getStroke();
- g.setColor(BorderStaticDecorator.COLOR);
- g.setStroke(FlowStaticDecorator.STROKE);
+ //noinspection ConstantConditions
+ if (SHOW_STATIC_GRID) {
+ DesignerGraphics.useStroke(DrawingStyle.GRID, g);
- Rectangle bounds = component.getBounds(layer);
- GridInfo gridInfo = ((IGridProvider)component).getGridInfo();
- Dimension gridSize = gridInfo.getSize(layer);
+ Rectangle bounds = component.getBounds(layer);
+ GridInfo gridInfo = ((IGridProvider)component).getGridInfo();
+ Dimension gridSize = gridInfo.getSize(layer);
- for (int column = 0; column < gridInfo.vLines.length; column++) {
- int x = gridInfo.getCellPosition(layer, 0, column).x;
- g.drawLine(bounds.x + x, bounds.y, bounds.x + x, bounds.y + gridSize.height);
- }
- for (int row = 0; row < gridInfo.hLines.length; row++) {
- int y = gridInfo.getCellPosition(layer, row, 0).y;
- g.drawLine(bounds.x, bounds.y + y, bounds.x + gridSize.width, bounds.y + y);
+ for (int column = 0; column < gridInfo.vLines.length; column++) {
+ int x = gridInfo.getCellPosition(layer, 0, column).x;
+ g.drawLine(bounds.x + x, bounds.y, bounds.x + x, bounds.y + gridSize.height);
+ }
+ for (int row = 0; row < gridInfo.hLines.length; row++) {
+ int y = gridInfo.getCellPosition(layer, row, 0).y;
+ g.drawLine(bounds.x, bounds.y + y, bounds.x + gridSize.width, bounds.y + y);
+ }
}
-
- g.setStroke(stroke);
- g.drawRect(bounds.x, bounds.y, gridSize.width, gridSize.height);
- g.drawRect(bounds.x + 1, bounds.y + 1, gridSize.width - 2, gridSize.height - 2);
}
} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridOperation.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridOperation.java
index 63e458906c4..586d3e03c0d 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridOperation.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridOperation.java
@@ -16,19 +16,18 @@
package com.intellij.android.designer.designSurface.layout.grid;
import com.intellij.android.designer.designSurface.AbstractEditOperation;
-import com.intellij.android.designer.designSurface.layout.BorderStaticDecorator;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
+import com.intellij.android.designer.designSurface.graphics.InsertFeedback;
import com.intellij.android.designer.model.grid.GridInfo;
import com.intellij.android.designer.model.grid.GridInsertType;
import com.intellij.android.designer.model.grid.IGridProvider;
import com.intellij.designer.designSurface.EditableArea;
import com.intellij.designer.designSurface.FeedbackLayer;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.feedbacks.AlphaFeedback;
-import com.intellij.designer.designSurface.feedbacks.InsertFeedback;
import com.intellij.designer.designSurface.feedbacks.TextFeedback;
import com.intellij.designer.model.RadComponent;
import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.JBColor;
import javax.swing.*;
import java.awt.*;
@@ -58,7 +57,7 @@ public abstract class GridOperation extends AbstractEditOperation {
if (myFeedback == null) {
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
- myInsertFeedback = new InsertFeedback(JBColor.GREEN);
+ myInsertFeedback = new InsertFeedback(DrawingStyle.DROP_ZONE_ACTIVE);
layer.add(myInsertFeedback);
myBounds = myContainer.getBounds(layer);
@@ -414,7 +413,8 @@ public abstract class GridOperation extends AbstractEditOperation {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
- g.setColor(BorderStaticDecorator.COLOR);
+
+ DesignerGraphics.useStroke(DrawingStyle.DROP_ZONE, g);
GridInfo gridInfo = getGridInfo();
Dimension size = gridInfo.getSize(this);
@@ -429,15 +429,17 @@ public abstract class GridOperation extends AbstractEditOperation {
}
g.drawRect(0, 0, size.width - 1, size.height - 1);
g.drawRect(1, 1, size.width - 3, size.height - 3);
+ DesignerGraphics.drawRect(DrawingStyle.DROP_RECIPIENT, g, 0, 0, size.width, size.height);
if (myInsertType == GridInsertType.in_cell) {
Rectangle cellRect = getInsertRect(myExist);
if (myExist) {
- AlphaFeedback.fillRect2(g, cellRect.x, cellRect.y, cellRect.width, cellRect.height, Color.pink);
+ DesignerGraphics.drawFilledRect(DrawingStyle.INVALID, g, cellRect.x, cellRect.y, cellRect.width + 1, cellRect.height + 1);
}
else {
- AlphaFeedback.fillRect1(g, cellRect.x, cellRect.y, cellRect.width, cellRect.height, Color.green);
+ DesignerGraphics.drawFilledRect(DrawingStyle.DROP_ZONE_ACTIVE, g, cellRect.x, cellRect.y, cellRect.width + 1,
+ cellRect.height + 1);
}
}
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridSelectionDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridSelectionDecorator.java
index 80aba9ff143..8f827d0ab88 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridSelectionDecorator.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/grid/GridSelectionDecorator.java
@@ -1,8 +1,9 @@
package com.intellij.android.designer.designSurface.layout.grid;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.grid.GridInfo;
import com.intellij.designer.designSurface.DecorationLayer;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import java.awt.*;
@@ -11,8 +12,8 @@ import java.awt.*;
* @author Alexander Lobas
*/
public abstract class GridSelectionDecorator extends ResizeSelectionDecorator {
- public GridSelectionDecorator(Color color, int lineWidth) {
- super(color, lineWidth);
+ public GridSelectionDecorator(DrawingStyle style) {
+ super(style);
}
@Override
@@ -46,4 +47,4 @@ public abstract class GridSelectionDecorator extends ResizeSelectionDecorator {
return bounds;
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/RelativeDecorator.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/RelativeDecorator.java
index 02b3de0766c..f84f181afbd 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/RelativeDecorator.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/RelativeDecorator.java
@@ -15,12 +15,13 @@
*/
package com.intellij.android.designer.designSurface.layout.relative;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.model.layout.relative.RelativeInfo;
import com.intellij.designer.designSurface.DecorationLayer;
import com.intellij.designer.designSurface.StaticDecorator;
import com.intellij.designer.model.RadComponent;
-import com.intellij.ui.JBColor;
import java.awt.*;
import java.util.List;
@@ -46,9 +47,7 @@ public class RelativeDecorator extends StaticDecorator {
return;
}
- Stroke stroke = g.getStroke();
- g.setStroke(SnapPointFeedbackHost.STROKE);
- g.setColor(SnapPointFeedbackHost.COLOR);
+ DesignerGraphics.useStroke(DrawingStyle.GUIDELINE_DASHED_STROKE, g);
Rectangle bounds = container.getBounds(layer);
Map<RadComponent, RelativeInfo> relativeInfos = container.getClientProperty(RelativeInfo.KEY);
@@ -62,8 +61,7 @@ public class RelativeDecorator extends StaticDecorator {
}
}
- g.setStroke(stroke);
- g.setColor(JBColor.ORANGE);
+ DesignerGraphics.useStroke(DrawingStyle.GUIDELINE, g);
for (RadComponent component : selection) {
RelativeInfo info = relativeInfos.get(component);
@@ -122,19 +120,19 @@ public class RelativeDecorator extends StaticDecorator {
if (info.parentTop && margins.y > 0) {
int x = componentBounds.x + componentBounds.width / 2;
- SnapPointFeedbackHost.paintArrowVertical(g, x, containerBounds.y, x, componentBounds.y);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, x, componentBounds.y, x, containerBounds.y);
}
if (info.parentBottom && margins.height > 0) {
int x = componentBounds.x + componentBounds.width / 2;
- SnapPointFeedbackHost.paintArrowVertical(g, x, componentBounds.y + componentBounds.height, x, containerBounds.y);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, x, containerBounds.y, x, componentBounds.y + componentBounds.height);
}
if (info.parentLeft && margins.x > 0) {
int y = componentBounds.y + componentBounds.height / 2;
- SnapPointFeedbackHost.paintArrowHorizontal(g, containerBounds.x, y, componentBounds.x, y);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, componentBounds.x, y, containerBounds.x, y);
}
if (info.parentRight && margins.width > 0) {
int y = componentBounds.y + componentBounds.height / 2;
- SnapPointFeedbackHost.paintArrowHorizontal(g, componentBounds.x + componentBounds.width, y, containerBounds.x, y);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, containerBounds.x, y, componentBounds.x + componentBounds.width, y);
}
}
diff --git a/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/SnapPointFeedbackHost.java b/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/SnapPointFeedbackHost.java
index fdce2e7040b..dd9e8c5665e 100644
--- a/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/SnapPointFeedbackHost.java
+++ b/android-designer/src/com/intellij/android/designer/designSurface/layout/relative/SnapPointFeedbackHost.java
@@ -15,6 +15,8 @@
*/
package com.intellij.android.designer.designSurface.layout.relative;
+import com.intellij.android.designer.designSurface.graphics.DesignerGraphics;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.ui.SimpleTextAttributes;
import javax.swing.*;
@@ -26,12 +28,10 @@ import java.util.List;
* @author Alexander Lobas
*/
public class SnapPointFeedbackHost extends JComponent {
- public static final BasicStroke STROKE = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[]{3, 1}, 0);
- public static final Color COLOR = new Color(60, 139, 186);
public static final int EXPAND_SIZE = 10;
public static final String KEY = "SnapPointFeedbackHost";
- public static SimpleTextAttributes SNAP_ATTRIBUTES = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, COLOR);
+ public static SimpleTextAttributes SNAP_ATTRIBUTES = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, new Color(60, 139, 186));
private final List<Rectangle> myLines = new ArrayList<Rectangle>();
private final List<Rectangle> myArrows = new ArrayList<Rectangle>();
@@ -65,11 +65,8 @@ public class SnapPointFeedbackHost extends JComponent {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
- Graphics2D g2d = (Graphics2D)g;
- Stroke stroke = g2d.getStroke();
- g.setColor(COLOR);
- g2d.setStroke(STROKE);
+ DesignerGraphics.useStroke(DrawingStyle.GUIDELINE_DASHED_STROKE, g);
Rectangle bounds = getBounds();
@@ -85,35 +82,16 @@ public class SnapPointFeedbackHost extends JComponent {
}
}
- g.setColor(Color.orange);
- g2d.setStroke(stroke);
-
for (Rectangle line : myArrows) {
int x = line.x - bounds.x;
int y = line.y - bounds.y;
if (line.width == -1) {
- paintArrowVertical(g, x, y, x, y + line.height);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, x, y + line.height, x, y);
}
else {
- paintArrowHorizontal(g, x, y, x + line.width, y);
+ DesignerGraphics.drawArrow(DrawingStyle.GUIDELINE, g, x + line.width, y, x, y);
}
}
}
-
- public static void paintArrowHorizontal(Graphics g, int x1, int y1, int x2, int y2) {
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 + 5, y1 - 5, x1, y1);
- g.drawLine(x1 + 5, y1 + 5, x1, y1);
- g.drawLine(x2 - 5, y2 - 5, x2, y2);
- g.drawLine(x2 - 5, y2 + 5, x2, y2);
- }
-
- public static void paintArrowVertical(Graphics g, int x1, int y1, int x2, int y2) {
- g.drawLine(x1, y1, x2, y2);
- g.drawLine(x1 - 5, y1 + 5, x1, y1);
- g.drawLine(x1 + 5, y1 + 5, x1, y1);
- g.drawLine(x2 - 5, y2 - 5, x2, y2);
- g.drawLine(x2 + 5, y2 - 5, x2, y2);
- }
} \ No newline at end of file
diff --git a/android-designer/src/com/intellij/android/designer/model/ModelParser.java b/android-designer/src/com/intellij/android/designer/model/ModelParser.java
index 4402d967c30..e8936640bbb 100644
--- a/android-designer/src/com/intellij/android/designer/model/ModelParser.java
+++ b/android-designer/src/com/intellij/android/designer/model/ModelParser.java
@@ -58,6 +58,7 @@ public class ModelParser extends XmlRecursiveElementVisitor {
public static final String FOLDER_CONFIG_KEY = "FOLDER_CONFIG";
private static final int EMPTY_COMPONENT_SIZE = 5;
+ private static final int VISUAL_EMPTY_COMPONENT_SIZE = 14;
private final IdManager myIdManager = new IdManager();
@@ -435,10 +436,10 @@ public class ModelParser extends XmlRecursiveElementVisitor {
int height = view.getBottom() - view.getTop();
if (width < EMPTY_COMPONENT_SIZE && height < EMPTY_COMPONENT_SIZE) {
- nativeComponent.addEmptyRegion(left, top, EMPTY_COMPONENT_SIZE, EMPTY_COMPONENT_SIZE);
+ nativeComponent.addEmptyRegion(left, top, VISUAL_EMPTY_COMPONENT_SIZE, VISUAL_EMPTY_COMPONENT_SIZE);
}
- component.setBounds(left, top, Math.max(width, EMPTY_COMPONENT_SIZE), Math.max(height, EMPTY_COMPONENT_SIZE));
+ component.setBounds(left, top, Math.max(width, VISUAL_EMPTY_COMPONENT_SIZE), Math.max(height, VISUAL_EMPTY_COMPONENT_SIZE));
updateChildren(component, view.getChildren(), nativeComponent, left, top);
}
diff --git a/android-designer/src/com/intellij/android/designer/model/RadViewLayout.java b/android-designer/src/com/intellij/android/designer/model/RadViewLayout.java
index 336ef0289b5..838f14d73ec 100644
--- a/android-designer/src/com/intellij/android/designer/model/RadViewLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/RadViewLayout.java
@@ -15,13 +15,14 @@
*/
package com.intellij.android.designer.model;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.DesignerEditorPanel;
-import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.NonResizeSelectionDecorator;
+import com.intellij.designer.designSurface.EmptyComponentDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.model.RadLayout;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.ui.JBColor;
import javax.swing.*;
import java.util.List;
@@ -31,10 +32,13 @@ import java.util.List;
*/
public class RadViewLayout extends RadLayout {
public static final RadLayout INSTANCE = new RadViewLayout();
- public static final ComponentDecorator NON_RESIZE_DECORATOR = new NonResizeSelectionDecorator(JBColor.RED, 1);
+ public static final ComponentDecorator NON_RESIZE_DECORATOR = new NonResizeSelectionDecorator(DrawingStyle.SELECTION);
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
+ if (component.isBackground()) {
+ return EmptyComponentDecorator.INSTANCE;
+ }
return NON_RESIZE_DECORATOR;
}
@@ -46,4 +50,4 @@ public class RadViewLayout extends RadLayout {
public void wrapIn(RadViewComponent newParent, List<RadViewComponent> components) throws Exception {
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/RadViewLayoutWithData.java b/android-designer/src/com/intellij/android/designer/model/RadViewLayoutWithData.java
index 9fe7bde7bd4..35876e9ac0f 100644
--- a/android-designer/src/com/intellij/android/designer/model/RadViewLayoutWithData.java
+++ b/android-designer/src/com/intellij/android/designer/model/RadViewLayoutWithData.java
@@ -15,6 +15,7 @@
*/
package com.intellij.android.designer.model;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.BorderStaticDecorator;
import com.intellij.designer.designSurface.StaticDecorator;
import com.intellij.designer.model.RadComponent;
@@ -22,6 +23,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
+import static com.intellij.android.designer.designSurface.graphics.DrawingStyle.*;
+
/**
* @author Alexander Lobas
*/
@@ -39,6 +42,10 @@ public abstract class RadViewLayoutWithData extends RadViewLayout {
}
public void addStaticDecorators(List<StaticDecorator> decorators, List<RadComponent> selection) {
+ //noinspection ConstantConditions
+ if (!SHOW_STATIC_BORDERS) {
+ return;
+ }
if (!selection.contains(myContainer) && myContainer.getParent() != myContainer.getRoot()) {
decorators.add(getBorderDecorator());
}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/RadAbsoluteLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/RadAbsoluteLayout.java
index 5f7f5b267f4..3d2e5b9810f 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/RadAbsoluteLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/RadAbsoluteLayout.java
@@ -16,6 +16,7 @@
package com.intellij.android.designer.model.layout;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.AbsoluteLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
import com.intellij.android.designer.model.RadViewLayoutWithData;
@@ -23,9 +24,8 @@ import com.intellij.designer.componentTree.TreeEditOperation;
import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -64,9 +64,9 @@ public class RadAbsoluteLayout extends RadViewLayoutWithData {
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new ResizeSelectionDecorator(JBColor.RED, 1);
+ mySelectionDecorator = new ResizeSelectionDecorator(DrawingStyle.SELECTION);
ResizeOperation.points(mySelectionDecorator);
}
return mySelectionDecorator;
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/RadFrameLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/RadFrameLayout.java
index b6c4d174a72..3b168a5cc18 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/RadFrameLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/RadFrameLayout.java
@@ -17,6 +17,8 @@ package com.intellij.android.designer.model.layout;
import com.android.SdkConstants;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DirectionResizePoint;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.FrameLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.LayoutMarginOperation;
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
@@ -28,15 +30,13 @@ import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.DesignerEditorPanel;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.OperationContext;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
import com.intellij.designer.designSurface.selection.ResizePoint;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.util.Pair;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -80,7 +80,7 @@ public class RadFrameLayout extends RadViewLayoutWithData {
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new ResizeSelectionDecorator(JBColor.RED, 1) {
+ mySelectionDecorator = new ResizeSelectionDecorator(DrawingStyle.SELECTION) {
@Override
protected boolean visible(RadComponent component, ResizePoint point) {
if (point.getType() == LayoutMarginOperation.TYPE) {
@@ -189,4 +189,4 @@ public class RadFrameLayout extends RadViewLayoutWithData {
actionGroup.add(action);
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/RadLinearLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/RadLinearLayout.java
index 9ffd87ffa0b..7b3cdace4b3 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/RadLinearLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/RadLinearLayout.java
@@ -17,6 +17,8 @@ package com.intellij.android.designer.model.layout;
import com.android.SdkConstants;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DirectionResizePoint;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.LinearLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.LayoutMarginOperation;
import com.intellij.android.designer.designSurface.layout.actions.LayoutWeightOperation;
@@ -29,16 +31,14 @@ import com.intellij.android.designer.model.layout.actions.AbstractGravityAction;
import com.intellij.android.designer.model.layout.actions.OrientationAction;
import com.intellij.designer.componentTree.TreeEditOperation;
import com.intellij.designer.designSurface.*;
-import com.intellij.designer.designSurface.selection.DirectionResizePoint;
import com.intellij.designer.designSurface.selection.ResizePoint;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.utils.Position;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Pair;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -47,10 +47,13 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import static com.intellij.android.designer.designSurface.graphics.DrawingStyle.SHOW_STATIC_GRID;
+
/**
* @author Alexander Lobas
*/
public class RadLinearLayout extends RadViewLayoutWithData implements ILayoutDecorator {
+
private static final String[] LAYOUT_PARAMS = {"LinearLayout_Layout", "ViewGroup_MarginLayout"};
private ResizeSelectionDecorator mySelectionDecorator;
@@ -103,6 +106,11 @@ public class RadLinearLayout extends RadViewLayoutWithData implements ILayoutDec
@Override
public void addStaticDecorators(List<StaticDecorator> decorators, List<RadComponent> selection) {
+ //noinspection ConstantConditions
+ if (!SHOW_STATIC_GRID) {
+ return;
+ }
+
if (selection.contains(myContainer)) {
if (!(myContainer.getParent().getLayout() instanceof ILayoutDecorator)) {
decorators.add(getLineDecorator());
@@ -124,7 +132,7 @@ public class RadLinearLayout extends RadViewLayoutWithData implements ILayoutDec
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new ResizeSelectionDecorator(JBColor.RED, 1) {
+ mySelectionDecorator = new ResizeSelectionDecorator(DrawingStyle.SELECTION) {
@Override
protected boolean visible(RadComponent component, ResizePoint point) {
if (point.getType() == LayoutMarginOperation.TYPE) {
@@ -352,4 +360,4 @@ public class RadLinearLayout extends RadViewLayoutWithData implements ILayoutDec
});
}
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/grid/RadGridLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/grid/RadGridLayout.java
index f34fd7de8b1..3952f1f66dd 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/grid/RadGridLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/grid/RadGridLayout.java
@@ -16,6 +16,7 @@
package com.intellij.android.designer.model.layout.grid;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.GridLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.GridLayoutSpanOperation;
import com.intellij.android.designer.designSurface.layout.actions.LayoutSpanOperation;
@@ -34,7 +35,6 @@ import com.intellij.designer.designSurface.*;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.model.RadLayout;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -107,7 +107,7 @@ public class RadGridLayout extends RadViewLayoutWithData implements ILayoutDecor
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new GridSelectionDecorator(JBColor.RED, 1) {
+ mySelectionDecorator = new GridSelectionDecorator(DrawingStyle.SELECTION) {
@Override
public Rectangle getCellBounds(Component layer, RadComponent component) {
try {
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/relative/RadRelativeLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/relative/RadRelativeLayout.java
index 9ed7cb488a6..c02b46143df 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/relative/RadRelativeLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/relative/RadRelativeLayout.java
@@ -16,6 +16,7 @@
package com.intellij.android.designer.model.layout.relative;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.RelativeLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.RelativeLayoutResizeOperation;
import com.intellij.android.designer.designSurface.layout.relative.RelativeDecorator;
@@ -28,12 +29,11 @@ import com.intellij.android.designer.propertyTable.JavadocParser;
import com.intellij.android.designer.propertyTable.RelativeIdAttributeProperty;
import com.intellij.designer.componentTree.TreeEditOperation;
import com.intellij.designer.designSurface.*;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.Property;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.propertyTable.PropertyTable;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -135,7 +135,7 @@ public class RadRelativeLayout extends RadViewLayoutWithData implements ILayoutD
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new ResizeSelectionDecorator(JBColor.RED, 1);
+ mySelectionDecorator = new ResizeSelectionDecorator(DrawingStyle.SELECTION);
RelativeLayoutResizeOperation.points(mySelectionDecorator);
}
return mySelectionDecorator;
@@ -180,4 +180,4 @@ public class RadRelativeLayout extends RadViewLayoutWithData implements ILayoutD
actionGroup.add(new AllGravityAction(designer, Arrays.asList(myContainer)));
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableLayout.java
index 2cf2c80899d..bdc1c496954 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableLayout.java
@@ -16,6 +16,7 @@
package com.intellij.android.designer.model.layout.table;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.TableLayoutOperation;
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
import com.intellij.android.designer.designSurface.layout.caption.TableHorizontalCaptionOperation;
@@ -27,10 +28,9 @@ import com.intellij.android.designer.model.RadViewLayoutWithData;
import com.intellij.android.designer.model.grid.GridInfo;
import com.intellij.designer.componentTree.TreeEditOperation;
import com.intellij.designer.designSurface.*;
-import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
+import com.intellij.android.designer.designSurface.graphics.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.model.RadLayout;
-import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -101,7 +101,7 @@ public class RadTableLayout extends RadViewLayoutWithData implements ILayoutDeco
}
if (mySelectionDecorator == null) {
- mySelectionDecorator = new ResizeSelectionDecorator(JBColor.RED, 1);
+ mySelectionDecorator = new ResizeSelectionDecorator(DrawingStyle.SELECTION);
ResizeOperation.height(mySelectionDecorator);
}
return mySelectionDecorator;
@@ -200,4 +200,4 @@ public class RadTableLayout extends RadViewLayoutWithData implements ILayoutDeco
}
return myCaptionRowLayout;
}
-} \ No newline at end of file
+}
diff --git a/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableRowLayout.java b/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableRowLayout.java
index e3581ac861d..73ddf40ba0d 100644
--- a/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableRowLayout.java
+++ b/android-designer/src/com/intellij/android/designer/model/layout/table/RadTableRowLayout.java
@@ -15,6 +15,7 @@
*/
package com.intellij.android.designer.model.layout.table;
+import com.intellij.android.designer.designSurface.graphics.DrawingStyle;
import com.intellij.android.designer.designSurface.layout.actions.LayoutSpanOperation;
import com.intellij.android.designer.designSurface.layout.actions.TableLayoutSpanOperation;
import com.intellij.android.designer.designSurface.layout.grid.GridSelectionDecorator;
@@ -24,7 +25,6 @@ import com.intellij.android.designer.model.layout.actions.AllGravityAction;
import com.intellij.designer.designSurface.*;
import com.intellij.designer.model.RadComponent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.ui.JBColor;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -81,7 +81,7 @@ public class RadTableRowLayout extends RadLinearLayout {
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (isTableParent()) {
if (mySelectionDecorator == null) {
- mySelectionDecorator = new GridSelectionDecorator(JBColor.RED, 1) {
+ mySelectionDecorator = new GridSelectionDecorator(DrawingStyle.SELECTION) {
@Override
public Rectangle getCellBounds(Component layer, RadComponent component) {
try {