-
Notifications
You must be signed in to change notification settings - Fork 827
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
tree fix #744
Merged
Merged
tree fix #744
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
385a02a
tree fix
willmcgugan 27bd26c
docstring
willmcgugan f9e9d03
remove log
willmcgugan 9491510
whitespace
willmcgugan 3053798
remove log
willmcgugan 8b66054
optimize content height
willmcgugan 04d3fc1
fixes for state updates
willmcgugan ad95eb9
superfluous code
willmcgugan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -611,6 +611,18 @@ def region(self) -> Region: | |
except errors.NoWidget: | ||
return Region() | ||
|
||
@property | ||
def container_viewport(self) -> Region: | ||
"""The viewport region (parent window) | ||
|
||
Returns: | ||
Region: The region that contains this widget. | ||
""" | ||
if self.parent is None: | ||
return self.size.region | ||
assert isinstance(self.parent, Widget) | ||
return self.parent.region | ||
|
||
@property | ||
def virtual_region(self) -> Region: | ||
"""The widget region relative to it's container. Which may not be visible, | ||
|
@@ -1070,6 +1082,7 @@ def scroll_to_region( | |
window = self.content_region.at_offset(self.scroll_offset) | ||
if spacing is not None: | ||
window = window.shrink(spacing) | ||
self.log(window=window, region=region) | ||
delta_x, delta_y = Region.get_scroll_to_visible(window, region) | ||
scroll_x, scroll_y = self.scroll_offset | ||
delta = Offset( | ||
|
@@ -1080,7 +1093,7 @@ def scroll_to_region( | |
self.scroll_relative( | ||
delta.x or None, | ||
delta.y or None, | ||
animate=animate, | ||
animate=animate if abs(delta_y) > 1 else False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't animate movement of a single line. |
||
duration=0.2, | ||
) | ||
return delta | ||
|
@@ -1093,13 +1106,21 @@ def scroll_visible(self) -> None: | |
|
||
def __init_subclass__( | ||
cls, | ||
can_focus: bool = False, | ||
can_focus_children: bool = True, | ||
can_focus: bool | None = None, | ||
can_focus_children: bool | None = None, | ||
inherit_css: bool = True, | ||
) -> None: | ||
|
||
base = cls.__mro__[0] | ||
super().__init_subclass__(inherit_css=inherit_css) | ||
cls.can_focus = can_focus | ||
cls.can_focus_children = can_focus_children | ||
if issubclass(base, Widget): | ||
|
||
cls.can_focus = base.can_focus if can_focus is None else can_focus | ||
cls.can_focus_children = ( | ||
base.can_focus_children | ||
if can_focus_children is None | ||
else can_focus_children | ||
) | ||
|
||
def __rich_repr__(self) -> rich.repr.Result: | ||
yield "id", self.id, None | ||
|
@@ -1529,49 +1550,52 @@ def _on_hide(self, event: events.Hide) -> None: | |
if self.has_focus: | ||
self.app._reset_focus(self) | ||
|
||
def key_home(self) -> bool: | ||
def _on_scroll_to_region(self, message: messages.ScrollToRegion) -> None: | ||
self.scroll_to_region(message.region, animate=True) | ||
|
||
def _key_home(self) -> bool: | ||
if self._allow_scroll: | ||
self.scroll_home() | ||
return True | ||
return False | ||
|
||
def key_end(self) -> bool: | ||
def _key_end(self) -> bool: | ||
if self._allow_scroll: | ||
self.scroll_end() | ||
return True | ||
return False | ||
|
||
def key_left(self) -> bool: | ||
def _key_left(self) -> bool: | ||
if self.allow_horizontal_scroll: | ||
self.scroll_left() | ||
return True | ||
return False | ||
|
||
def key_right(self) -> bool: | ||
def _key_right(self) -> bool: | ||
if self.allow_horizontal_scroll: | ||
self.scroll_right() | ||
return True | ||
return False | ||
|
||
def key_down(self) -> bool: | ||
def _key_down(self) -> bool: | ||
if self.allow_vertical_scroll: | ||
self.scroll_down() | ||
return True | ||
return False | ||
|
||
def key_up(self) -> bool: | ||
def _key_up(self) -> bool: | ||
if self.allow_vertical_scroll: | ||
self.scroll_up() | ||
return True | ||
return False | ||
|
||
def key_pagedown(self) -> bool: | ||
def _key_pagedown(self) -> bool: | ||
if self.allow_vertical_scroll: | ||
self.scroll_page_down() | ||
return True | ||
return False | ||
|
||
def key_pageup(self) -> bool: | ||
def _key_pageup(self) -> bool: | ||
if self.allow_vertical_scroll: | ||
self.scroll_page_up() | ||
return True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sight change in semantics here. If there is a
key_
method defined for a given key then it won't attempt to try the base classes.