Fixed tooltip flickering when not blocking on events.

This commit is contained in:
Sander Schobers 2020-05-17 21:02:07 +02:00
parent 0f54224cc7
commit 32c53eb947
4 changed files with 14 additions and 7 deletions

View File

@ -66,12 +66,12 @@ type Renderer struct {
// Renderer implementation (events)
func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) bool {
r.disp.Flip()
var ev = eventWait(r.eq, wait)
if ev == nil {
return
return false
}
cursor := r.cursor
@ -141,6 +141,7 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
r.disp.SetMouseCursor(allg5.MouseCursorEdit)
}
}
return true
}
func (r *Renderer) RegisterRecorder(rec *allg5.Recorder) {

View File

@ -100,7 +100,7 @@ func (r *Renderer) WindowBounds() geom.RectangleF32 {
return geom.RectF32(float32(x), float32(y), float32(x+w), float32(y+h))
}
func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) bool {
r.renderer.Present()
waitOrPoll := func() sdl.Event {
@ -111,7 +111,9 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
}
cursor := r.cursor
var pushed bool
for event := waitOrPoll(); event != nil; event = sdl.PollEvent() {
pushed = true
r.cursor = ui.MouseCursorDefault
var unhandled bool
@ -191,6 +193,7 @@ func (r *Renderer) PushEvents(t ui.EventTarget, wait bool) {
sdl.SetCursor(r.SystemCursor(sdl.SYSTEM_CURSOR_IBEAM))
}
}
return pushed
}
func (r *Renderer) Refresh() {

View File

@ -9,7 +9,7 @@ import (
type Renderer interface {
// Events
PushEvents(t EventTarget, wait bool)
PushEvents(t EventTarget, wait bool) bool
Refresh()
// Lifetime

View File

@ -55,10 +55,13 @@ func RunWait(r Renderer, s *Style, view Control, wait bool) error {
tooltip := ctx.tooltip.Text
ctx.tooltip.Text = ""
r.PushEvents(ctx, wait)
if r.PushEvents(ctx, wait) {
if ctx.tooltip.Text != tooltip {
ctx.overlays.SetVisibility(uiDefaultTooltipOverlay, ctx.tooltip.Text != "")
}
} else {
ctx.tooltip.Text = tooltip
}
}
return nil
}