Diff
diff --git a/cstyle/plugins/textAlign/main.go b/cstyle/plugins/textAlign/main.go
index b0054d2..64f571b 100644
--- a/cstyle/plugins/textAlign/main.go
+++ b/cstyle/plugins/textAlign/main.go
@@ -6 +5,0 @@ import (
- "gui/library"
@@ -23,2 +22,2 @@ func Init() cstyle.Plugin {
- Level: 3,
- Handler: func(n *element.Node, state *map[string]element.State, shelf *library.Shelf) {
+ Level: 2,
+ Handler: func(n *element.Node, state *map[string]element.State) {
@@ -26,0 +26 @@ func Init() cstyle.Plugin {
+ // parent := s[n.Parent.Properties.Id]
@@ -30,9 +30 @@ func Init() cstyle.Plugin {
- nChildren := []*element.Node{}
-
- for _, v := range n.Children {
- // This prevents using absolutely positionioned elements in the alignment of text
- // + Will need to add the other styles
- if v.Style["position"] != "absolute" {
- nChildren = append(nChildren, v)
- }
- }
+ // fmt.Println(n.Properties.Id)
@@ -39,0 +32 @@ func Init() cstyle.Plugin {
+ // fmt.Println(n.Properties.Id, len(n.Children))
@@ -41,3 +34,3 @@ func Init() cstyle.Plugin {
- if len(nChildren) > 0 {
- minX = s[nChildren[0].Properties.Id].X
- baseY := s[nChildren[0].Properties.Id].Y + s[nChildren[0].Properties.Id].Height
+ if len(n.Children) > 0 {
+ minX = s[n.Children[0].Properties.Id].X
+ baseY := s[n.Children[0].Properties.Id].Y + s[n.Children[0].Properties.Id].Height
@@ -45,3 +38,4 @@ func Init() cstyle.Plugin {
- for i := 1; i < len(nChildren)-1; i++ {
- cState := s[nChildren[i].Properties.Id]
- next := s[nChildren[i+1].Properties.Id]
+ for i := 1; i < len(n.Children)-1; i++ {
+
+ cState := s[n.Children[i].Properties.Id]
+ next := s[n.Children[i+1].Properties.Id]
@@ -59,3 +53,3 @@ func Init() cstyle.Plugin {
- cState := s[nChildren[a].Properties.Id]
- cState.X += self.Padding.Left + ((((self.Width - (self.Padding.Left + self.Padding.Right)) + (self.Border.Left.Width + self.Border.Right.Width)) - (maxXW - minX)) / 2) - (minX - self.X)
- (*state)[nChildren[a].Properties.Id] = cState
+ cState := s[n.Children[a].Properties.Id]
+ cState.X += (((self.Width + (self.Border.Left.Width + self.Border.Right.Width)) - (maxXW - minX)) / 2) - (minX - self.X)
+ (*state)[n.Children[a].Properties.Id] = cState
@@ -69,6 +63,6 @@ func Init() cstyle.Plugin {
- minX = s[nChildren[last].Properties.Id].X
- maxXW = s[nChildren[len(nChildren)-1].Properties.Id].X + s[nChildren[len(nChildren)-1].Properties.Id].Width
- for a := last; a < len(nChildren); a++ {
- cState := s[nChildren[a].Properties.Id]
- cState.X += self.Padding.Left + ((((self.Width - (self.Padding.Left + self.Padding.Right)) + (self.Border.Left.Width + self.Border.Right.Width)) - (maxXW - minX)) / 2) - (minX - self.X)
- (*state)[nChildren[a].Properties.Id] = cState
+ minX = s[n.Children[last].Properties.Id].X
+ maxXW = s[n.Children[len(n.Children)-1].Properties.Id].X + s[n.Children[len(n.Children)-1].Properties.Id].Width
+ for a := last; a < len(n.Children); a++ {
+ cState := s[n.Children[a].Properties.Id]
+ cState.X += (((self.Width + (self.Border.Left.Width + self.Border.Right.Width)) - (maxXW - minX)) / 2) - (minX - self.X)
+ (*state)[n.Children[a].Properties.Id] = cState
@@ -78,3 +72,3 @@ func Init() cstyle.Plugin {
- if len(nChildren) > 0 {
- minX = s[nChildren[0].Properties.Id].X
- baseY := s[nChildren[0].Properties.Id].Y + s[nChildren[0].Properties.Id].Height
+ if len(n.Children) > 0 {
+ minX = s[n.Children[0].Properties.Id].X
+ baseY := s[n.Children[0].Properties.Id].Y + s[n.Children[0].Properties.Id].Height
@@ -82 +76 @@ func Init() cstyle.Plugin {
- for i := 1; i < len(nChildren)-1; i++ {
+ for i := 1; i < len(n.Children)-1; i++ {
@@ -84,2 +78,2 @@ func Init() cstyle.Plugin {
- cState := s[nChildren[i].Properties.Id]
- next := s[nChildren[i+1].Properties.Id]
+ cState := s[n.Children[i].Properties.Id]
+ next := s[n.Children[i+1].Properties.Id]
@@ -97 +91 @@ func Init() cstyle.Plugin {
- cState := s[nChildren[a].Properties.Id]
+ cState := s[n.Children[a].Properties.Id]
@@ -99 +93 @@ func Init() cstyle.Plugin {
- (*state)[nChildren[a].Properties.Id] = cState
+ (*state)[n.Children[a].Properties.Id] = cState
@@ -107,4 +101,4 @@ func Init() cstyle.Plugin {
- minX = s[nChildren[last].Properties.Id].X
- maxXW = s[nChildren[len(nChildren)-1].Properties.Id].X + s[nChildren[len(nChildren)-1].Properties.Id].Width
- for a := last; a < len(nChildren); a++ {
- cState := s[nChildren[a].Properties.Id]
+ minX = s[n.Children[last].Properties.Id].X
+ maxXW = s[n.Children[len(n.Children)-1].Properties.Id].X + s[n.Children[len(n.Children)-1].Properties.Id].Width
+ for a := last; a < len(n.Children); a++ {
+ cState := s[n.Children[a].Properties.Id]
@@ -112 +106 @@ func Init() cstyle.Plugin {
- (*state)[nChildren[a].Properties.Id] = cState
+ (*state)[n.Children[a].Properties.Id] = cState