2018-08-01 00:18:13 +00:00
|
|
|
package doodle
|
|
|
|
|
|
|
|
import (
|
2018-08-02 01:52:52 +00:00
|
|
|
"fmt"
|
|
|
|
|
2019-04-10 00:35:44 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
2019-06-24 00:52:48 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/branding"
|
2019-04-10 00:35:44 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/log"
|
2019-12-28 03:16:34 +00:00
|
|
|
"git.kirsle.net/go/render"
|
|
|
|
"git.kirsle.net/go/render/event"
|
|
|
|
"git.kirsle.net/go/ui"
|
2018-08-01 00:18:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GUITestScene implements the main menu of Doodle.
|
|
|
|
type GUITestScene struct {
|
|
|
|
Supervisor *ui.Supervisor
|
2018-08-02 01:52:52 +00:00
|
|
|
|
|
|
|
// Private widgets.
|
|
|
|
Frame *ui.Frame
|
|
|
|
Window *ui.Frame
|
2019-04-19 22:08:00 +00:00
|
|
|
body *ui.Frame
|
2018-08-01 00:18:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Name of the scene.
|
|
|
|
func (s *GUITestScene) Name() string {
|
2019-04-19 22:08:00 +00:00
|
|
|
return "GUITest"
|
2018-08-01 00:18:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the scene.
|
|
|
|
func (s *GUITestScene) Setup(d *Doodle) error {
|
|
|
|
s.Supervisor = ui.NewSupervisor()
|
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
window := ui.NewFrame("window")
|
|
|
|
s.Window = window
|
2018-08-01 00:18:13 +00:00
|
|
|
window.Configure(ui.Config{
|
2018-08-02 01:52:52 +00:00
|
|
|
Width: 750,
|
|
|
|
Height: 450,
|
2018-08-01 00:18:13 +00:00
|
|
|
Background: render.Grey,
|
|
|
|
BorderStyle: ui.BorderRaised,
|
|
|
|
BorderSize: 2,
|
|
|
|
})
|
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
// Title Bar
|
2018-08-05 19:54:57 +00:00
|
|
|
titleBar := ui.NewLabel(ui.Label{
|
|
|
|
Text: "Widget Toolkit",
|
|
|
|
Font: render.Text{
|
|
|
|
Size: 12,
|
|
|
|
Color: render.White,
|
|
|
|
Stroke: render.DarkBlue,
|
|
|
|
},
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
|
|
|
titleBar.Configure(ui.Config{
|
2018-08-02 01:52:52 +00:00
|
|
|
Background: render.Blue,
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
|
|
|
window.Pack(titleBar, ui.Pack{
|
2019-12-29 05:48:49 +00:00
|
|
|
Side: ui.N,
|
2019-12-31 02:13:28 +00:00
|
|
|
Fill: true,
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
// Window Body
|
|
|
|
body := ui.NewFrame("Window Body")
|
|
|
|
body.Configure(ui.Config{
|
|
|
|
Background: render.Yellow,
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
2018-08-02 01:52:52 +00:00
|
|
|
window.Pack(body, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.N,
|
2018-08-02 01:52:52 +00:00
|
|
|
Expand: true,
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
2019-04-19 22:08:00 +00:00
|
|
|
s.body = body
|
2018-08-01 00:18:13 +00:00
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
// Left Frame
|
|
|
|
leftFrame := ui.NewFrame("Left Frame")
|
|
|
|
leftFrame.Configure(ui.Config{
|
|
|
|
Background: render.Grey,
|
|
|
|
BorderStyle: ui.BorderSolid,
|
|
|
|
BorderSize: 4,
|
|
|
|
Width: 100,
|
|
|
|
})
|
|
|
|
body.Pack(leftFrame, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.W,
|
|
|
|
FillY: true,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Some left frame buttons.
|
|
|
|
for _, label := range []string{"New", "Edit", "Play", "Help"} {
|
2018-08-05 19:54:57 +00:00
|
|
|
btn := ui.NewButton("dummy "+label, ui.NewLabel(ui.Label{
|
|
|
|
Text: label,
|
|
|
|
Font: balance.StatusFont,
|
2018-08-02 01:52:52 +00:00
|
|
|
}))
|
2020-03-10 05:22:22 +00:00
|
|
|
btn.Handle(ui.Click, func(ed ui.EventData) {
|
2018-08-05 19:54:57 +00:00
|
|
|
d.Flash("%s clicked", btn)
|
|
|
|
})
|
2018-08-02 01:52:52 +00:00
|
|
|
s.Supervisor.Add(btn)
|
|
|
|
leftFrame.Pack(btn, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
|
|
|
PadY: 2,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Main Frame
|
|
|
|
frame := ui.NewFrame("Main Frame")
|
|
|
|
frame.Configure(ui.Config{
|
|
|
|
Background: render.White,
|
|
|
|
BorderSize: 0,
|
|
|
|
})
|
|
|
|
body.Pack(frame, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.W,
|
2018-08-02 01:52:52 +00:00
|
|
|
Expand: true,
|
2018-08-05 19:54:57 +00:00
|
|
|
Fill: true,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Right Frame
|
|
|
|
rightFrame := ui.NewFrame("Right Frame")
|
|
|
|
rightFrame.Configure(ui.Config{
|
|
|
|
Background: render.SkyBlue,
|
|
|
|
BorderStyle: ui.BorderSunken,
|
|
|
|
BorderSize: 2,
|
|
|
|
Width: 80,
|
|
|
|
})
|
|
|
|
body.Pack(rightFrame, ui.Pack{
|
2019-12-29 05:48:49 +00:00
|
|
|
Side: ui.W,
|
2019-12-31 02:13:28 +00:00
|
|
|
Fill: true,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// A grid of buttons.
|
|
|
|
for row := 0; row < 3; row++ {
|
|
|
|
rowFrame := ui.NewFrame(fmt.Sprintf("Row%d", row))
|
2018-08-05 19:54:57 +00:00
|
|
|
rowFrame.Configure(ui.Config{
|
|
|
|
Background: render.RGBA(0, uint8((row*20)+120), 0, 255),
|
|
|
|
})
|
2018-08-02 01:52:52 +00:00
|
|
|
for col := 0; col < 3; col++ {
|
2018-08-05 19:54:57 +00:00
|
|
|
(func(row, col int, frame *ui.Frame) {
|
|
|
|
btn := ui.NewButton(fmt.Sprintf("Grid Button %d:%d", col, row),
|
|
|
|
ui.NewFrame(fmt.Sprintf("Col%d", col)),
|
|
|
|
)
|
|
|
|
btn.Configure(ui.Config{
|
|
|
|
Height: 20,
|
|
|
|
BorderStyle: ui.BorderRaised,
|
|
|
|
})
|
2020-03-10 05:22:22 +00:00
|
|
|
btn.Handle(ui.Click, func(ed ui.EventData) {
|
2018-08-05 19:54:57 +00:00
|
|
|
d.Flash("%s clicked", btn)
|
|
|
|
})
|
|
|
|
rowFrame.Pack(btn, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.W,
|
2018-08-05 19:54:57 +00:00
|
|
|
Expand: true,
|
|
|
|
FillX: true,
|
|
|
|
})
|
|
|
|
s.Supervisor.Add(btn)
|
|
|
|
})(row, col, rowFrame)
|
2018-08-02 01:52:52 +00:00
|
|
|
}
|
|
|
|
rightFrame.Pack(rowFrame, ui.Pack{
|
2019-12-29 05:48:49 +00:00
|
|
|
Side: ui.N,
|
2019-12-31 02:13:28 +00:00
|
|
|
Fill: true,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
WIP Texture Caching
NOTICE: Chunk size set to 100 for visual testing!
NOTICE: guitest references a bmp file that isn't checked in!
BUGS REMAINING:
- When scrolling the level in Edit Mode, some of the chunks will pop
out of existence randomly.
- When clicking-dragging to draw in Edit Mode, if the scroll position
is not at 0,0 then the pixels drawn will be offset from the cursor.
- These are to do with the Scroll position and chunk coordinate calc
functions probably.
Implements a texture caching interface to stop redrawing everything
pixel by pixel on every frame.
The texture caching workflow is briefly:
- The uix.Canvas widget's Present() function iterates over the list of
Chunk Coordinates that are visible inside of the current viewport
(i.e. viewable on screen)
- For each Chunk:
- Make it render and/or return its cached Texture object.
- Work out how much of the Chunk will be visible and how to crop the
boxes for the Copy()
- Copy the cached Texture instead of drawing all the pixels every
time like we were doing before.
- The Chunk.Texture() function that returns said Texture:
- It calls Chunk.ToBitmap() to save a bitmap on disk.
- It calls Engine.NewBitmap() to get a Texture it can hang onto.
- It hangs onto the Texture and returns it on future calls.
- Any call to Set() or Delete() a pixel will invalidate the cache
(mark the Chunk "dirty") and Texture() will rebuild next call.
The interface `render.Texturer` provides a way for rendering backends
(SDL2, OpenGL) to transport a "texture" of their own kind without
exposing the type details to the user.
The interface `render.Engine` adds two new methods:
* NewBitmap(filename string) (Texturer, error)
* Copy(t Texturer, src, dst Rect)
NewBitmap should open a bitmap image on disk and return it wrapped in a
Texturer (really it's an SDL2 Texture). This is for caching purposes.
Next the Copy() function blits the texture onto the screen renderer
using the source and destination rectangles.
The uix.Canvas widget orchestrates the caching for the drawing it's
responsible for. It queries which chunks are viewable in the Canvas
viewport (scroll and bounding boxes), has each chunk render out their
entire bitmap image to then cache them as SDL textures and then only
_those_ need to be copied out to the renderer each frame.
The frame rate now sits at a decent 60 FPS even when the drawing gets
messy and full of lines. Each unique version of each chunk needs to
render only one time and then it's a fast copy operation for future
ticks.
Other changes:
- Chunker now assigns each Chunk what their coordinate and size are, so
that the chunk can self reference that information. This info is
considered read-only but that isn't really enforced.
- Add Chunker.IterViewportChunks() that returns a channel of Chunk
Coordinates that are visible in your viewport, rather than iterating
over all of the pixels in all of those chunks.
- Add Chunk.ToBitmap(filename) that causes a Chunk to render its pixels
to a bitmap image on disk. SDL2 can natively speak Bitmaps for texture
caching. Currently these go to files in /tmp but will soon go into your
$XDG_CACHE_FOLDER instead.
- Add Chunk.Texture() that causes a Chunk to render and then return a
cached bitmap texture of the pixels it's responsible for. The texture
is cached until the Chunk is next modified with Set() or Delete().
- UI: add an Image widget that currently just shows a bitmap image. It
was the first test for caching bitmap images for efficiency. Can show
any *.bmp file on disk!
- Editor UI: make the StatusBar boxes dynamically build from an array
of string pointers to make it SUPER EASY to add/remove labels.
2018-10-18 03:52:14 +00:00
|
|
|
// Main frame widgets.
|
2018-08-05 19:54:57 +00:00
|
|
|
frame.Pack(ui.NewLabel(ui.Label{
|
|
|
|
Text: "Hello World!",
|
|
|
|
Font: render.Text{
|
|
|
|
Size: 14,
|
|
|
|
Color: render.Black,
|
|
|
|
},
|
2018-08-02 01:52:52 +00:00
|
|
|
}), ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.NW,
|
2018-08-01 00:18:13 +00:00
|
|
|
Padding: 2,
|
|
|
|
})
|
2018-08-02 02:52:09 +00:00
|
|
|
|
|
|
|
cb := ui.NewCheckbox("Overlay",
|
|
|
|
&DebugOverlay,
|
2018-08-05 19:54:57 +00:00
|
|
|
ui.NewLabel(ui.Label{
|
|
|
|
Text: "Toggle Debug Overlay",
|
|
|
|
Font: balance.StatusFont,
|
2018-08-02 02:52:09 +00:00
|
|
|
}),
|
|
|
|
)
|
|
|
|
frame.Pack(cb, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.NW,
|
2018-08-02 02:52:09 +00:00
|
|
|
Padding: 4,
|
|
|
|
})
|
|
|
|
cb.Supervise(s.Supervisor)
|
WIP Texture Caching
NOTICE: Chunk size set to 100 for visual testing!
NOTICE: guitest references a bmp file that isn't checked in!
BUGS REMAINING:
- When scrolling the level in Edit Mode, some of the chunks will pop
out of existence randomly.
- When clicking-dragging to draw in Edit Mode, if the scroll position
is not at 0,0 then the pixels drawn will be offset from the cursor.
- These are to do with the Scroll position and chunk coordinate calc
functions probably.
Implements a texture caching interface to stop redrawing everything
pixel by pixel on every frame.
The texture caching workflow is briefly:
- The uix.Canvas widget's Present() function iterates over the list of
Chunk Coordinates that are visible inside of the current viewport
(i.e. viewable on screen)
- For each Chunk:
- Make it render and/or return its cached Texture object.
- Work out how much of the Chunk will be visible and how to crop the
boxes for the Copy()
- Copy the cached Texture instead of drawing all the pixels every
time like we were doing before.
- The Chunk.Texture() function that returns said Texture:
- It calls Chunk.ToBitmap() to save a bitmap on disk.
- It calls Engine.NewBitmap() to get a Texture it can hang onto.
- It hangs onto the Texture and returns it on future calls.
- Any call to Set() or Delete() a pixel will invalidate the cache
(mark the Chunk "dirty") and Texture() will rebuild next call.
The interface `render.Texturer` provides a way for rendering backends
(SDL2, OpenGL) to transport a "texture" of their own kind without
exposing the type details to the user.
The interface `render.Engine` adds two new methods:
* NewBitmap(filename string) (Texturer, error)
* Copy(t Texturer, src, dst Rect)
NewBitmap should open a bitmap image on disk and return it wrapped in a
Texturer (really it's an SDL2 Texture). This is for caching purposes.
Next the Copy() function blits the texture onto the screen renderer
using the source and destination rectangles.
The uix.Canvas widget orchestrates the caching for the drawing it's
responsible for. It queries which chunks are viewable in the Canvas
viewport (scroll and bounding boxes), has each chunk render out their
entire bitmap image to then cache them as SDL textures and then only
_those_ need to be copied out to the renderer each frame.
The frame rate now sits at a decent 60 FPS even when the drawing gets
messy and full of lines. Each unique version of each chunk needs to
render only one time and then it's a fast copy operation for future
ticks.
Other changes:
- Chunker now assigns each Chunk what their coordinate and size are, so
that the chunk can self reference that information. This info is
considered read-only but that isn't really enforced.
- Add Chunker.IterViewportChunks() that returns a channel of Chunk
Coordinates that are visible in your viewport, rather than iterating
over all of the pixels in all of those chunks.
- Add Chunk.ToBitmap(filename) that causes a Chunk to render its pixels
to a bitmap image on disk. SDL2 can natively speak Bitmaps for texture
caching. Currently these go to files in /tmp but will soon go into your
$XDG_CACHE_FOLDER instead.
- Add Chunk.Texture() that causes a Chunk to render and then return a
cached bitmap texture of the pixels it's responsible for. The texture
is cached until the Chunk is next modified with Set() or Delete().
- UI: add an Image widget that currently just shows a bitmap image. It
was the first test for caching bitmap images for efficiency. Can show
any *.bmp file on disk!
- Editor UI: make the StatusBar boxes dynamically build from an array
of string pointers to make it SUPER EASY to add/remove labels.
2018-10-18 03:52:14 +00:00
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
frame.Pack(ui.NewLabel(ui.Label{
|
|
|
|
Text: "Like Tk!",
|
|
|
|
Font: render.Text{
|
|
|
|
Size: 16,
|
|
|
|
Color: render.Red,
|
|
|
|
},
|
2018-08-02 01:52:52 +00:00
|
|
|
}), ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.SE,
|
2018-08-02 01:52:52 +00:00
|
|
|
Padding: 8,
|
|
|
|
})
|
2018-08-05 19:54:57 +00:00
|
|
|
frame.Pack(ui.NewLabel(ui.Label{
|
|
|
|
Text: "Frame widget for pack layouts",
|
|
|
|
Font: render.Text{
|
|
|
|
Size: 14,
|
|
|
|
Color: render.Blue,
|
|
|
|
},
|
2018-08-02 01:52:52 +00:00
|
|
|
}), ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: ui.SE,
|
2018-08-02 01:52:52 +00:00
|
|
|
Padding: 8,
|
|
|
|
})
|
2018-08-01 00:18:13 +00:00
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
// Buttom Frame
|
|
|
|
btnFrame := ui.NewFrame("btnFrame")
|
|
|
|
btnFrame.Configure(ui.Config{
|
|
|
|
Background: render.Grey,
|
|
|
|
})
|
|
|
|
window.Pack(btnFrame, ui.Pack{
|
2019-12-29 05:48:49 +00:00
|
|
|
Side: ui.N,
|
2018-08-02 01:52:52 +00:00
|
|
|
})
|
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
button1 := ui.NewButton("Button1", ui.NewLabel(ui.Label{
|
|
|
|
Text: "New Map",
|
|
|
|
Font: balance.StatusFont,
|
2018-08-01 00:18:13 +00:00
|
|
|
}))
|
|
|
|
button1.SetBackground(render.Blue)
|
2020-03-10 05:22:22 +00:00
|
|
|
button1.Handle(ui.Click, func(ed ui.EventData) {
|
2018-08-01 00:18:13 +00:00
|
|
|
d.NewMap()
|
|
|
|
})
|
|
|
|
|
|
|
|
log.Info("Button1 bg: %s", button1.Background())
|
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
button2 := ui.NewButton("Button2", ui.NewLabel(ui.Label{
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
Text: "Load Map",
|
2018-08-05 19:54:57 +00:00
|
|
|
Font: balance.StatusFont,
|
2018-08-01 00:18:13 +00:00
|
|
|
}))
|
2020-03-10 05:22:22 +00:00
|
|
|
button2.Handle(ui.Click, func(ed ui.EventData) {
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
d.Prompt("Map name>", func(name string) {
|
2018-09-26 17:04:46 +00:00
|
|
|
d.EditDrawing(name)
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
})
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
2018-08-01 00:18:13 +00:00
|
|
|
|
|
|
|
var align = ui.W
|
|
|
|
btnFrame.Pack(button1, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: align,
|
2018-08-01 00:18:13 +00:00
|
|
|
Padding: 20,
|
|
|
|
})
|
|
|
|
btnFrame.Pack(button2, ui.Pack{
|
2019-12-31 02:13:28 +00:00
|
|
|
Side: align,
|
2018-08-01 00:18:13 +00:00
|
|
|
Padding: 20,
|
|
|
|
})
|
|
|
|
|
|
|
|
s.Supervisor.Add(button1)
|
|
|
|
s.Supervisor.Add(button2)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop the editor scene.
|
2019-12-22 22:11:01 +00:00
|
|
|
func (s *GUITestScene) Loop(d *Doodle, ev *event.State) error {
|
2018-08-01 00:18:13 +00:00
|
|
|
s.Supervisor.Loop(ev)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the pixels on this frame.
|
|
|
|
func (s *GUITestScene) Draw(d *Doodle) error {
|
|
|
|
// Clear the canvas and fill it with white.
|
|
|
|
d.Engine.Clear(render.White)
|
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
label := ui.NewLabel(ui.Label{
|
2019-06-24 00:52:48 +00:00
|
|
|
Text: fmt.Sprintf("GUITest %s v%s", branding.AppName, branding.Version),
|
2018-08-05 19:54:57 +00:00
|
|
|
Font: render.Text{
|
|
|
|
Size: 26,
|
|
|
|
Color: render.Pink,
|
|
|
|
Stroke: render.SkyBlue,
|
|
|
|
Shadow: render.Black,
|
|
|
|
},
|
2018-08-01 00:18:13 +00:00
|
|
|
})
|
|
|
|
label.Compute(d.Engine)
|
|
|
|
label.MoveTo(render.Point{
|
2019-12-28 03:16:34 +00:00
|
|
|
X: (d.width / 2) - (label.Size().W / 2),
|
2018-08-01 00:18:13 +00:00
|
|
|
Y: 40,
|
|
|
|
})
|
2018-08-05 19:54:57 +00:00
|
|
|
label.Present(d.Engine, label.Point())
|
2018-08-01 00:18:13 +00:00
|
|
|
|
2018-08-02 01:52:52 +00:00
|
|
|
s.Window.Compute(d.Engine)
|
|
|
|
s.Window.MoveTo(render.Point{
|
2019-12-28 03:16:34 +00:00
|
|
|
X: (d.width / 2) - (s.Window.Size().W / 2),
|
2018-08-01 00:18:13 +00:00
|
|
|
Y: 100,
|
|
|
|
})
|
2018-08-05 19:54:57 +00:00
|
|
|
s.Window.Present(d.Engine, s.Window.Point())
|
2018-08-02 01:52:52 +00:00
|
|
|
|
2018-08-01 00:18:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy the scene.
|
|
|
|
func (s *GUITestScene) Destroy() error {
|
|
|
|
return nil
|
|
|
|
}
|