Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reveal() doesn't work but draw() does for GtkCanvas draw updates #81

Closed
srikumarks opened this issue Jan 4, 2025 · 1 comment
Closed

Comments

@srikumarks
Copy link

This is either a documentation bug or a code bug I'm not sure.

The doc recommends calling reveal(canvas) to queue a draw call for the canvas' assigned draw function. I see that the code just turns around and calls G_.queue_draw(widget). reveal seems to do nothing though. However, calling draw(canvas) directly seems to do the job. I found this via methods(draw).

Sample code below -

using Gtk4
c = GtkCanvas()
win = GtkWindow("Canvas")
color = Ref(0.0)
@guarded draw(c) do widget
    ctx = getgc(c)
    h = height(c)
    w = width(c)
    # Paint red rectangle
    rectangle(ctx, 0, 0, w, h/2)
    set_source_rgb(ctx, 1, color[], 0)
    fill(ctx)
    # Paint blue rectangle
    rectangle(ctx, 0, 3h/4, w, h/4)
    set_source_rgb(ctx, 0, 0, 1)
    fill(ctx)
end
win.child = c
# Change colour from red to yellow after 5 seconds
@async begin
    sleep(5)
    println("FIRE")
    color[] = 1.0 
    draw(c) # Putting reveal(c) here does not trigger a draw.
end

showall(win)
@jwahlstrand
Copy link
Member

Yup, you're right. All reveal does is redraw the backing store. I just fixed this in the docs -- thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants