Hi, i'll start to work in a series of features i've been thinking for many time, first one is Patch9 support for sprites, i have talked with @reduz about this in the past, but i don't remember too much of the idea i had back then.
Basically, the idea is to add a new node similar Sprite with an enum. The enum is called PatchPolicy and changes the way the 9 patch is rendered, i have 5 policies in mind:
enum Patch9Policy {
PATCH9_NONE,
PATCH9_EXPAND,
PATCH9_TILE,
PATCH9_TILE_SHRINK,
PATCH9_TILE_EXPAND
};
The new properties are the PatchPolicy and the 4 margins of the texture, same way as StyleBoxImage and Patch9Frame control.
At the same time i'll remove some useless properties:
Centered (will be the default)
Vframes (unused)
Hframes (unused)
Frame (unused)
Region (unused)
Region Rect (unused)
Instead of using Regions We'll encourage people to use the already available AtlasTexture, since now it's much easier to edit thx to the Texture Region editor.
So, what do you think of it as is? do you see any of these policies useless? any other policy to add?
I'll try to make a mockup of how every policy looks like so it's more clear.
I'm not sure if removing Centered is good idea. Centered sprites are useful in free transform scenarios, but when you use grid to place your sprites not so much :B
Will it support 3D sprites?
A Patch9Sprite3D too if possible, I think that will help to quickly prototype fancy 3D UI (among other things) without dealing with Control and Viewports
Ah, yes, i supose Patch9Sprite3D would be nice too, i never use 3D so i didn't think about it.
About centered, the reason why i'm removing the property is because you can allways use offset to set the pivot wherever you want, if it becomes clear that many people want's to use the corners as anchors i can add a helper to fastly set the anchors of the pivot (pretty much like Control's Anchor button)
This is what i have so far

New update, i have all 5 policies working.
https://www.youtube.com/watch?v=xshpILh3cLs&feature=youtu.be
Up until now i was thinking into using scale to handle the sprite size (this is current implementation) but now i realized that this causes trouble when you want to have child nodes ir scale the texture size along with the sprite size, so, i'll probably add a new property: Size and handle it independently from the scale (wich means i'll have to do an editor plugin to change size from editor)
Any thoughts about this?
Yeah helper to set pivot in corners would be pretty useful in my opinion.
+1 not use scale. Scale itself could be useful for just scale sprite overall
Here comes a question, what should i do with size property when texture changes? keep it as is or match texture size?
@MarianoGnu I would prefer to keep the size, if texture is too different you may have to change/scale the borders too, not sure if the class itself should have to care about it.
This is what i have thought: set the minimum size as the addition of the margins, if the addition of the margins is greather than texture size , margins kept, but the draw phase will consider margins as 0.
Closing since Godot3.0 has an equivalent to this (NinePatchRect)
Most helpful comment
New update, i have all 5 policies working.
https://www.youtube.com/watch?v=xshpILh3cLs&feature=youtu.be
Up until now i was thinking into using scale to handle the sprite size (this is current implementation) but now i realized that this causes trouble when you want to have child nodes ir scale the texture size along with the sprite size, so, i'll probably add a new property: Size and handle it independently from the scale (wich means i'll have to do an editor plugin to change size from editor)
Any thoughts about this?