Skip to content

Commit

Permalink
Improve CImGui demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jheinen committed Aug 9, 2024
1 parent 3c135da commit f4e0e48
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/imgui_ex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,20 @@ function gr_demo(; engine=nothing)
if isnothing(image_id)
image_id = CImGui.create_image_texture(img_width, img_height)
end

@c CImGui.SliderFloat("Angle", &phi, 0, 360, "%.4f")

size = CImGui.GetWindowSize()
canvas = CImGui.GetWindowPos()
mouse_x = unsafe_load(CImGui.GetIO().MousePos.x)
mouse_y = unsafe_load(CImGui.GetIO().MousePos.y)
x = (mouse_x - canvas.x) / size.x
y = 1 - (mouse_y - canvas.y) / size.y
if 0 <= x <= 1 && 0 <= y <= 1
@c CImGui.Text("($(round(x, digits=4)), $(round(y, digits=4)))")
end
CImGui.SetCursorPos(0, 0)

beginprint(conid)
draw(phi * π/180)
endprint()
Expand All @@ -88,7 +100,6 @@ function gr_demo(; engine=nothing)
end
end


# Run automatically if the script is launched from the command-line
if !isempty(Base.PROGRAM_FILE)
gr_demo()
Expand Down

0 comments on commit f4e0e48

Please sign in to comment.