Custom UIlayout

I want to make a unique element ui
How can I draw a simple rectangle in any panel?
https://docs.blender.org/api/2.81/gpu.html#d-rectangle
Nothing happens when I add this to the draw function of my panel.

1 Like

As far as I know, you can only draw custom OpenGL in editor areas (e.g. 3D view, node editor, image editor etc.), but not in the properties area. I’d love to be proven wrong though.

You’re right :+1:, I draw text in a node, but it is shown on canvas
eerr

1 Like

You can draw gl in any space type that has a draw handler. Which should be all of them. I have an add-on that draws GL in the preferences panel, for example.

1 Like

I’m interested :slightly_smiling_face:

Ah, nice, SpacePreferences is indeed in this list: https://docs.blender.org/api/current/search.html?q=draw_handler_add&check_keywords=yes&area=default#

@mac7ua To draw inside a node, you need to get the node’s location (node.location) and transform it to OpenGL coordinates by calling view_to_region().

Thank you, I was able to do something. :slightly_smiling_face: