shithub: mycel

Download patch

ref: aefd71facfcdaef5070cde8979bdd22e85ce20de
parent: 2f32575415b57d62b82664764855cf51896aa2f0
author: Philip Silva <[email protected]>
date: Mon Nov 22 08:28:31 EST 2021

add orig to rect

--- a/browser/browser.go
+++ b/browser/browser.go
@@ -310,6 +310,7 @@
 type Element struct {
 	duit.UI
 	n       *nodes.Node
+	orig    image.Point
 	rect    image.Rectangle
 	IsLink  bool
 	Click   func() duit.Event
@@ -424,7 +425,7 @@
 	if el == nil {
 		log.Errorf("Rect: nil element")
 	}
-	return el.rect
+	return el.rect.Add(el.orig)
 }
 
 func (el *Element) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool) {
@@ -446,6 +447,7 @@
 	} else {
 		el.UI.Draw(dui, self, img, orig, m, force)
 	}
+	el.orig = orig
 }
 
 func (el *Element) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool) {
@@ -476,7 +478,7 @@
 		el.UI.Layout(dui, self, sizeAvail, force)
 	}
 
-	el.rect  = self.R
+	el.rect = self.R
 
 	return
 }
--- a/browser/fs/experimental.go
+++ b/browser/fs/experimental.go
@@ -28,7 +28,7 @@
 // (dir structure stolen from domfs)
 type Node struct {
 	name string
-	nt *nodes.Node
+	nt   *nodes.Node
 }
 
 func (n Node) Stat() (s proto.Stat) {
@@ -59,7 +59,7 @@
 		ddn := fmt.Sprintf("%v", i)
 		cs[ddn] = &Node{
 			name: ddn,
-			nt: c,
+			nt:   c,
 		}
 	}
 	if n.nt.Type() == html.ElementNode {
@@ -161,7 +161,7 @@
 	for _, attr := range *as.attrs {
 		cs[attr.Key] = ff(attr.Key)
 	}
-	return 
+	return
 }
 
 type Style struct {
@@ -207,5 +207,5 @@
 	for p := range st.cs.Declarations {
 		cs[p] = ff(p)
 	}
-	return 
+	return
 }
--- a/js/js.go
+++ b/js/js.go
@@ -75,7 +75,7 @@
 	// Prevent Zombie processes after stopping
 	go cmd.Wait()
 
-	<-time.After(5*time.Second)
+	<-time.After(5 * time.Second)
 
 	resp, err := call("ctl", "start")
 	if err != nil {
--- a/nodes/experimental.go
+++ b/nodes/experimental.go
@@ -11,7 +11,7 @@
 func (n *Node) Path() (p string, ok bool) {
 	p, ok = n.path()
 	if ok {
-		p = opossum.PathPrefix+p
+		p = opossum.PathPrefix + p
 	}
 	return
 }
--- a/nodes/experimental_test.go
+++ b/nodes/experimental_test.go
@@ -1,12 +1,12 @@
 package nodes
 
 import (
+	"fmt"
 	"github.com/psilva261/opossum"
 	"github.com/psilva261/opossum/style"
 	"golang.org/x/net/html"
 	"strings"
 	"testing"
-"fmt"
 )
 
 func TestPath(t *testing.T) {