ref: 3ddf47ad691b8fdae0aa930543107052a6ee2d6d
parent: ba66a58b7772b1d28f90f103ee0f97415e20ef52
author: Philip Silva <[email protected]>
date: Sat Feb 13 14:34:52 EST 2021
minor optimization
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -57,13 +57,23 @@
log = l
}
-type ColoredLabel struct {
+type Label struct {
*duit.Label
n *nodes.Node
}
-func (ui *ColoredLabel) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool) {
+func NewLabel(t string, n *nodes.Node) *Label {
+ return &Label{
+ Label: &duit.Label{
+ Text: t,
+ Font: n.Font(),
+ },
+ n: n,
+ }
+}
+
+func (ui *Label) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool) {
c := ui.n.Map.Color()
i, ok := colorCache[c]
if !ok {
@@ -932,13 +942,7 @@
t = "• " + t
}
}
- innerContent = &ColoredLabel{
- Label: &duit.Label{
- Text: t,
- Font: n.Font(),
- },
- n: n,
- }
+ innerContent = NewLabel(t, n)
} else {
innerContent = InnerNodesToBox(r+1, b, n)
}
@@ -952,13 +956,10 @@
var innerContent duit.UI
if nodes.IsPureTextContent(*n) {
- innerContent = &ColoredLabel{
- Label: &duit.Label{
- Text: nodes.ContentFrom(*n),
- Font: n.Font(),
- },
- n: n,
- }
+ innerContent = NewLabel(
+ nodes.ContentFrom(*n),
+ n,
+ )
} else {
innerContent = InnerNodesToBox(r+1, b, n)
}
@@ -983,13 +984,7 @@
var innerContent duit.UI
if nodes.IsPureTextContent(*n) {
t := strings.TrimSpace(nodes.ContentFrom(*n))
- innerContent = &ColoredLabel{
- Label: &duit.Label{
- Text: t,
- Font: n.Font(),
- },
- n: n,
- }
+ innerContent = NewLabel(t, n)
} else {
innerContent = InnerNodesToBox(r+1, b, n)
}
@@ -1015,13 +1010,7 @@
}
text = strings.Join(nn, " ")
- ui := &ColoredLabel{
- Label: &duit.Label{
- Text: text,
- Font: n.Font(),
- },
- n: n,
- }
+ ui := NewLabel(text, n)
return NewElement(
ui,
@@ -1084,7 +1073,7 @@
}
case *duit.Image:
case *duit.Label:
- case *ColoredLabel:
+ case *Label:
traverseTree(r+1, v.Label, f)
case *Image:
traverseTree(r+1, v.Image, f)
@@ -1143,12 +1132,12 @@
t = t[:15] + "..."
}
fmt.Printf("Label %v\n", t)
- case *ColoredLabel:
+ case *Label:
t := v.Text
if len(t) > 20 {
t = t[:15] + "..."
}
- fmt.Printf("ColoredLabel %v\n", t)
+ fmt.Printf("Label %v\n", t)
default:
fmt.Printf("%+v\n", v)
}
--- a/browser/experimental.go
+++ b/browser/experimental.go
@@ -72,7 +72,7 @@
return true
case *duit.Label:
return true
- case *ColoredLabel:
+ case *Label:
return false
case *duit.Button:
return true
@@ -109,7 +109,7 @@
case *duit.Grid:
case *duit.Image:
case *duit.Label:
- case *ColoredLabel:
+ case *Label:
case *duit.Button:
case *Image:
case *duit.Field:
--- a/package.rc
+++ b/package.rc
@@ -18,6 +18,7 @@
mv $name.bin ./$name/
cp README.md ./$name/
cp normalize.css ./$name/
+cp possum-655x493.jpg ./$name/
dircp domino-lib ./$name/domino-lib
tarball=`{pwd} ^ '/packages/' ^ $name ^ '-v0.0.1-' ^ `{date -i} ^ '-' ^ `{cat /mnt/git/branch/heads/master/hash | read -c 6} ^ '.tgz'
tar czf $tarball $name