Compare commits
6 Commits
2af42a3568
...
v0.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
| d166d88388 | |||
| 74025aac97 | |||
| e1cf524c57 | |||
| 919f000073 | |||
| 8aa8dc9570 | |||
| a60a729ad9 |
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/backend
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
git.tebibyte.media/tomo/tomo v0.42.0
|
||||
git.tebibyte.media/tomo/tomo v0.45.0
|
||||
git.tebibyte.media/tomo/typeset v0.7.1
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1
|
||||
github.com/jezek/xgb v1.1.1
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,6 +1,6 @@
|
||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||
git.tebibyte.media/tomo/tomo v0.42.0 h1:yaEUnURYrvBdMdcajrFhpd83TNzyQyBB+jOxvIyQTkU=
|
||||
git.tebibyte.media/tomo/tomo v0.42.0/go.mod h1:WrtilgKB1y8O2Yu7X4mYcRiqOlPR8NuUnoA/ynkQWrs=
|
||||
git.tebibyte.media/tomo/tomo v0.45.0 h1:fQH0WIPidW275hOq9dE6R7p064xG1RGx2QU68Avlr84=
|
||||
git.tebibyte.media/tomo/tomo v0.45.0/go.mod h1:WrtilgKB1y8O2Yu7X4mYcRiqOlPR8NuUnoA/ynkQWrs=
|
||||
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
||||
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
||||
|
||||
@@ -423,6 +423,13 @@ func (this *box) Draw (can canvas.Canvas) {
|
||||
|
||||
// centered texture
|
||||
if textureMode == tomo.TextureModeCenter && texture != nil {
|
||||
this.centeredTexture(can, texture)
|
||||
}
|
||||
}
|
||||
|
||||
func (this *box) centeredTexture (can canvas.Canvas, texture canvas.Texture) {
|
||||
pen := can.Pen()
|
||||
bounds := this.Bounds()
|
||||
textureBounds := texture.Bounds()
|
||||
textureOrigin :=
|
||||
bounds.Min.
|
||||
@@ -436,7 +443,6 @@ func (this *box) Draw (can canvas.Canvas) {
|
||||
pen.Fill(color.Transparent)
|
||||
pen.Texture(texture)
|
||||
pen.Rectangle(textureBounds.Sub(textureBounds.Min).Add(textureOrigin))
|
||||
}
|
||||
}
|
||||
|
||||
func (this *box) drawBorders (can canvas.Canvas) {
|
||||
@@ -602,7 +608,8 @@ func (this *box) invalidateMinimum () {
|
||||
}
|
||||
|
||||
func (this *box) recursiveReApply () {
|
||||
if this.getHierarchy() == nil { return }
|
||||
hierarchy := this.getHierarchy()
|
||||
if hierarchy == nil { return }
|
||||
|
||||
// re-apply styling, icons *if needed*
|
||||
|
||||
@@ -614,7 +621,7 @@ func (this *box) recursiveReApply () {
|
||||
// information about the boxes they're linked to (like all rules
|
||||
// with a matching role).
|
||||
this.lastStyleNonce = hierarchyStyleNonce
|
||||
this.styleApplicator = this.getHierarchy().newStyleApplicator()
|
||||
this.styleApplicator = hierarchy.newStyleApplicator()
|
||||
this.invalidateStyle()
|
||||
this.on.styleChange.Broadcast()
|
||||
}
|
||||
|
||||
@@ -493,9 +493,9 @@ func (this *textBox) scrollToDot () {
|
||||
|
||||
func (this *textBox) handleFaceChange () {
|
||||
hierarchy := this.getHierarchy()
|
||||
if hierarchy != nil { return }
|
||||
if hierarchy == nil { return }
|
||||
faceSet := hierarchy.getFaceSet()
|
||||
if faceSet != nil { return }
|
||||
if faceSet == nil { return }
|
||||
|
||||
face := faceSet.Face(tomo.Face(this.attrFace.Value()))
|
||||
this.face.Set(face, face)
|
||||
@@ -503,3 +503,23 @@ func (this *textBox) handleFaceChange () {
|
||||
this.invalidateMinimum()
|
||||
this.invalidateLayout()
|
||||
}
|
||||
|
||||
func (this *textBox) recursiveReApply () {
|
||||
this.box.recursiveReApply()
|
||||
|
||||
hierarchy := this.getHierarchy()
|
||||
if hierarchy == nil { return }
|
||||
|
||||
previousFace := this.face.Value()
|
||||
if previousFace == nil {
|
||||
faceSet := hierarchy.getFaceSet()
|
||||
if faceSet == nil { return }
|
||||
face := faceSet.Face(tomo.Face(this.attrFace.Value()))
|
||||
if face != previousFace {
|
||||
this.face.Set(face, face)
|
||||
this.drawer.SetFace(face)
|
||||
this.invalidateMinimum()
|
||||
this.invalidateLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
x/backend.go
32
x/backend.go
@@ -4,7 +4,9 @@ import "image"
|
||||
import "errors"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/xgbkb"
|
||||
import "git.tebibyte.media/tomo/tomo/data"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
import "git.tebibyte.media/tomo/backend/style"
|
||||
import "git.tebibyte.media/tomo/backend/x/canvas"
|
||||
import "git.tebibyte.media/tomo/backend/internal/system"
|
||||
|
||||
@@ -18,6 +20,9 @@ type Backend struct {
|
||||
x *xgbutil.XUtil
|
||||
system *system.System
|
||||
|
||||
style *style.Style
|
||||
iconSet style.IconSet
|
||||
|
||||
doChannel chan func()
|
||||
windows map[xproto.Window] *window
|
||||
open bool
|
||||
@@ -126,12 +131,33 @@ func (this *Backend) NewCanvas (bounds image.Rectangle) canvas.CanvasCloser {
|
||||
return xcanvas.NewCanvas(this.x, bounds)
|
||||
}
|
||||
|
||||
func (this *Backend) SetStyle (style *tomo.Style) {
|
||||
func (this *Backend) ColorRGBA (id tomo.Color) (r, g, b, a uint32) {
|
||||
if col, ok := this.style.Colors[id]; ok {
|
||||
return col.RGBA()
|
||||
}
|
||||
return 0xFFFF, 0, 0xFFFF, 0xFFFF // punish bad styles
|
||||
}
|
||||
|
||||
func (this *Backend) IconTexture (id tomo.Icon, size tomo.IconSize) canvas.Texture {
|
||||
return this.iconSet.Icon(id, size)
|
||||
}
|
||||
|
||||
func (this *Backend) MimeIconTexture (mime data.Mime, size tomo.IconSize) canvas.Texture {
|
||||
return this.iconSet.MimeIcon(mime, size)
|
||||
}
|
||||
|
||||
func (this *Backend) SetStyle (style *style.Style) {
|
||||
this.style = style
|
||||
this.system.SetStyle(style)
|
||||
}
|
||||
|
||||
func (this *Backend) SetIconSet (icons tomo.IconSet) {
|
||||
this.system.SetIconSet(icons)
|
||||
func (this *Backend) SetIconSet (iconSet style.IconSet) {
|
||||
this.iconSet = iconSet
|
||||
this.system.SetIconSet(iconSet)
|
||||
}
|
||||
|
||||
func (this *Backend) SetFaceSet (faceSet style.FaceSet) {
|
||||
this.system.SetFaceSet(faceSet)
|
||||
}
|
||||
|
||||
func (this *Backend) assert () {
|
||||
|
||||
Reference in New Issue
Block a user