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

ImPlot example with state-management and Renderer #10

Closed
sairus7 opened this issue Mar 7, 2021 · 3 comments
Closed

ImPlot example with state-management and Renderer #10

sairus7 opened this issue Mar 7, 2021 · 3 comments

Comments

@sairus7
Copy link
Collaborator

sairus7 commented Mar 7, 2021

https://gist.github.com/sairus7/19778c05ffba7c677a3414f752a0f9cb

Just rewrote the example from demo/example_plots.jl, using Renderer to hide ImGUI boilerplate code, as explained here.

However, there are some things I don't like in this example:

  • store state variables inside a structure - it will be very bloated for complex GUI - is there some static macro in Julia, or isdefined for local variables?
  • passing state with field destructuring - maybe it's fine to write state. in front of all data variables.
@Gnimuc
Copy link
Member

Gnimuc commented Mar 7, 2021

  • store state variables inside a structure - it will be very bloated for complex GUI - is there some static macro in Julia, or isdefined for local variables?

you may find this useful. I prefer Redux.jl for something scalable, but it needs even more boilerplate code.

@sairus7
Copy link
Collaborator Author

sairus7 commented Mar 7, 2021

@Gnimuc thanks for the links!
Using @cstatic has some limitations:

  1. you cannot write complex initialization code that should be run only at startup,
  2. it is just one-liners for variables, and if there are many variables, the code becomes messy:
using CImGui.CSyntax.CStatic
function foo()
    @cstatic a, b, c = 1, zeros(3), [x^2 for x in 1:5] begin
        a += 100
        b .+= 10
        c .+= 1
        println("$a,$b,$c")
    end
end
function loop()
    for i=1:10
        foo()
    end
end

loop()

I don't quite understand strong parts of Redux from the link above.

Can you point me to some complex ImGui projects and how do they actually handle state-sharing between a whole lot of GUI components in the scene, if they interact with each other?

@wsphillips
Copy link
Collaborator

Closing this. These are CStatic / ImGui questions.

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

3 participants