-
Notifications
You must be signed in to change notification settings - Fork 42
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
Title/status bar unset still take up UI space #114
Comments
Related #116 |
Maybe we could add a But from what I understand, top and bottom padding are absolute. I guess top padding is set in y_pos = self._row * row_height + 2 + y_adjust And bottom padding is set within return self._height - (2 * self._pady) - 3 We could either replace these absolute values by relatives or use if-statements based on potential |
Yes, at the moment the padding is hard-coded both in those functions as well as some other places where the logic for window re-sizing is located. Something like
which makes the window height subtract the padding for the title/status bars. Probably this can be changed to add a check to see if one or both are hidden or not. |
Indeed after looking closer I see some more hard-coded values 😬 So, there are multiple self._height = self._height - 4 Also references to the bottom viewport_height = self._height - (2 * self._pady) - 3 If I understand correctly, the And I see other absolute values in I can work on it, I was thinking about adding to class StatusBar:
def __init__(self):
self.__visible = True
self.__height = 1
@property
def height(self):
return self.__height
@property
def visible(self):
return self.__visible
@visible.setter
def visible(self, value: bool):
if not type(value) == bool:
raise ValueError
self.__visible= value
if self.__visible:
self.__height = 1
else:
self.__height = 0 But then we still have to deal with the Also, maybe |
@jwlodek You can assign me on this one. Can you just tell me what do you think about these above attributes/methods for StatusBar? Also, if I understand correctly, there are currently respectively 1 and 2 blank lines at the top and bottom, separating the status bars from other UI content. How should we handle that if the status bars are hidden? Either just remove these lines or leave a 1 line padding on both sides? |
So for the first part of your previous comment, the For the Off of the top of my head, here are the places where this padding is hard-coded:
I could have missed something somewhere, but pretty sure those are the only ones. Most of the other hard-coded values are relative to the height/width that is centrally managed, so they should stay as they are for now. Most are just used to handle the borders. I'd say maybe we should have the 1 character top/bottom padding as an optional thing, have it enabled by default and add a |
Ok, thanks for the help👍 I think we need a self._height = self._height - self.status_bar.height - self.title_bar.height - 2 Avoiding multiple ifs, considering we could leave only one of the two status bars visible, that would already be 4 possible combinations. And if we do set a padding |
Alright I've tinkered a bit, trying to only consider status bars, not the padding blank lines yet. First, I came up with this type of implementation to show/hide the status bars: class StatusBar:
def __init__(self, text, color):
self.__height = 1
def get_height(self):
return self.__height
def show(self):
self.__height = 1
def hide(self):
self.__height = 0 I think it's more consistent with current coding style. self._height = self._height - self.title_bar.get_height() - self.status_bar.get_height() - 2 So, right now, modifying Regarding Now, what's trickier:
y_pos = self._row * row_height + 2 + y_adjust We could grab the status bars using
Main |
I think this implementation suits the current code style for the project better like you said, so I think that we should keep. For the widget set, I think just having an extra parameter (the root PyCUI instance) passed in makes sense, since each widget set should be tied to the overall UI. I'm eventually planning to have the base PyCUI object be an extension of the widgetset class, to avoid a bunch of the code duplication we have now. For the widgets, I think maybe the best solution is to have it be done through the grid, since each widget already gets a reference to the grid it inhabits. That's another thing I want to revisit in the future is adding support for different layout managers than just a grid, but for now I think having the grid handle that kind of resizing would be best. And I think passing a reference to |
Describe the bug
When unsetting the title/status bar objects, some space is still taken up on the UI where they would have otherwise been displayed.
To Reproduce
Steps to reproduce the behavior:
status_bar
andtitle_bar
attributes of thePyCUI
instance toNone
Expected behavior
The widgets are displayed starting/ending at the top/bottom of the terminal, not one row away (where the bars would be display).
The text was updated successfully, but these errors were encountered: