Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2014-05-12 14:43:48 +0000
committerTom Schindl2014-05-12 14:43:48 +0000
commitac779f17c6a67937c6c6ff85685b7b9cf33a2007 (patch)
treeee2e116e71a182eb99910c0fc0046db3de486936
parentc8db0af50e0753b81a2d08a4f982615ba026194a (diff)
downloadorg.eclipse.efxclipse-ac779f17c6a67937c6c6ff85685b7b9cf33a2007.tar.gz
org.eclipse.efxclipse-ac779f17c6a67937c6c6ff85685b7b9cf33a2007.tar.xz
org.eclipse.efxclipse-ac779f17c6a67937c6c6ff85685b7b9cf33a2007.zip
Bug 434228 - [e4] Add support for DnD of Parts
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java179
1 files changed, 123 insertions, 56 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
index 5b084e66f..972077a37 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
@@ -10,10 +10,22 @@
*******************************************************************************/
package org.eclipse.fx.ui.controls.markers;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import com.sun.javafx.css.converters.PaintConverter;
+
+import javafx.beans.property.ObjectProperty;
+import javafx.css.CssMetaData;
+import javafx.css.Styleable;
+import javafx.css.StyleableObjectProperty;
+import javafx.css.StyleableProperty;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.scene.Group;
import javafx.scene.paint.Color;
+import javafx.scene.paint.Paint;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeType;
@@ -21,77 +33,132 @@ public class TabOutlineMarker extends Group {
private Bounds containerBounds;
private Bounds referenceBounds;
private boolean before;
-
+
public TabOutlineMarker(Bounds containerBounds, Bounds referenceBounds, boolean before) {
updateBounds(containerBounds, referenceBounds, before);
}
-
+
public void updateBounds(Bounds containerBounds, Bounds referenceBounds, boolean before) {
- if( containerBounds.equals(this.containerBounds) && referenceBounds.equals(this.referenceBounds) && before == this.before ) {
+ if (containerBounds.equals(this.containerBounds) && referenceBounds.equals(this.referenceBounds) && before == this.before) {
return;
}
-
+
this.containerBounds = containerBounds;
this.referenceBounds = referenceBounds;
this.before = before;
-
+
Polyline pl = new Polyline();
-
- if( before ) {
- referenceBounds = new BoundingBox(Math.max(0,referenceBounds.getMinX()-referenceBounds.getWidth()/2), referenceBounds.getMinY(),referenceBounds.getWidth(), referenceBounds.getHeight());
+
+ if (before) {
+ referenceBounds = new BoundingBox(Math.max(0, referenceBounds.getMinX() - referenceBounds.getWidth() / 2), referenceBounds.getMinY(), referenceBounds.getWidth(), referenceBounds.getHeight());
} else {
- referenceBounds = new BoundingBox(Math.max(0,referenceBounds.getMaxX()-referenceBounds.getWidth()/2), referenceBounds.getMinY(),referenceBounds.getWidth(), referenceBounds.getHeight());
+ referenceBounds = new BoundingBox(Math.max(0, referenceBounds.getMaxX() - referenceBounds.getWidth() / 2), referenceBounds.getMinY(), referenceBounds.getWidth(), referenceBounds.getHeight());
}
-
+
pl.getPoints().addAll(
- // -----------------
- // top
- // -----------------
- // start
- 0.0,
- referenceBounds.getMaxY(),
-
- // tab start
- referenceBounds.getMinX(),
- referenceBounds.getMaxY(),
-
-// // tab start top
- referenceBounds.getMinX(),
- referenceBounds.getMinY(),
-
- // tab end right
- referenceBounds.getMaxX(),
- referenceBounds.getMinY(),
-
- // tab end bottom
- referenceBounds.getMaxX(),
- referenceBounds.getMaxY(),
-
- // end
- containerBounds.getMaxX(),
- referenceBounds.getMaxY(),
-
- // -----------------
- // right
- // -----------------
- containerBounds.getMaxX(),
- containerBounds.getMaxY(),
-
- // -----------------
- // bottom
- // -----------------
- containerBounds.getMinX(),
- containerBounds.getMaxY(),
-
- // -----------------
- // left
- // -----------------
- containerBounds.getMinX(),
- referenceBounds.getMaxY()
- );
- pl.setStroke(Color.ORANGE);
+ // -----------------
+ // top
+ // -----------------
+ // start
+ 0.0, referenceBounds.getMaxY(),
+
+ // tab start
+ referenceBounds.getMinX(), referenceBounds.getMaxY(),
+
+ // // tab start top
+ referenceBounds.getMinX(), referenceBounds.getMinY(),
+
+ // tab end right
+ referenceBounds.getMaxX(), referenceBounds.getMinY(),
+
+ // tab end bottom
+ referenceBounds.getMaxX(), referenceBounds.getMaxY(),
+
+ // end
+ containerBounds.getMaxX(), referenceBounds.getMaxY(),
+
+ // -----------------
+ // right
+ // -----------------
+ containerBounds.getMaxX(), containerBounds.getMaxY(),
+
+ // -----------------
+ // bottom
+ // -----------------
+ containerBounds.getMinX(), containerBounds.getMaxY(),
+
+ // -----------------
+ // left
+ // -----------------
+ containerBounds.getMinX(), referenceBounds.getMaxY());
+ pl.strokeProperty().bind(fillProperty());
pl.setStrokeWidth(3);
pl.setStrokeType(StrokeType.INSIDE);
getChildren().setAll(pl);
}
+
+ private ObjectProperty<Paint> fill;
+
+ public ObjectProperty<Paint> fillProperty() {
+ if (fill == null) {
+ fill = new StyleableObjectProperty<Paint>(Color.ORANGE) {
+
+ @Override
+ public CssMetaData<? extends Styleable, Paint> getCssMetaData() {
+ return FILL;
+ }
+
+ @Override
+ public Object getBean() {
+ return TabOutlineMarker.this;
+ }
+
+ @Override
+ public String getName() {
+ return "fill";
+ }
+
+ };
+ }
+ return fill;
+ }
+
+ public void setFill(Paint fill) {
+ fillProperty().set(fill);
+ }
+
+ public Paint getFill() {
+ return fillProperty().get();
+ }
+
+ private static final CssMetaData<TabOutlineMarker, Paint> FILL = new CssMetaData<TabOutlineMarker, Paint>("-fx-fill", PaintConverter.getInstance(), Color.rgb(0, 139, 255)) {
+
+ @Override
+ public boolean isSettable(TabOutlineMarker node) {
+ return node.fill == null || !node.fill.isBound();
+ }
+
+ @Override
+ public StyleableProperty<Paint> getStyleableProperty(TabOutlineMarker node) {
+ return (StyleableProperty<Paint>) node.fillProperty();
+ }
+
+ };
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+
+ static {
+ final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(Group.getClassCssMetaData());
+ styleables.add(FILL);
+ STYLEABLES = Collections.unmodifiableList(styleables);
+ }
+
+ public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
+ return STYLEABLES;
+ }
+
+ @Override
+ public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
+ return getClassCssMetaData();
+ }
}

Back to the top