raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.36k stars 289 forks source link

Support controls rounded corners #338

Closed danielchasehooper closed 4 months ago

danielchasehooper commented 11 months ago

It'd be great if raygui supported rounded corners. I know it's not in raylib's branding to round corners, but users of raygui may want to have rounded corners in their projects. rounded corners are everywhere in UI.

If you wanted a minimal impact way to support for this, you could leave existing functions as-is and add support for GuiSetStyle(DEFAULT, CORNER_RADIUS, value)

raysan5 commented 11 months ago

I considered that possibility in the past but it implies an impact on performance and the addition of more raylib-dependant functions, and, as you mentioned is not in the raylib branding.

A while ago all rectangle drawing functions were abstracted to GuiDrawRectangle() to considering that possibility or other customization possibilities. Still, not tested and probably some controls would require more customization.

danielchasehooper commented 11 months ago

Computers have been able to handle rounded rects since the Macintosh. but if you're still worried about performance, the default can remain a corner radius of 0. and in such cases, call DrawRectangle instead of DrawRectangleRounded

raysan5 commented 11 months ago

Computers have been able to handle rounded rects since the Macintosh.

Sure, but back in the day round rectangles rasterization did not imply a x32 or x64 increment in triangles to be processed. But yeah, mostly any GPU today can handle it without problems.

danielchasehooper commented 11 months ago

yeah, no sweat.

Could also render rounded rects with a signed distance function, though I don't know how that would dovetail with things like BeginShaderMode(...); DrawRectangleRounded(...)

raysan5 commented 11 months ago

@danielchasehooper Just did a quick test using DrawRectangleRounded() in GuiDrawRectangle():

image

This is a very dirt test, roundness parameter should be calculated depending on rectangle width and height... but you can see how it works.

danielchasehooper commented 11 months ago

I do think the rounded corners do a lot for the look! We can tweak that radius :) what are your thoughts now that you did the test?

raysan5 commented 11 months ago

Hehehe... personally, I'm not a fan of rounded borders but I agree some users could like it.

In any case, it would imply an important redesign for raygui, looking at the quick test I see many controls need to be reviewed and probably redesigned to accomodate those round corners. It could increase code complexity with many side-case to consider.

No plans to implement this feature for now.

funlw65 commented 8 months ago

He can do round rectangles on buttons with gradients eventually, but use the normal rectangular collision detection... Because the round corner will be subtle enough... using his additional header with the new added controls, no need to alter the original. And because the free zone uncovered by the round corner is not used anyway for any special click zone... If I am clear enough.

BTW Daniel, just adding gradient to a rectangular button with corners, instantly looks much better...for anything else, make it look like a modern UI web (or Android) interface. You have complete control because of the simplicity of raylib+raygui.

raysan5 commented 4 months ago

As seen on the image, there are multiple issues with the rounded rectangles to address. I'm afraid this implies a raygui redesign that it's out of scope for now.