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

Geometry management questions #24

Open
peterjschroeder opened this issue Dec 29, 2017 · 4 comments
Open

Geometry management questions #24

peterjschroeder opened this issue Dec 29, 2017 · 4 comments

Comments

@peterjschroeder
Copy link
Contributor

When assigning coordinates to widgets, picotui does not consider that some consoles will be different sizes. So when the application is executed on a different size terminal than it was written for, the widgets may be off-screen, wrap, or there may be extra padding.

Here is my current idea on how to fix this.

Define some functions like this

def ax(x):
    return int(x / 191 * Screen.screen_size()[0])
          
def ay(y):
    return int(y / 52 * Screen.screen_size()[1])

191x52 is the console size on my main desktop. By wrapping each coordinate with these functions it should adjust the placement of the widgets depending on the screen size.

Something like this would be beneficial in the library.

I am thinking it could work like this.

Create a variable in Screen which hold a virtual screen, vscreen_size? The user than sets vscreen_size when writing their code and uses those coordinates to place widgets.

Now in the widgets, when x, y, height, weight, etc. is set, it wraps the given coordinates in these new functions (could probably be a single function, as a tuple?) in each widget.

This would remove the need for constant dividing in a user's application to place the widgets in the same proportional location when screen size is different than what is being developed on.

@pfalcon
Copy link
Owner

pfalcon commented Dec 29, 2017

When assigning coordinates to widgets, picotui does not consider that some consoles will be different sizes.

Of course it considers that, in a very specific and obvious way, from the README:

it lacks geometry managers, so calculating coordinates is up to you

@pfalcon pfalcon changed the title Handle different console sizes. Geometry management questions Dec 29, 2017
@peterjschroeder
Copy link
Contributor Author

Yes, the README considers that, but that actual code does not. Is this something you would accept if I can get it working?

@pfalcon
Copy link
Owner

pfalcon commented Dec 29, 2017

README explicitly states that it's outside of picotui's scope. Geometry management can be implemented on top of picotui using separate libraries. Feel free to keep this issue open and discuss the matter with other interested picotui users. (I personally won't be interested in it until I find a usecase for it. In the meantime, there're much more mundane issues to resolve like #13 or #23).

@peterjschroeder
Copy link
Contributor Author

peterjschroeder commented Dec 31, 2017

The functions above work almost perfectly for this. Some additional math is required when text and frames are involved tho. When using ax for a widget width, it would be something like ax(30)-2. Same goes if you have text on the side of the widget, but the minus would be the length of the label.
The way I got it to work, was to set the dialog to 80x24. Than I set all the widget coordinates within that range and wrapped them in these new functions.
Now all the widgets will expand to their right positions on different size screens and when resizing.
The only thing it doesn't handle is if the screen goes below 80x24. It will have overlaps.

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

2 participants