Support rounded corners for frames

Assigned to
1 year, 7 months ago
2 months ago
feature v0.3.0

~ireas referenced this from #34 1 year, 7 months ago

~ap4sc 1 year, 7 months ago

I extended my rounded corners implementation to add the ability enable/disable individual sides of the border, set in the new struct BorderStyle. The draw function isn't pretty but after several attempts this "manual" mapping method is the most efficient I could think of. On the plus side it simplifies the element code by automatically figuring out which corners need to be connected and rounded.


One way to make it more modular in the future could be to move the rounded corners, LineStyle, [and fill color] into a separate RoundedRectangle shape struct for reuse in the shapes drawing feature

~ireas 1 year, 7 months ago

My idea for the API is:

  • Create a new RoundedCorners struct similar to Margins that can be constructed from a single value for all four corners, or from four different corners.
  • Change FramedElement so that new is the only constructor and that there are these setters:
    • set_line_style / with_line_style
    • set_rounded_corners / with_rounded_corners
    • set_fill_color / with_fill_color (eventually)

I see that you made it possible to select which borders to draw. This could be fitted in this model by creating a Borders struct with four boolean values (again similar to Margins) and set_borders / with_borders setters in FramedElement.

If it makes sense for the implementation (for example to reduce the number of arguments in the draw methods), you can combine these settings in a BorderStyle or FrameStyle struct. But this should be an implementation detail of the FramedElement and not directly exposed to the user.

Does that make sense to you? If yes, please submit the patches.

~bharath412 2 months ago

is set_fill_color / with_fill_color for FrameCellDecorator implemented? If yes, can you please share a sample

Register here or Log in to comment, or comment via email.