Fixed rotating layouts; Added Shader layout

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:54 +01:00
1 parent 86aad51e37
commit 0196bb3707
13 files changed
+207 -93

No files matched your search

+25 -5
View File
@@ -3,6 +3,7 @@ package widget
import (
"image"
"image/color"
"image/draw"
"github.com/makeworld-the-better-one/dither/v2"
"github.com/nfnt/resize"
@@ -56,11 +57,6 @@ func (w *Image) Update(image image.Image, model color.Model) app.Widget {
func (w *Image) Refresh(ctx app.Context) bool {
log := logrus.WithField("widget", w.String())
if !w.IsVisible() {
log.Trace("not refreshing; not visisble")
return false
}
if !w.changed.CompareAndSwap(true, false) {
log.Trace("not refreshing; not changed")
return false
@@ -116,4 +112,28 @@ func convertImageFor(model color.Model, image image.Image) image.Image {
return d.Dither(image)
}
type Canvas struct {
Base
}
func NewCanvas(size image.Point, model color.Model) *Canvas {
w := new(Canvas)
w.buffer = app.BufferFor(model, size)
w.Extend(w)
return w
}
func (w *Canvas) Buffer() draw.Image {
return w.buffer
}
func (w *Canvas) String() string {
return "canvas:" + w.buffer.Bounds().Size().String()
}
func (w *Canvas) Refresh(ctx app.Context) bool {
app.ImageCopy(ctx.Display(), w.buffer)
return true
}
var _ app.Widget = (*Image)(nil)