Diff
diff --git a/cstyle/plugins/crop/main.go b/cstyle/plugins/crop/main.go
index 1d331ed..269465a 100644
--- a/cstyle/plugins/crop/main.go
+++ b/cstyle/plugins/crop/main.go
@@ -4 +3,0 @@ import (
- "fmt"
@@ -7 +6 @@ import (
- "strings"
+ "gui/library"
@@ -21 +20 @@ func Init() cstyle.Plugin {
- Handler: func(n *element.Node, state *map[string]element.State) {
+ Handler: func(n *element.Node, state *map[string]element.State, shelf *library.Shelf) {
@@ -26 +25 @@ func Init() cstyle.Plugin {
- // if n.ScrollTop == 0 {
+ // if n.ScrollY == 0 {
@@ -29,11 +28,4 @@ func Init() cstyle.Plugin {
- scrollY := n.ScrollY
- // scrollY := findScroll(n)
- // thumb := scrollEl.QuerySelector("grim-thumb")
- // fmt.Println("this", s[scrollEl.Properties.Id].Y, s[thumb.Properties.Id].Y)
- // scrollTop := int((s[thumb.Properties.Id].Y - s[scrollEl.Properties.Id].Y) + float32(scrollY))
- // // !TODO: Limit scroll
- // // + in the styles per what ever the css way to do it is
- // // fmt.Println(scrollTop, scrollEl.ScrollY)
- // if scrollTop < 0 {
- // scrollTop = 0
- // }
+ scrollY := findScroll(n)
+ // !TODO: Limit scroll, and make scroll bar
+ // + in the styles per what ever the css way to do it is
+
@@ -41,10 +33,9 @@ func Init() cstyle.Plugin {
- // // !ISSUE: Can add to the scroll value while it is pegged out
- scrollAmt := ((maxY - minY) + self.Padding.Bottom + self.Padding.Top) / self.Height
- // // if there is more than 100% of parent
- // if scrollAmt > 1 {
- // diff := scrollAmt - 1
- // if scrollTop > int(self.Height*diff) {
- // scrollTop = int(self.Height * diff)
- // // need to stop the scroll value by dispatching an event to set the scroll
- // }
- // }
+ // !ISSUE: Can add to the scroll value while it is pegged out
+ scrollAmt := ((maxY - minY) + self.Padding.Bottom) / self.Height
+ if scrollAmt > 1 {
+ diff := scrollAmt - 1
+ if scrollY > int(self.Height*diff) {
+ scrollY = int(self.Height * diff)
+ n.ScrollY = scrollY
+ }
+ }
@@ -53,14 +43,0 @@ func Init() cstyle.Plugin {
- scrollTop := 0
- for _, v := range n.Children {
- if v.TagName == "grim-scrollbar" {
- if scrollAmt > 1 {
- diff := 1 - (scrollAmt - 1)
- p := s[v.Children[0].Properties.Id]
- p.Height = self.Height * diff
- p.Y += float32(scrollY)
- if self.Y+self.Height < p.Y+p.Height {
- p.Y = (self.Y + self.Height) - p.Height
- } else if p.Y < self.Y {
- p.Y = self.Y
- }
- fmt.Println(p.Y)
@@ -68,11 +45,34 @@ func Init() cstyle.Plugin {
- scrollTop = int((p.Y - self.Y))
- (*state)[v.Children[0].Properties.Id] = p
- } else {
- p := s[v.Properties.Id]
- p.Hidden = true
- (*state)[v.Properties.Id] = p
- }
- break
- }
- }
- fmt.Println(scrollTop, scrollY)
+ // DOnt work
+ // !TODO: The width of the scroll bar needs to effect the width of the content inside of the container, needs
+ // + to be moved up the render chain
+ // + Also ::before and ::after can be handled by a plugin but will also need to be moved up
+
+ // need to run before everything else, parents styles that need to change are width -= scrollbar width, padding-right += scrollbar-width
+
+ // !TODO: Add keygen
+ // key := n.Properties.Id + "123123"
+ // exists := shelf.Check(key)
+ // if exists {
+ // lookup := make(map[string]struct{}, len(self.Textures))
+ // for _, v := range self.Textures {
+ // lookup[v] = struct{}{}
+ // }
+
+ // if _, found := lookup[key]; !found {
+ // self.Textures = append(self.Textures, key)
+ // }
+ // } else {
+ // width := int(self.Width + self.Padding.Left + self.Padding.Right)
+ // height := int(self.Height + self.Padding.Top + self.Padding.Bottom)
+ // ctx := canvas.NewCanvas(width, int(height))
+ // ctx.FillStyle = color.RGBA{0, 255, 0, 255}
+ // ctx.LineWidth = 1
+ // ctx.BeginPath()
+ // ctx.Rect(width-32, -1, 30, int(height)-1)
+ // ctx.Fill()
+ // ctx.ClosePath()
+ // fmt.Println(self.Textures, ctx.Context.RGBAAt(width+10, 10))
+ // self.Textures = append(self.Textures, shelf.Set(key, ctx.Context))
+ // }
+ // self.Width -= 30
+
@@ -85 +85 @@ func Init() cstyle.Plugin {
- if (child.Y+child.Height)-float32(scrollTop) < (self.Y) || (child.Y-float32(scrollTop)) > self.Y+self.Height {
+ if (child.Y+child.Height)-float32(scrollY) < (self.Y) || (child.Y-float32(scrollY)) > self.Y+self.Height {
@@ -93,2 +93,2 @@ func Init() cstyle.Plugin {
- if child.Y-float32(scrollTop) < (self.Y) {
- yCrop = int((self.Y) - (child.Y - float32(scrollTop)))
+ if child.Y-float32(scrollY) < (self.Y) {
+ yCrop = int((self.Y) - (child.Y - float32(scrollY)))
@@ -96,2 +96,2 @@ func Init() cstyle.Plugin {
- } else if (child.Y-float32(scrollTop))+child.Height > self.Y+self.Height {
- diff := ((child.Y - float32(scrollTop)) + child.Height) - (self.Y + self.Height)
+ } else if (child.Y-float32(scrollY))+child.Height > self.Y+self.Height {
+ diff := ((child.Y - float32(scrollY)) + child.Height) - (self.Y + self.Height)
@@ -107 +107 @@ func Init() cstyle.Plugin {
- // child.Y -= float32(n.ScrollTop)
+ // child.Y -= float32(n.ScrollY)
@@ -109 +109 @@ func Init() cstyle.Plugin {
- updateChildren(v, state, scrollTop)
+ updateChildren(v, state, scrollY)
@@ -125,0 +126,16 @@ func updateChildren(n *element.Node, state *map[string]element.State, offset int
+func findScroll(n *element.Node) int {
+ if n.ScrollY != 0 {
+ return n.ScrollY
+ } else {
+ for _, v := range n.Children {
+ if v.Style["overflow"] == "" && v.Style["overflow-x"] == "" && v.Style["overflow-y"] == "" {
+ s := findScroll(v)
+ if s != 0 {
+ return s
+ }
+ }
+ }
+ return 0
+ }
+}
+
@@ -131,3 +146,0 @@ func findBounds(n *element.Node, state *map[string]element.State) (float32, floa
- if strings.HasPrefix(v.TagName, "grim") {
- continue
- }
@@ -152,13 +164,0 @@ func findBounds(n *element.Node, state *map[string]element.State) (float32, floa
-
-func findScroll(n *element.Node) int {
- // THis function should only return a value if none of its children have a value
- for _, v := range n.Children {
- if v.Style["overflow"] == "" && v.Style["overflow-x"] == "" && v.Style["overflow-y"] == "" {
- s := findScroll(v)
- if s != 0 {
- return 0
- }
- }
- }
- return n.ScrollY
-}