Diff
diff --git a/docs/cstyle/plugins/inline/index.html b/docs/cstyle/plugins/inline/index.html
index 40bc357..d50cb2c 100644
--- a/docs/cstyle/plugins/inline/index.html
+++ b/docs/cstyle/plugins/inline/index.html
@@ -30,109 +30,111 @@
- 4 "gui/cstyle"
- 5 "gui/element"
- 6 "math"
- 7)
- 8
- 9func Init() cstyle.Plugin {
- 10 return cstyle.Plugin{
- 11 Selector: func(n *element.Node) bool {
- 12 styles := map[string]string{
- 13 "display": "inline",
- 14 }
- 15 matches := true
- 16 for name, value := range styles {
- 17 if n.Style[name] != value && !(value == "*") && n.Style[name] != "" {
- 18 matches = false
- 19 }
- 20 }
- 21 return matches
- 22 },
- 23 Level: 1,
- 24 Handler: func(n *element.Node, state *map[string]element.State) {
- 25 s := *state
- 26 self := s[n.Properties.Id]
- 27 parent := s[n.Parent.Properties.Id]
- 28 copyOfX := self.X
- 29 copyOfY := self.Y
- 30 if copyOfX < parent.X+parent.Padding.Left {
- 31 copyOfX = parent.X + parent.Padding.Left
- 32 }
- 33
- 34 // xCollect := float32(0)
- 35 for i, v := range n.Parent.Children {
- 36 // vState := s[v.Properties.Id]
- 37 if i > 0 {
- 38 if v.Style["position"] != "absolute" {
- 39 if v.Properties.Id == n.Properties.Id {
- 40 sib := n.Parent.Children[i-1]
- 41 sibling := s[sib.Properties.Id]
- 42 if sibling.X+sibling.Width+self.Width > (parent.Width+parent.X+parent.Border.Left.Width)-parent.Padding.Left {
- 43 // Break Node.Id
- 44 self.Y = sibling.Y + sibling.Height
- 45 self.X = copyOfX
- 46 } else {
- 47 // Node did not break
- 48 if sib.Style["display"] != "inline" {
- 49 self.Y = sibling.Y + sibling.Height
- 50 } else {
- 51 self.Y = sibling.Y
- 52 self.X = sibling.X + sibling.Width
- 53 }
- 54 if n.InnerText != "" {
- 55 baseY := sibling.Y
- 56 var max float32
- 57 for a := i; a >= 0; a-- {
- 58 b := n.Parent.Children[a]
- 59 bStyle := s[b.Properties.Id]
- 60 if bStyle.Y == baseY {
- 61 if bStyle.EM > max {
- 62 max = bStyle.EM
- 63 }
- 64 }
- 65 }
- 66
- 67 for a := i; a >= 0; a-- {
- 68 b := n.Parent.Children[a]
- 69 bStyle := s[b.Properties.Id]
- 70 if bStyle.Y == baseY {
- 71 bStyle.Y += (float32(math.Ceil(float64((max - (max * 0.3))))) - float32(math.Ceil(float64(bStyle.EM-(bStyle.EM*0.3)))))
- 72 (*state)[b.Properties.Id] = bStyle
- 73 }
- 74 }
- 75 if self.Y == baseY {
- 76 self.Y += (float32(math.Ceil(float64((max - (max * 0.3))))) - float32(math.Ceil(float64(self.EM-(self.EM*0.3)))))
- 77 }
- 78 }
- 79
- 80 }
- 81 break
- 82 }
- 83 }
- 84 }
- 85
- 86 }
- 87 propagateOffsets(n, copyOfX, copyOfY, self, state)
- 88 (*state)[n.Properties.Id] = self
- 89 },
- 90 }
- 91}
- 92
- 93func propagateOffsets(n *element.Node, copyOfX, copyOfY float32, self element.State, state *map[string]element.State) {
- 94 s := *state
- 95 for _, v := range n.Children {
- 96 vState := s[v.Properties.Id]
- 97 vState.X += self.X - copyOfX
- 98 vState.Y += self.Y - copyOfY
- 99 if len(v.Children) > 0 {
-100 propagateOffsets(v, copyOfX, copyOfY, self, state)
-101 }
-102 (*state)[v.Properties.Id] = vState
-103 }
-104}
-105
-106// func colliderDetection(s1, s2 element.State) bool {
-107// s1Min := s1.Y
-108// s1Max := s1.Y + s1.Height
-109// s2Min := s2.Y
-110// s2Max := s2.Y + s2.Height
-111// return s1Min > s2Min && s1Min < s2Max || s1Max > s2Min && s1Min < s2Max || s2Min > s1Min && s2Min < s1Max || s2Max > s1Min && s2Min < s1Max
-112// }
+ 4 "fmt"
+ 5 "gui/cstyle"
+ 6 "gui/element"
+ 7 "math"
+ 8)
+ 9
+ 10func Init() cstyle.Plugin {
+ 11 return cstyle.Plugin{
+ 12 Selector: func(n *element.Node) bool {
+ 13 styles := map[string]string{
+ 14 "display": "inline",
+ 15 }
+ 16 matches := true
+ 17 for name, value := range styles {
+ 18 if n.Style[name] != value && !(value == "*") && n.Style[name] != "" {
+ 19 matches = false
+ 20 }
+ 21 }
+ 22 return matches
+ 23 },
+ 24 Level: 1,
+ 25 Handler: func(n *element.Node, state *map[string]element.State) {
+ 26 s := *state
+ 27 self := s[n.Properties.Id]
+ 28 parent := s[n.Parent.Properties.Id]
+ 29 copyOfX := self.X
+ 30 copyOfY := self.Y
+ 31 if copyOfX < parent.X+parent.Padding.Left {
+ 32 copyOfX = parent.X + parent.Padding.Left
+ 33 }
+ 34
+ 35 // xCollect := float32(0)
+ 36 for i, v := range n.Parent.Children {
+ 37 // vState := s[v.Properties.Id]
+ 38 if i > 0 {
+ 39 if v.Style["position"] != "absolute" {
+ 40 if v.Properties.Id == n.Properties.Id {
+ 41 sib := n.Parent.Children[i-1]
+ 42 sibling := s[sib.Properties.Id]
+ 43 if sibling.X+sibling.Width+self.Width > (parent.Width+parent.X+parent.Border.Width)-parent.Padding.Left {
+ 44 // Break Node.Id
+ 45 self.Y = sibling.Y + sibling.Height
+ 46 self.X = copyOfX
+ 47 fmt.Println(n.InnerText, self.X, parent.X)
+ 48 } else {
+ 49 // Node did not break
+ 50 if sib.Style["display"] != "inline" {
+ 51 self.Y = sibling.Y + sibling.Height
+ 52 } else {
+ 53 self.Y = sibling.Y
+ 54 self.X = sibling.X + sibling.Width
+ 55 }
+ 56 if n.InnerText != "" {
+ 57 baseY := sibling.Y
+ 58 var max float32
+ 59 for a := i; a >= 0; a-- {
+ 60 b := n.Parent.Children[a]
+ 61 bStyle := s[b.Properties.Id]
+ 62 if bStyle.Y == baseY {
+ 63 if bStyle.EM > max {
+ 64 max = bStyle.EM
+ 65 }
+ 66 }
+ 67 }
+ 68
+ 69 for a := i; a >= 0; a-- {
+ 70 b := n.Parent.Children[a]
+ 71 bStyle := s[b.Properties.Id]
+ 72 if bStyle.Y == baseY {
+ 73 bStyle.Y += (float32(math.Ceil(float64((max - (max * 0.3))))) - float32(math.Ceil(float64(bStyle.EM-(bStyle.EM*0.3)))))
+ 74 (*state)[b.Properties.Id] = bStyle
+ 75 }
+ 76 }
+ 77 if self.Y == baseY {
+ 78 self.Y += (float32(math.Ceil(float64((max - (max * 0.3))))) - float32(math.Ceil(float64(self.EM-(self.EM*0.3)))))
+ 79 }
+ 80 }
+ 81
+ 82 }
+ 83 break
+ 84 }
+ 85 }
+ 86 }
+ 87
+ 88 }
+ 89 propagateOffsets(n, copyOfX, copyOfY, self, state)
+ 90 (*state)[n.Properties.Id] = self
+ 91 },
+ 92 }
+ 93}
+ 94
+ 95func propagateOffsets(n *element.Node, copyOfX, copyOfY float32, self element.State, state *map[string]element.State) {
+ 96 s := *state
+ 97 for _, v := range n.Children {
+ 98 vState := s[v.Properties.Id]
+ 99 vState.X += self.X - copyOfX
+100 vState.Y += self.Y - copyOfY
+101 if len(v.Children) > 0 {
+102 propagateOffsets(v, copyOfX, copyOfY, self, state)
+103 }
+104 (*state)[v.Properties.Id] = vState
+105 }
+106}
+107
+108// func colliderDetection(s1, s2 element.State) bool {
+109// s1Min := s1.Y
+110// s1Max := s1.Y + s1.Height
+111// s2Min := s2.Y
+112// s2Max := s2.Y + s2.Height
+113// return s1Min > s2Min && s1Min < s2Max || s1Max > s2Min && s1Min < s2Max || s2Min > s1Min && s2Min < s1Max || s2Max > s1Min && s2Min < s1Max
+114// }