Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (c *Context) draw(screen *ebiten.Image) {
for cmd := range c.commands() {
switch cmd.typ {
case commandRect:
vector.DrawFilledRect(
vector.FillRect(
target,
float32(cmd.rect.rect.Min.X*scale),
float32(cmd.rect.rect.Min.Y*scale),
Expand Down Expand Up @@ -205,12 +205,19 @@ func (c *Context) drawIcon(icon icon, rect image.Rectangle, color color.Color) {
// DrawOnlyWidget adds a widget that only draws the given function without user interaction.
func (c *Context) DrawOnlyWidget(f func(screen *ebiten.Image)) {
_ = c.wrapEventHandlerAndError(func() (EventHandler, error) {
_, _ = c.widget(widgetID{}, 0, nil, nil, func(bounds image.Rectangle) {
c.setClip(c.clipRect())
defer c.setClip(unclippedRect)
cmd := c.appendCommand(commandDraw)
cmd.draw.f = f
})
// The layout item is allocated as usual, so that the layout does not depend
// on whether the drawing is visible. The item's bounds must not be used to
// cull the drawing though: f can draw outside them, and the clip rect
// already limits the output to the visible area.
if _, err := c.layoutNext(); err != nil {
return nil, err
}

c.setClip(c.clipRect())
defer c.setClip(unclippedRect)

cmd := c.appendCommand(commandDraw)
cmd.draw.f = f
return nil, nil
})
}
Expand Down
Loading