Suggestions based on current status.
kattni opened this issue · 2 comments
@FoamyGuy @kmatch98 Thank you so much for writing this! It made my project much simpler. Here are a few thoughts!
For context, I am currently working with this file.
The project I am using it in can be found here.
In terms of add_sub_view
:
- The naming of the function
add_sub_view
doesn't make it clear to me what it's doing - the example did that. I do not know, however, from where the name was derived, so it could be adisplayio
thing, in which case proceed as is. Really, I am unclear on what the concept of aview
is - this may be a concept I'm simply unfamiliar with in which case education will resolve the issue. Otherwise, consider a naming change to make things more clear. - Along those lines,
view
could be clearer. That or we supplement with excellent documentation. :) view_grid_size
should default to(1, 1)
as that seems like a sane default. It would significantly shorten up a basic constructor.
In the GridLayout
constructor:
child_padding
could be more clearly named, I had to mess with it to figure out what it did, and I'm still not sure I really know.max_children
could default to the grid sizex
*y
.- Looking at it, I'm wondering what
child_padding
does versus what settingx
andy
do?
Feature requests:
- I would appreciate a way to nudge or "pad" columns or rows. I did it initially by adding spaces into all of the text elements, then went back and created a grid that included empty columns as padding. Basically I have a column on each side of the display that is only a few characters wide, and the ones in the middle are much wider. So I "padded" it with empty columns. The results were successful, but I'm wondering if there's some way to control subsections of the grid without making everything a lot more complicated. (That last bit is important!)
These are the things that occurred to me while using the version linked above in a project. I'm sure I'll come up with more as we work through it!
On the "view" naming and concept: One thing that led to the use of "sub_view" was an attempt to avoid using parent/child relationship terms. But it turned out inconsistent, because it's still used in some places. It may be worthwhile to use them in the "add" function name to make it more clear and consistent.
The specific use of the term "view" came from my background with Android. There is an object View
which represents a similar concept to how I've used it here.
I do think we have a need for some higher level object that the rest of our widgets should extend. We could use "view" or a different term ( "Widget" perhaps?) It will have the common properties like x
, y
, width
, height
, and any others that make sense. Personally I think it should have a contains()
method like the one current on display_button
that way all widgets can easily be made clickable if the user wants. The other one that I think should be on this object are the anchor_point
and anchored_position
concepts that currently exist on the labels in the display_text library.
If we make a higher level object like that and use it for all widgets moving forward it will make a nice unified API between all of the widgets that allows the user to place them how they want. One thing this unified API will allow us to do build up layout classes like grid layout that will make use of that core set of positioning APIs to do the heavy lifting of arranging views into interesting or useful ways.
With regards to child_padding: I need to test it out a bit to be sure but I think the idea is it would add extra space inside the grid cell, but outside the child ( so it would make the cell a little bigger than it needs to be to contain the child). Theoretically this might be one way to help ease the complexities of adding extra things.
But I have in mind another solution to the core problem. I am working on a new kind of label that works a bit differently from the existing ones. The new one is going to allow setting it to an arbitrary size and then it will try to fit the text within that. When this component exists how I am thinking I think it should allow you to have much easier control over spacing within the grid without having to add extra children for spaces.
Agreed about view_grid_size
defaulting to 1,1. And max_children
defaulting to the grid size multiplied out.
Just a follow up question regarding use of anchor points inside of grid layout.
The use of anchored_position
in the display_text library is defined as the pixel position on the screen. However in the case of grid_layout, I think it will need to work different. It seems like we need to have two anchor_points, one for the widget (for example button) and one for the cell. For example if you want a widget centered then set anchor_point_widget = anchor_point_cell = (0.5,0.5).
But this seems a little awkward. Also, could there be situations where you want to place widgets specifically based on pixel dimensions rather than on relative dimensions (of the widget and cell sizes)?
Just wanted to elicit y’all’s thoughts on handling widget placement issues.