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

Method to disable/grey-out widgets? #7

Closed
IanButterworth opened this issue May 16, 2019 · 3 comments
Closed

Method to disable/grey-out widgets? #7

IanButterworth opened this issue May 16, 2019 · 3 comments

Comments

@IanButterworth
Copy link
Collaborator

It seems that disabling/greying-out widgets to prevent user interaction in imgui itself isn't well implemented (see ocornut/imgui#211), but I was wondering whether that functionality is somehow added/addable through CImGui.jl?

Also, thanks for all the work on this package! It's been a delight to work with

@Gnimuc
Copy link
Owner

Gnimuc commented May 17, 2019

I was wondering whether that functionality is somehow added/addable through CImGui.jl?

It looks like this feature is already in ocornut's TODO list, it would be great if it could come into 1.70. Since CImGui.jl is just a wrapper and not able to provide additional internal features like this one, the only feasible way is to manually patch imgui and expose that API like what CImGuiBuilder did here.

@Gnimuc
Copy link
Owner

Gnimuc commented Aug 23, 2020

Now those internal APIs are supported in CImGui.LibCImGui, so we can implement this on the Julia side:

julia> using CImGui, CImGui.LibCImGui

julia> include(joinpath(pathof(CImGui), "..", "..", "examples", "Renderer.jl"))
Main.Renderer

julia> using .Renderer

julia> Renderer.render(width = 360, height = 480, title = "IMGUI Window") do
           CImGui.CSyntax.@cstatic disabled=false begin
               CImGui.Begin("Hello ImGui")
               CImGui.CSyntax.@c CImGui.Checkbox("Disable", &disabled)
               if disabled
                   igPushItemFlag(ImGuiItemFlags_Disabled, true)
                   CImGui.PushStyleVar(ImGuiStyleVar_Alpha, 0.5)
               end
               CImGui.Button("My Button") && @show "trigger"
               if disabled
                   igPopItemFlag()
                   CImGui.PopStyleVar()
               end
               CImGui.End()
           end
       end

@IanButterworth
Copy link
Collaborator Author

Great! Thanks for the example

I'll close this but if I come across any issues will reopen

JamesWrigley added a commit that referenced this issue Jun 9, 2024
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