This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/elements/basic/test.go

54 lines
1.3 KiB
Go
Raw Normal View History

2023-01-09 06:03:19 +00:00
package basic
import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
2023-01-10 02:25:11 +00:00
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
2023-01-09 06:03:19 +00:00
// Test is a simple element that can be used as a placeholder.
type Test struct {
2023-01-10 02:25:11 +00:00
*core.Core
core core.CoreControl
2023-01-09 06:03:19 +00:00
}
// NewTest creates a new test element.
func NewTest () (element *Test) {
element = &Test { }
2023-01-10 02:25:11 +00:00
element.Core, element.core = core.NewCore(element)
2023-01-09 06:03:19 +00:00
element.core.SetMinimumSize(32, 32)
return
}
func (element *Test) Handle (event tomo.Event) {
switch event.(type) {
case tomo.EventResize:
resizeEvent := event.(tomo.EventResize)
element.core.AllocateCanvas (
resizeEvent.Width,
resizeEvent.Height)
for y := 0; y < resizeEvent.Height; y ++ {
for x := 0; x < resizeEvent.Width; x ++ {
pixel := color.RGBA {
R: 0x40, G: 0x80, B: 0x90, A: 0xFF,
}
element.core.SetRGBA (x, y, pixel)
}}
artist.Line (
element.core, artist.NewUniform(color.White), 1,
image.Pt(0, 0),
image.Pt(resizeEvent.Width, resizeEvent.Height))
artist.Line (
element.core, artist.NewUniform(color.White), 1,
image.Pt(0, resizeEvent.Height),
image.Pt(resizeEvent.Width, 0))
default:
}
return
}
2023-01-09 20:14:36 +00:00
func (element *Test) AdvanceSelection (direction int) (ok bool) {
2023-01-09 06:03:19 +00:00
return
}