Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Border Widget #10

Open
burksbuilds opened this issue Oct 7, 2023 · 2 comments
Open

Add Border Widget #10

burksbuilds opened this issue Oct 7, 2023 · 2 comments

Comments

@burksbuilds
Copy link
Contributor

A border around a widget. Some example sketches implement this with two horizontal and two vertical lines. I have also thought about adding this capability to UIEnvelope, but the reflections about combination over capabilities speak against this idea.

@burksbuilds
Copy link
Contributor Author

The big question that comes to mind when thinking about a border widget is "what do you do if the widget is allocated more space than it requested?". In some cases, you want the border to be drawn tight around some fixed-size content, so extra space should appear as 'margin' outside of the border. In other cases, you want the border to surround all of the allocated space to portion it off from other surrounding widgets, leaving extra 'padding' between the content and the border. The solutions I came up with are:

  • Add a 'UIExpansion' parameter to a border widget to describe how it should handle margin and padding
  • Blindly draw the border on the outside of the allocated space, passing the resulting internal area to the enclosed content, even though it would prefer a different size.

Blindly drawing the border is simple, but requires potentially two envelope widgets to properly manage margin and padding. Combining some envelope functionality is tempting to avoid making tons of widgets. I got it working in this commit, but it still required one envelope to work properly (basically eliminating one envelope from the two required for margin and padding).

While it works, that solution flies in the face of the 'combination over capabilities' strategy of this library. My next attempt will be a simple border widget that draws its frame around the outside of the allotted area, then passes the internal frame area to the content. However, I will separately add a 'composite widget' class to include two envelopes and a border which allows framing content similarly to the CSS Box Model

@burksbuilds
Copy link
Contributor Author

The only final question is what kind of restrictions or freedoms should the user have for determining the border thickness. The options I see are:

  • Uniform border thickness only, specified in pixels
  • Horizontal and Vertical borders that can be independently and symmetrically specified (similar to UIEnvelope padding)
  • Left/Top/Right/Bottom borders than can be independently and symmetrically specified (similar to HTML or Excel)

My first inclination is to allow 4 independent border thicknesses, because why not? However because of the way centering and aligning works it seems unlikely anyone will ever need asymmetric borders. If they do, they can just stack lines in a Rows/Columns widget. Supporting different horizontal/vertical thicknesses just to mirror the envelope functionality seems like a good compromise, but a constructor that only requires a uniform thickness to be specified is a must.

burksbuilds added a commit to burksbuilds/UiUiUi that referenced this issue Oct 7, 2023
Simple UIBorder widget that draws a border around the outside of its allocated space
burksbuilds added a commit to burksbuilds/UiUiUi that referenced this issue Oct 7, 2023
Simple UIBorder widget that draws a border around the outside of its allocated space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant