GithubHelp home page GithubHelp logo

Custom drawing functionality? about pyimgui HOT 10 OPEN

pyimgui avatar pyimgui commented on July 22, 2024
Custom drawing functionality?

from pyimgui.

Comments (10)

swistakm avatar swistakm commented on July 22, 2024

I'm not sure I understand your question. What exactly do you want to achieve? Could you elaborate or give a more specific example?

If you want to implement your own rendering then the ImDrawList objects are available indirectly in render callbacks (via draw_data argument).

from pyimgui.

iliyang avatar iliyang commented on July 22, 2024

Sorry I wasn't clear the first time. What I want is to create my own widget that will have some area that will be custom-drawn. I want to be able to draw my own charts, histograms, etc using 2D primitives like lines, curves, ellipses, rectangles -- this sort of stuff. Is that currently possible with pyimgui? It would be truly great if yes, but how?

I am a complete imgui beginner, but I remember seeing some custom-draw C++ code that was adding primitives to ImDrawList. That's why I mentioned it. Please forgive my ignorance!

from pyimgui.

iliyang avatar iliyang commented on July 22, 2024

Just to be clear, my entire application is an imgui window - everything that I display on screen are imgui controls. This is slightly different to traditional use cases where imgui supplements the user's application. What I'm doing is essentially using imgui instead of Qt or wxWidgets for a UI application because I need better performance.

I want to have my own controls that draw themselves. For example, I want to have a scrollable list where each item is a widget that plots some data (a histogram, function plot, etc) thay is not supported by imgui out of the box.

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Oh, now I understand. Thanks for clarification :)

Such thing is not possible right now but it is definitely doable. We will heave to expose some internal functions that return the current window object and also to create mapping for ImGuiWindow and extend the existing mapping for ImDrawList that will allow to manually add new drawing primitives.

I will try to take a look into this in my free time soon to see how it could be done. I'm sure I won't have time to ensure 100% feature compatibility on my own but I will try to at least set some foundation for others so new functions could be easily contributed.

from pyimgui.

iliyang avatar iliyang commented on July 22, 2024

Thanks for the reply, I very much appreciate your time! The ability to take advantage of imgui's 2D drawing subsystem would be huge on its own!

In the mean time I hope option 1 from this post would be possible. That is, render my custom stuff to texture and then put this texture in a imgui widget. This is a bit less convenient as it has overhead (if I want to have many such widgets) and I'll have to use another drawing library. But I'd be fine with it if it's possible. Does pyimgui support placing images in widgets? Do I understand correctly that I can simply render to an OpenGL texture and then pass the ID (handle) of this texture to a call to imgui.core.image(texture_id, ...)? If so, that would be great! These is also is this related discussion on the imgui issue tracker.

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Yes, for now you can render directly to texture and display it as imgui.core.image() widget.

from pyimgui.

iliyang avatar iliyang commented on July 22, 2024

Great, I will try and report, thanks!!

from pyimgui.

lubieowoce avatar lubieowoce commented on July 22, 2024

Note for anyone encountering this issue: The 1.0.0a2 pre-release has some ImDrawList functionality exposed – we can draw lines and [filled] rectangles, and adding bindings for the rest should be easy.

from pyimgui.

vstepchik avatar vstepchik commented on July 22, 2024

Note for anyone encountering this issue: The 1.0.0a2 pre-release has some ImDrawList functionality exposed – we can draw lines and [filled] rectangles, and adding bindings for the rest should be easy.

Already found the ImDrawList exposed, however, I'm missing the ImDrawList::AddText API. Are the missing parts to be added anytime soon?

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Released as 1.0.0

from pyimgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.