Skip to content

Commit

Permalink
fix widget, add to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Dec 1, 2023
1 parent e367796 commit 37ab012
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/widget.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function realizewidgetcb(glareaptr, user_data)
GLMakie.apply_config!(screen, config)

a.render_id = Gtk4.signal_connect(refreshwidgetcb, a, "render", Cint, (Ptr{Gtk4.Gtk4.GdkGLContext},))
nothing
end

function unrealizewidgetcb(glareaptr, glarea)
Expand All @@ -97,7 +98,8 @@ end

function Makie.window_area(scene::Scene, screen::GLMakie.Screen{T}) where T <: GtkGLMakie
glarea=screen.glscreen
_window_area(scene, glarea)
winscale = screen.scalefactor[] / Gtk4.scale_factor(glarea)
_window_area(scene, glarea, winscale)
end

glarea(screen::GLMakie.Screen{T}) where T <: GtkGLArea = screen.glscreen
Expand All @@ -114,6 +116,15 @@ function Base.isopen(win::GtkGLMakie)
return true
end

function GLMakie.set_screen_visibility!(nw::GtkGLMakie, b::Bool)
if b
Gtk4.show(nw)
else
Gtk4.hide(nw)
end
end


function GLMakie.apply_config!(screen::GLMakie.Screen{T},config::GLMakie.ScreenConfig; start_renderloop=true) where T <: GtkGLArea
return _apply_config!(screen, config, start_renderloop)
end
Expand Down
13 changes: 12 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,16 @@ using Gtk4Makie, GLMakie, Gtk4
end

@testset "widget screen" begin

win = GtkWindow("2 Makie widgets in one window", 600, 600, true, false)
p=GtkPaned(:v;position=200)
p[1]=GtkMakieWidget()
p[2]=GtkMakieWidget()
win[]=p

show(win)

push!(p[1],lines(rand(10)))
push!(p[2],scatter(rand(10)))

destroy(win)
end

0 comments on commit 37ab012

Please sign in to comment.