#How do I draw a nine patch in C#?

1 messages · Page 1 of 1 (latest)

glad hinge
#

How do I draw a nine patch in C#?
I don't see a Draw NinePatch method

swift osprey
#

This doesn't really depend on language. You can either use the NinePatchRect node, or use a StyleBoxTexture on any Control node that supports it

glad hinge
swift osprey
#

What do you mean "draw" it? Why can't you use one of those two options?

#

If you're just talking about using draw functions, then you can do that but there's no built-in method for it. You'd just have to use draw_texture_rect_region and make the logic yourself using multiple calls to that function

glad hinge
#

can you provide a example? I have never drawn nine patches before

swift osprey
#

If you're not sure how, I highly recommend one of the other two options

#

A NinePatchRect node is the easiest way to do this

glad hinge
#

I am building my own widget node that suits my needs NinePatchRect is not a option

swift osprey
#

Then you'll have to figure it out yourself

#

It's a lot of code, I don't really want to write it for you

#

How about you give it a try and then return if you can't get it to work?

#

Also, seriously consider whether you can actually use NinePatchRect or StyleBoxTexture. It will be much easier

#

Maybe if you can explain what you're trying to accomplish?

glad hinge
#

the scene tree makes the whole process alot more complex not to mention I can't convert a scene into a custom type

swift osprey
#

Well if you're not willing to use one of the easy options, and you're not willing to try to write it yourself, and you're not willing to describe what you're trying to do, then I'm not sure there's anything else I can help you with, sorry

glad hinge
#

how is another node easier then just drawing it?

swift osprey
#

Because it does it for you?

glad hinge
#

yes but it requires me to delete it and to make sure it's in the scene and it also requires me to hide it so it doesn't get removed with get_child

swift osprey
#

None of that has anything to do with a 9-patch

glad hinge
#

also it doesn't scale well with scenes and scripts

#

it does

swift osprey
#

You would still need a node to draw it with, so these issues will exist either way

glad hinge
#

yes I have one but it doesn't need to manage a child

#

it's part of the script instead of the scene

#

which scales a hell of alot better

swift osprey
#

Keep in mind I have no context about what you're trying to do

glad hinge
#

I am making a widget node that handles focus themes, sounds and everything I would expect the control node would do but doesn't

#

it also handles pressing and toggling so it's kinda like a button

swift osprey
#

Just let it use a StyleBox

glad hinge
#

stylebox is too limited

#

themes are way too limited

#

also they don't support sound

#

also I have some fixes

#

like disabled nodes being focused

#

I made it so they can't be