Merge pull request #1438 from gavin-ts/set-label-icon-position
use specified label/icon position
This commit is contained in:
commit
aa321c2066
16 changed files with 24374 additions and 29 deletions
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"oss.terrastruct.com/d2/d2themes/d2themescatalog"
|
"oss.terrastruct.com/d2/d2themes/d2themescatalog"
|
||||||
"oss.terrastruct.com/d2/lib/color"
|
"oss.terrastruct.com/d2/lib/color"
|
||||||
"oss.terrastruct.com/d2/lib/geo"
|
"oss.terrastruct.com/d2/lib/geo"
|
||||||
|
"oss.terrastruct.com/d2/lib/label"
|
||||||
"oss.terrastruct.com/d2/lib/shape"
|
"oss.terrastruct.com/d2/lib/shape"
|
||||||
"oss.terrastruct.com/d2/lib/textmeasure"
|
"oss.terrastruct.com/d2/lib/textmeasure"
|
||||||
)
|
)
|
||||||
|
|
@ -1382,6 +1383,18 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler
|
||||||
for _, obj := range g.Objects {
|
for _, obj := range g.Objects {
|
||||||
obj.Box = &geo.Box{}
|
obj.Box = &geo.Box{}
|
||||||
|
|
||||||
|
// user-specified label/icon positions
|
||||||
|
if obj.HasLabel() && obj.Attributes.LabelPosition != nil {
|
||||||
|
scalar := *obj.Attributes.LabelPosition
|
||||||
|
position := LabelPositionsMapping[scalar.Value]
|
||||||
|
obj.LabelPosition = go2.Pointer(string(position))
|
||||||
|
}
|
||||||
|
if obj.Icon != nil && obj.Attributes.IconPosition != nil {
|
||||||
|
scalar := *obj.Attributes.IconPosition
|
||||||
|
position := LabelPositionsMapping[scalar.Value]
|
||||||
|
obj.IconPosition = go2.Pointer(string(position))
|
||||||
|
}
|
||||||
|
|
||||||
var desiredWidth int
|
var desiredWidth int
|
||||||
var desiredHeight int
|
var desiredHeight int
|
||||||
if obj.WidthAttr != nil {
|
if obj.WidthAttr != nil {
|
||||||
|
|
@ -1735,6 +1748,37 @@ var LabelPositionsArray = []string{
|
||||||
}
|
}
|
||||||
var LabelPositions map[string]struct{}
|
var LabelPositions map[string]struct{}
|
||||||
|
|
||||||
|
// convert to label.Position
|
||||||
|
var LabelPositionsMapping = map[string]label.Position{
|
||||||
|
"top-left": label.InsideTopLeft,
|
||||||
|
"top-center": label.InsideTopCenter,
|
||||||
|
"top-right": label.InsideTopRight,
|
||||||
|
|
||||||
|
"center-left": label.InsideMiddleLeft,
|
||||||
|
"center-center": label.InsideMiddleCenter,
|
||||||
|
"center-right": label.InsideMiddleRight,
|
||||||
|
|
||||||
|
"bottom-left": label.InsideBottomLeft,
|
||||||
|
"bottom-center": label.InsideBottomCenter,
|
||||||
|
"bottom-right": label.InsideBottomRight,
|
||||||
|
|
||||||
|
"outside-top-left": label.OutsideTopLeft,
|
||||||
|
"outside-top-center": label.OutsideTopCenter,
|
||||||
|
"outside-top-right": label.OutsideTopRight,
|
||||||
|
|
||||||
|
"outside-left-top": label.OutsideLeftTop,
|
||||||
|
"outside-left-center": label.OutsideLeftMiddle,
|
||||||
|
"outside-left-bottom": label.OutsideLeftBottom,
|
||||||
|
|
||||||
|
"outside-right-top": label.OutsideRightTop,
|
||||||
|
"outside-right-center": label.OutsideRightMiddle,
|
||||||
|
"outside-right-bottom": label.OutsideRightBottom,
|
||||||
|
|
||||||
|
"outside-bottom-left": label.OutsideBottomLeft,
|
||||||
|
"outside-bottom-center": label.OutsideBottomCenter,
|
||||||
|
"outside-bottom-right": label.OutsideBottomRight,
|
||||||
|
}
|
||||||
|
|
||||||
var FillPatterns = []string{
|
var FillPatterns = []string{
|
||||||
"dots",
|
"dots",
|
||||||
"lines",
|
"lines",
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,16 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.Width = math.Ceil(dn.Width)
|
obj.Width = math.Ceil(dn.Width)
|
||||||
obj.Height = math.Ceil(dn.Height)
|
obj.Height = math.Ceil(dn.Height)
|
||||||
|
|
||||||
|
if obj.Icon != nil && obj.IconPosition == nil {
|
||||||
|
if len(obj.ChildrenArray) > 0 {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.OutsideTopLeft))
|
||||||
|
if obj.LabelPosition == nil {
|
||||||
|
obj.LabelPosition = go2.Pointer(string(label.OutsideTopRight))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
|
}
|
||||||
if obj.HasLabel() && obj.LabelPosition == nil {
|
if obj.HasLabel() && obj.LabelPosition == nil {
|
||||||
if len(obj.ChildrenArray) > 0 {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
obj.LabelPosition = go2.Pointer(string(label.OutsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.OutsideTopCenter))
|
||||||
|
|
@ -249,14 +259,6 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if obj.Icon != nil && obj.IconPosition == nil {
|
|
||||||
if len(obj.ChildrenArray) > 0 {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.OutsideTopLeft))
|
|
||||||
obj.LabelPosition = go2.Pointer(string(label.OutsideTopRight))
|
|
||||||
} else {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, edge := range g.Edges {
|
for i, edge := range g.Edges {
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,16 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.Width = math.Ceil(n.Width)
|
obj.Width = math.Ceil(n.Width)
|
||||||
obj.Height = math.Ceil(n.Height)
|
obj.Height = math.Ceil(n.Height)
|
||||||
|
|
||||||
|
if obj.Icon != nil && obj.IconPosition == nil {
|
||||||
|
if len(obj.ChildrenArray) > 0 {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideTopLeft))
|
||||||
|
if obj.LabelPosition == nil {
|
||||||
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopRight))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
|
}
|
||||||
if obj.HasLabel() && obj.LabelPosition == nil {
|
if obj.HasLabel() && obj.LabelPosition == nil {
|
||||||
if len(obj.ChildrenArray) > 0 {
|
if len(obj.ChildrenArray) > 0 {
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
|
|
@ -419,14 +429,6 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if obj.Icon != nil && obj.IconPosition == nil {
|
|
||||||
if len(obj.ChildrenArray) > 0 {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideTopLeft))
|
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopRight))
|
|
||||||
} else {
|
|
||||||
obj.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byID[obj.AbsID()] = obj
|
byID[obj.AbsID()] = obj
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -228,7 +227,7 @@ func run(t *testing.T, tc testCase) {
|
||||||
|
|
||||||
err = os.MkdirAll(dataPath, 0755)
|
err = os.MkdirAll(dataPath, 0755)
|
||||||
assert.Success(t, err)
|
assert.Success(t, err)
|
||||||
err = ioutil.WriteFile(pathGotSVG, svgBytes, 0600)
|
err = os.WriteFile(pathGotSVG, svgBytes, 0600)
|
||||||
assert.Success(t, err)
|
assert.Success(t, err)
|
||||||
|
|
||||||
// Check that it's valid SVG
|
// Check that it's valid SVG
|
||||||
|
|
@ -246,16 +245,6 @@ func run(t *testing.T, tc testCase) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getShape(t *testing.T, diagram *d2target.Diagram, id string) d2target.Shape {
|
|
||||||
for _, shape := range diagram.Shapes {
|
|
||||||
if shape.ID == id {
|
|
||||||
return shape
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.Fatalf(`Shape "%s" not found`, id)
|
|
||||||
return d2target.Shape{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func mdTestScript(md string) string {
|
func mdTestScript(md string) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
md: |md
|
md: |md
|
||||||
|
|
@ -267,7 +256,7 @@ a -> md -> b
|
||||||
|
|
||||||
func loadFromFile(t *testing.T, name string) testCase {
|
func loadFromFile(t *testing.T, name string) testCase {
|
||||||
fn := filepath.Join("testdata", "files", fmt.Sprintf("%s.d2", name))
|
fn := filepath.Join("testdata", "files", fmt.Sprintf("%s.d2", name))
|
||||||
d2Text, err := ioutil.ReadFile(fn)
|
d2Text, err := os.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to load test from file:%s. %s", name, err.Error())
|
t.Fatalf("failed to load test from file:%s. %s", name, err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2779,6 +2779,8 @@ scenarios: {
|
||||||
loadFromFile(t, "multiple_offset_left"),
|
loadFromFile(t, "multiple_offset_left"),
|
||||||
loadFromFile(t, "multiple_box_selection"),
|
loadFromFile(t, "multiple_box_selection"),
|
||||||
loadFromFile(t, "outside_bottom_labels"),
|
loadFromFile(t, "outside_bottom_labels"),
|
||||||
|
loadFromFile(t, "label_positions"),
|
||||||
|
loadFromFile(t, "icon_positions"),
|
||||||
}
|
}
|
||||||
|
|
||||||
runa(t, tcs)
|
runa(t, tcs)
|
||||||
|
|
|
||||||
158
e2etests/testdata/files/icon_positions.d2
vendored
Normal file
158
e2etests/testdata/files/icon_positions.d2
vendored
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
non container: {
|
||||||
|
Default.class: icon
|
||||||
|
|
||||||
|
OutsideTopLeft.class: [icon; OutsideTopLeft]
|
||||||
|
OutsideTopCenter.class: [icon; OutsideTopCenter]
|
||||||
|
OutsideTopRight.class: [icon; OutsideTopRight]
|
||||||
|
|
||||||
|
OutsideLeftTop.class: [icon; OutsideLeftTop]
|
||||||
|
OutsideLeftMiddle.class: [icon; OutsideLeftMiddle]
|
||||||
|
OutsideLeftBottom.class: [icon; OutsideLeftBottom]
|
||||||
|
|
||||||
|
OutsideRightTop.class: [icon; OutsideRightTop]
|
||||||
|
OutsideRightMiddle.class: [icon; OutsideRightMiddle]
|
||||||
|
OutsideRightBottom.class: [icon; OutsideRightBottom]
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: [icon; OutsideBottomLeft]
|
||||||
|
OutsideBottomCenter.class: [icon; OutsideBottomCenter]
|
||||||
|
OutsideBottomRight.class: [icon; OutsideBottomRight]
|
||||||
|
|
||||||
|
InsideTopLeft.class: [icon; InsideTopLeft]
|
||||||
|
InsideTopCenter.class: [icon; InsideTopCenter]
|
||||||
|
InsideTopRight.class: [icon; InsideTopRight]
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: [icon; InsideMiddleLeft]
|
||||||
|
InsideMiddleCenter.class: [icon; InsideMiddleCenter]
|
||||||
|
InsideMiddleRight.class: [icon; InsideMiddleRight]
|
||||||
|
|
||||||
|
InsideBottomLeft.class: [icon; InsideBottomLeft]
|
||||||
|
InsideBottomCenter.class: [icon; InsideBottomCenter]
|
||||||
|
InsideBottomRight.class: [icon; InsideBottomRight]
|
||||||
|
}
|
||||||
|
|
||||||
|
container: {
|
||||||
|
Default.Default.class: icon
|
||||||
|
|
||||||
|
OutsideTopLeft.class: [icon; OutsideTopLeft]
|
||||||
|
OutsideTopCenter.class: [icon; OutsideTopCenter]
|
||||||
|
OutsideTopRight.class: [icon; OutsideTopRight]
|
||||||
|
|
||||||
|
OutsideLeftTop.class: [icon; OutsideLeftTop]
|
||||||
|
OutsideLeftMiddle.class: [icon; OutsideLeftMiddle]
|
||||||
|
OutsideLeftBottom.class: [icon; OutsideLeftBottom]
|
||||||
|
|
||||||
|
OutsideRightTop.class: [icon; OutsideRightTop]
|
||||||
|
OutsideRightMiddle.class: [icon; OutsideRightMiddle]
|
||||||
|
OutsideRightBottom.class: [icon; OutsideRightBottom]
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: [icon; OutsideBottomLeft]
|
||||||
|
OutsideBottomCenter.class: [icon; OutsideBottomCenter]
|
||||||
|
OutsideBottomRight.class: [icon; OutsideBottomRight]
|
||||||
|
|
||||||
|
InsideTopLeft.class: [icon; InsideTopLeft]
|
||||||
|
InsideTopCenter.class: [icon; InsideTopCenter]
|
||||||
|
InsideTopRight.class: [icon; InsideTopRight]
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: [icon; InsideMiddleLeft]
|
||||||
|
InsideMiddleCenter.class: [icon; InsideMiddleCenter]
|
||||||
|
InsideMiddleRight.class: [icon; InsideMiddleRight]
|
||||||
|
|
||||||
|
InsideBottomLeft.class: [icon; InsideBottomLeft]
|
||||||
|
InsideBottomCenter.class: [icon; InsideBottomCenter]
|
||||||
|
InsideBottomRight.class: [icon; InsideBottomRight]
|
||||||
|
|
||||||
|
OutsideTopLeft.OutsideTopLeft
|
||||||
|
OutsideTopCenter.OutsideTopCenter
|
||||||
|
OutsideTopRight.OutsideTopRight
|
||||||
|
|
||||||
|
OutsideLeftTop.OutsideLeftTop
|
||||||
|
OutsideLeftMiddle.OutsideLeftMiddle
|
||||||
|
OutsideLeftBottom.OutsideLeftBottom
|
||||||
|
|
||||||
|
OutsideRightTop.OutsideRightTop
|
||||||
|
OutsideRightMiddle.OutsideRightMiddle
|
||||||
|
OutsideRightBottom.OutsideRightBottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.OutsideBottomLeft
|
||||||
|
OutsideBottomCenter.OutsideBottomCenter
|
||||||
|
OutsideBottomRight.OutsideBottomRight
|
||||||
|
|
||||||
|
InsideTopLeft.InsideTopLeft
|
||||||
|
InsideTopCenter.InsideTopCenter
|
||||||
|
InsideTopRight.InsideTopRight
|
||||||
|
|
||||||
|
InsideMiddleLeft.InsideMiddleLeft
|
||||||
|
InsideMiddleCenter.InsideMiddleCenter
|
||||||
|
InsideMiddleRight.InsideMiddleRight
|
||||||
|
|
||||||
|
InsideBottomLeft.InsideBottomLeft
|
||||||
|
InsideBottomCenter.InsideBottomCenter
|
||||||
|
InsideBottomRight.InsideBottomRight
|
||||||
|
}
|
||||||
|
|
||||||
|
image: {
|
||||||
|
Default.class: [icon; image]
|
||||||
|
|
||||||
|
OutsideTopLeft.class: [icon; image; OutsideTopLeft]
|
||||||
|
OutsideTopCenter.class: [icon; image; OutsideTopCenter]
|
||||||
|
OutsideTopRight.class: [icon; image; OutsideTopRight]
|
||||||
|
|
||||||
|
OutsideLeftTop.class: [icon; image; OutsideLeftTop]
|
||||||
|
OutsideLeftMiddle.class: [icon; image; OutsideLeftMiddle]
|
||||||
|
OutsideLeftBottom.class: [icon; image; OutsideLeftBottom]
|
||||||
|
|
||||||
|
OutsideRightTop.class: [icon; image; OutsideRightTop]
|
||||||
|
OutsideRightMiddle.class: [icon; image; OutsideRightMiddle]
|
||||||
|
OutsideRightBottom.class: [icon; image; OutsideRightBottom]
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: [icon; image; OutsideBottomLeft]
|
||||||
|
OutsideBottomCenter.class: [icon; image; OutsideBottomCenter]
|
||||||
|
OutsideBottomRight.class: [icon; image; OutsideBottomRight]
|
||||||
|
|
||||||
|
InsideTopLeft.class: [icon; image; InsideTopLeft]
|
||||||
|
InsideTopCenter.class: [icon; image; InsideTopCenter]
|
||||||
|
InsideTopRight.class: [icon; image; InsideTopRight]
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: [icon; image; InsideMiddleLeft]
|
||||||
|
InsideMiddleCenter.class: [icon; image; InsideMiddleCenter]
|
||||||
|
InsideMiddleRight.class: [icon; image; InsideMiddleRight]
|
||||||
|
|
||||||
|
InsideBottomLeft.class: [icon; image; InsideBottomLeft]
|
||||||
|
InsideBottomCenter.class: [icon; image; InsideBottomCenter]
|
||||||
|
InsideBottomRight.class: [icon; image; InsideBottomRight]
|
||||||
|
}
|
||||||
|
|
||||||
|
non container -> container -> image
|
||||||
|
|
||||||
|
classes: {
|
||||||
|
image.shape: image
|
||||||
|
icon.icon: https://icons.terrastruct.com/essentials/time.svg
|
||||||
|
|
||||||
|
OutsideTopLeft.icon.near: outside-top-left
|
||||||
|
OutsideTopCenter.icon.near: outside-top-center
|
||||||
|
OutsideTopRight.icon.near: outside-top-right
|
||||||
|
|
||||||
|
OutsideLeftTop.icon.near: outside-left-top
|
||||||
|
OutsideLeftMiddle.icon.near: outside-left-center
|
||||||
|
OutsideLeftBottom.icon.near: outside-left-bottom
|
||||||
|
|
||||||
|
OutsideRightTop.icon.near: outside-right-top
|
||||||
|
OutsideRightMiddle.icon.near: outside-right-center
|
||||||
|
OutsideRightBottom.icon.near: outside-right-bottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.icon.near: outside-bottom-left
|
||||||
|
OutsideBottomCenter.icon.near: outside-bottom-center
|
||||||
|
OutsideBottomRight.icon.near: outside-bottom-right
|
||||||
|
|
||||||
|
InsideTopLeft.icon.near: top-left
|
||||||
|
InsideTopCenter.icon.near: top-center
|
||||||
|
InsideTopRight.icon.near: top-right
|
||||||
|
|
||||||
|
InsideMiddleLeft.icon.near: center-left
|
||||||
|
InsideMiddleCenter.icon.near: center-center
|
||||||
|
InsideMiddleRight.icon.near: center-right
|
||||||
|
|
||||||
|
InsideBottomLeft.icon.near: bottom-left
|
||||||
|
InsideBottomCenter.icon.near: bottom-center
|
||||||
|
InsideBottomRight.icon.near: bottom-right
|
||||||
|
}
|
||||||
221
e2etests/testdata/files/label_positions.d2
vendored
Normal file
221
e2etests/testdata/files/label_positions.d2
vendored
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
non container: {
|
||||||
|
Default
|
||||||
|
|
||||||
|
OutsideTopLeft.class: OutsideTopLeft
|
||||||
|
OutsideTopCenter.class: OutsideTopCenter
|
||||||
|
OutsideTopRight.class: OutsideTopRight
|
||||||
|
|
||||||
|
OutsideLeftTop.class: OutsideLeftTop
|
||||||
|
OutsideLeftMiddle.class: OutsideLeftMiddle
|
||||||
|
OutsideLeftBottom.class: OutsideLeftBottom
|
||||||
|
|
||||||
|
OutsideRightTop.class: OutsideRightTop
|
||||||
|
OutsideRightMiddle.class: OutsideRightMiddle
|
||||||
|
OutsideRightBottom.class: OutsideRightBottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: OutsideBottomLeft
|
||||||
|
OutsideBottomCenter.class: OutsideBottomCenter
|
||||||
|
OutsideBottomRight.class: OutsideBottomRight
|
||||||
|
|
||||||
|
InsideTopLeft.class: InsideTopLeft
|
||||||
|
InsideTopCenter.class: InsideTopCenter
|
||||||
|
InsideTopRight.class: InsideTopRight
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: InsideMiddleLeft
|
||||||
|
InsideMiddleCenter.class: InsideMiddleCenter
|
||||||
|
InsideMiddleRight.class: InsideMiddleRight
|
||||||
|
|
||||||
|
InsideBottomLeft.class: InsideBottomLeft
|
||||||
|
InsideBottomCenter.class: InsideBottomCenter
|
||||||
|
InsideBottomRight.class: InsideBottomRight
|
||||||
|
}
|
||||||
|
|
||||||
|
container: {
|
||||||
|
Default.Default
|
||||||
|
|
||||||
|
OutsideTopLeft.class: OutsideTopLeft
|
||||||
|
OutsideTopCenter.class: OutsideTopCenter
|
||||||
|
OutsideTopRight.class: OutsideTopRight
|
||||||
|
|
||||||
|
OutsideLeftTop.class: OutsideLeftTop
|
||||||
|
OutsideLeftMiddle.class: OutsideLeftMiddle
|
||||||
|
OutsideLeftBottom.class: OutsideLeftBottom
|
||||||
|
|
||||||
|
OutsideRightTop.class: OutsideRightTop
|
||||||
|
OutsideRightMiddle.class: OutsideRightMiddle
|
||||||
|
OutsideRightBottom.class: OutsideRightBottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: OutsideBottomLeft
|
||||||
|
OutsideBottomCenter.class: OutsideBottomCenter
|
||||||
|
OutsideBottomRight.class: OutsideBottomRight
|
||||||
|
|
||||||
|
InsideTopLeft.class: InsideTopLeft
|
||||||
|
InsideTopCenter.class: InsideTopCenter
|
||||||
|
InsideTopRight.class: InsideTopRight
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: InsideMiddleLeft
|
||||||
|
InsideMiddleCenter.class: InsideMiddleCenter
|
||||||
|
InsideMiddleRight.class: InsideMiddleRight
|
||||||
|
|
||||||
|
InsideBottomLeft.class: InsideBottomLeft
|
||||||
|
InsideBottomCenter.class: InsideBottomCenter
|
||||||
|
InsideBottomRight.class: InsideBottomRight
|
||||||
|
|
||||||
|
OutsideTopLeft.OutsideTopLeft
|
||||||
|
OutsideTopCenter.OutsideTopCenter
|
||||||
|
OutsideTopRight.OutsideTopRight
|
||||||
|
|
||||||
|
OutsideLeftTop.OutsideLeftTop
|
||||||
|
OutsideLeftMiddle.OutsideLeftMiddle
|
||||||
|
OutsideLeftBottom.OutsideLeftBottom
|
||||||
|
|
||||||
|
OutsideRightTop.OutsideRightTop
|
||||||
|
OutsideRightMiddle.OutsideRightMiddle
|
||||||
|
OutsideRightBottom.OutsideRightBottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.OutsideBottomLeft
|
||||||
|
OutsideBottomCenter.OutsideBottomCenter
|
||||||
|
OutsideBottomRight.OutsideBottomRight
|
||||||
|
|
||||||
|
InsideTopLeft.InsideTopLeft
|
||||||
|
InsideTopCenter.InsideTopCenter
|
||||||
|
InsideTopRight.InsideTopRight
|
||||||
|
|
||||||
|
InsideMiddleLeft.InsideMiddleLeft
|
||||||
|
InsideMiddleCenter.InsideMiddleCenter
|
||||||
|
InsideMiddleRight.InsideMiddleRight
|
||||||
|
|
||||||
|
InsideBottomLeft.InsideBottomLeft
|
||||||
|
InsideBottomCenter.InsideBottomCenter
|
||||||
|
InsideBottomRight.InsideBottomRight
|
||||||
|
}
|
||||||
|
|
||||||
|
with icon: {
|
||||||
|
Default.class: icon
|
||||||
|
|
||||||
|
OutsideTopLeft.class: [icon; OutsideTopLeft]
|
||||||
|
OutsideTopCenter.class: [icon; OutsideTopCenter]
|
||||||
|
OutsideTopRight.class: [icon; OutsideTopRight]
|
||||||
|
|
||||||
|
OutsideLeftTop.class: [icon; OutsideLeftTop]
|
||||||
|
OutsideLeftMiddle.class: [icon; OutsideLeftMiddle]
|
||||||
|
OutsideLeftBottom.class: [icon; OutsideLeftBottom]
|
||||||
|
|
||||||
|
OutsideRightTop.class: [icon; OutsideRightTop]
|
||||||
|
OutsideRightMiddle.class: [icon; OutsideRightMiddle]
|
||||||
|
OutsideRightBottom.class: [icon; OutsideRightBottom]
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: [icon; OutsideBottomLeft]
|
||||||
|
OutsideBottomCenter.class: [icon; OutsideBottomCenter]
|
||||||
|
OutsideBottomRight.class: [icon; OutsideBottomRight]
|
||||||
|
|
||||||
|
InsideTopLeft.class: [icon; InsideTopLeft]
|
||||||
|
InsideTopCenter.class: [icon; InsideTopCenter]
|
||||||
|
InsideTopRight.class: [icon; InsideTopRight]
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: [icon; InsideMiddleLeft]
|
||||||
|
InsideMiddleCenter.class: [icon; InsideMiddleCenter]
|
||||||
|
InsideMiddleRight.class: [icon; InsideMiddleRight]
|
||||||
|
|
||||||
|
InsideBottomLeft.class: [icon; InsideBottomLeft]
|
||||||
|
InsideBottomCenter.class: [icon; InsideBottomCenter]
|
||||||
|
InsideBottomRight.class: [icon; InsideBottomRight]
|
||||||
|
}
|
||||||
|
|
||||||
|
container with icon: {
|
||||||
|
Default.Default
|
||||||
|
|
||||||
|
OutsideTopLeft.OutsideTopLeft
|
||||||
|
OutsideTopCenter.OutsideTopCenter
|
||||||
|
OutsideTopRight.OutsideTopRight
|
||||||
|
|
||||||
|
OutsideLeftTop.OutsideLeftTop
|
||||||
|
OutsideLeftMiddle.OutsideLeftMiddle
|
||||||
|
OutsideLeftBottom.OutsideLeftBottom
|
||||||
|
|
||||||
|
OutsideRightTop.OutsideRightTop
|
||||||
|
OutsideRightMiddle.OutsideRightMiddle
|
||||||
|
OutsideRightBottom.OutsideRightBottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.OutsideBottomLeft
|
||||||
|
OutsideBottomCenter.OutsideBottomCenter
|
||||||
|
OutsideBottomRight.OutsideBottomRight
|
||||||
|
|
||||||
|
InsideTopLeft.InsideTopLeft
|
||||||
|
InsideTopCenter.InsideTopCenter
|
||||||
|
InsideTopRight.InsideTopRight
|
||||||
|
|
||||||
|
InsideMiddleLeft.InsideMiddleLeft
|
||||||
|
InsideMiddleCenter.InsideMiddleCenter
|
||||||
|
InsideMiddleRight.InsideMiddleRight
|
||||||
|
|
||||||
|
InsideBottomLeft.InsideBottomLeft
|
||||||
|
InsideBottomCenter.InsideBottomCenter
|
||||||
|
InsideBottomRight.InsideBottomRight
|
||||||
|
|
||||||
|
Default.class: icon
|
||||||
|
|
||||||
|
OutsideTopLeft.class: [icon; OutsideTopLeft]
|
||||||
|
OutsideTopCenter.class: [icon; OutsideTopCenter]
|
||||||
|
OutsideTopRight.class: [icon; OutsideTopRight]
|
||||||
|
|
||||||
|
OutsideLeftTop.class: [icon; OutsideLeftTop]
|
||||||
|
OutsideLeftMiddle.class: [icon; OutsideLeftMiddle]
|
||||||
|
OutsideLeftBottom.class: [icon; OutsideLeftBottom]
|
||||||
|
|
||||||
|
OutsideRightTop.class: [icon; OutsideRightTop]
|
||||||
|
OutsideRightMiddle.class: [icon; OutsideRightMiddle]
|
||||||
|
OutsideRightBottom.class: [icon; OutsideRightBottom]
|
||||||
|
|
||||||
|
OutsideBottomLeft.class: [icon; OutsideBottomLeft]
|
||||||
|
OutsideBottomCenter.class: [icon; OutsideBottomCenter]
|
||||||
|
OutsideBottomRight.class: [icon; OutsideBottomRight]
|
||||||
|
|
||||||
|
InsideTopLeft.class: [icon; InsideTopLeft]
|
||||||
|
InsideTopCenter.class: [icon; InsideTopCenter]
|
||||||
|
InsideTopRight.class: [icon; InsideTopRight]
|
||||||
|
|
||||||
|
InsideMiddleLeft.class: [icon; InsideMiddleLeft]
|
||||||
|
InsideMiddleCenter.class: [icon; InsideMiddleCenter]
|
||||||
|
InsideMiddleRight.class: [icon; InsideMiddleRight]
|
||||||
|
|
||||||
|
InsideBottomLeft.class: [icon; InsideBottomLeft]
|
||||||
|
InsideBottomCenter.class: [icon; InsideBottomCenter]
|
||||||
|
InsideBottomRight.class: [icon; InsideBottomRight]
|
||||||
|
}
|
||||||
|
|
||||||
|
non container -> container -> with icon -> container with icon
|
||||||
|
|
||||||
|
classes: {
|
||||||
|
icon: {
|
||||||
|
icon: https://icons.terrastruct.com/essentials/time.svg
|
||||||
|
}
|
||||||
|
|
||||||
|
OutsideTopLeft.label.near: outside-top-left
|
||||||
|
OutsideTopCenter.label.near: outside-top-center
|
||||||
|
OutsideTopRight.label.near: outside-top-right
|
||||||
|
|
||||||
|
OutsideLeftTop.label.near: outside-left-top
|
||||||
|
OutsideLeftMiddle.label.near: outside-left-center
|
||||||
|
OutsideLeftBottom.label.near: outside-left-bottom
|
||||||
|
|
||||||
|
OutsideRightTop.label.near: outside-right-top
|
||||||
|
OutsideRightMiddle.label.near: outside-right-center
|
||||||
|
OutsideRightBottom.label.near: outside-right-bottom
|
||||||
|
|
||||||
|
OutsideBottomLeft.label.near: outside-bottom-left
|
||||||
|
OutsideBottomCenter.label.near: outside-bottom-center
|
||||||
|
OutsideBottomRight.label.near: outside-bottom-right
|
||||||
|
|
||||||
|
InsideTopLeft.label.near: top-left
|
||||||
|
InsideTopCenter.label.near: top-center
|
||||||
|
InsideTopRight.label.near: top-right
|
||||||
|
|
||||||
|
InsideMiddleLeft.label.near: center-left
|
||||||
|
InsideMiddleCenter.label.near: center-center
|
||||||
|
InsideMiddleRight.label.near: center-right
|
||||||
|
|
||||||
|
InsideBottomLeft.label.near: bottom-left
|
||||||
|
InsideBottomCenter.label.near: bottom-center
|
||||||
|
InsideBottomRight.label.near: bottom-right
|
||||||
|
}
|
||||||
4949
e2etests/testdata/stable/icon_positions/dagre/board.exp.json
generated
vendored
Normal file
4949
e2etests/testdata/stable/icon_positions/dagre/board.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
192
e2etests/testdata/stable/icon_positions/dagre/sketch.exp.svg
vendored
Normal file
192
e2etests/testdata/stable/icon_positions/dagre/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 61 KiB |
4931
e2etests/testdata/stable/icon_positions/elk/board.exp.json
generated
vendored
Normal file
4931
e2etests/testdata/stable/icon_positions/elk/board.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
192
e2etests/testdata/stable/icon_positions/elk/sketch.exp.svg
vendored
Normal file
192
e2etests/testdata/stable/icon_positions/elk/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 61 KiB |
6594
e2etests/testdata/stable/label_positions/dagre/board.exp.json
generated
vendored
Normal file
6594
e2etests/testdata/stable/label_positions/dagre/board.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
237
e2etests/testdata/stable/label_positions/dagre/sketch.exp.svg
vendored
Normal file
237
e2etests/testdata/stable/label_positions/dagre/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 79 KiB |
6567
e2etests/testdata/stable/label_positions/elk/board.exp.json
generated
vendored
Normal file
6567
e2etests/testdata/stable/label_positions/elk/board.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
237
e2etests/testdata/stable/label_positions/elk/sketch.exp.svg
vendored
Normal file
237
e2etests/testdata/stable/label_positions/elk/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 79 KiB |
|
|
@ -50,6 +50,34 @@ const (
|
||||||
UnlockedBottom Position = "UNLOCKED_BOTTOM"
|
UnlockedBottom Position = "UNLOCKED_BOTTOM"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (position Position) IsShapePosition() bool {
|
||||||
|
switch position {
|
||||||
|
case OutsideTopLeft, OutsideTopCenter, OutsideTopRight,
|
||||||
|
OutsideBottomLeft, OutsideBottomCenter, OutsideBottomRight,
|
||||||
|
OutsideLeftTop, OutsideLeftMiddle, OutsideLeftBottom,
|
||||||
|
OutsideRightTop, OutsideRightMiddle, OutsideRightBottom,
|
||||||
|
|
||||||
|
InsideTopLeft, InsideTopCenter, InsideTopRight,
|
||||||
|
InsideMiddleLeft, InsideMiddleCenter, InsideMiddleRight,
|
||||||
|
InsideBottomLeft, InsideBottomCenter, InsideBottomRight:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (position Position) IsEdgePosition() bool {
|
||||||
|
switch position {
|
||||||
|
case OutsideTopLeft, OutsideTopCenter, OutsideTopRight,
|
||||||
|
InsideMiddleLeft, InsideMiddleCenter, InsideMiddleRight,
|
||||||
|
OutsideBottomLeft, OutsideBottomCenter, OutsideBottomRight,
|
||||||
|
UnlockedTop, UnlockedMiddle, UnlockedBottom:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (position Position) IsOutside() bool {
|
func (position Position) IsOutside() bool {
|
||||||
switch position {
|
switch position {
|
||||||
case OutsideTopLeft, OutsideTopCenter, OutsideTopRight,
|
case OutsideTopLeft, OutsideTopCenter, OutsideTopRight,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue