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