Scrolling nested containers (#538)

* Scrolling nested containers

* Return boolean if any scrolling occurred in any descendant in scroll_to_widget
This commit is contained in:
darrenburns
2022-06-08 16:20:53 +01:00
committed by Will McGugan
parent a5d46d6adc
commit 566eb837b7
3 changed files with 63 additions and 40 deletions

View File

@@ -42,7 +42,7 @@ App > Screen {
background: $primary-background-darken-2;
color: $text-primary-darken-2 ;
border-right: outer $primary-darken-3;
content-align: center middle;
content-align: center middle;
}
#sidebar .user {
@@ -71,7 +71,7 @@ App > Screen {
color: $text-background;
background: $background;
layout: vertical;
overflow-y: scroll;
overflow-y: scroll;
}
@@ -109,6 +109,7 @@ Tweet {
}
}
TweetHeader {
height:1;
@@ -136,7 +137,7 @@ Tweet.scroll-horizontal TweetBody {
/* border-top: hidden $accent-darken-3; */
border: tall $accent-darken-2;
/* border-left: tall $accent-darken-1; */
/* padding: 1 0 0 0 ; */
@@ -151,10 +152,10 @@ Tweet.scroll-horizontal TweetBody {
height: 3;
border: tall $accent-darken-1;
/* border-left: tall $accent-darken-3; */
}
#footer {
@@ -194,11 +195,11 @@ Error {
background: $error;
color: $text-error;
border-top: hkey $error-darken-2;
border-bottom: hkey $error-darken-2;
border-bottom: hkey $error-darken-2;
margin: 1 3;
text-style: bold;
align-horizontal: center;
align-horizontal: center;
}
Warning {
@@ -207,7 +208,7 @@ Warning {
background: $warning;
color: $text-warning-fade-1;
border-top: hkey $warning-darken-2;
border-bottom: hkey $warning-darken-2;
border-bottom: hkey $warning-darken-2;
margin: 1 2;
text-style: bold;
align-horizontal: center;
@@ -220,7 +221,7 @@ Success {
background: $success-lighten-3;
color: $text-success-lighten-3-fade-1;
border-top: hkey $success;
border-bottom: hkey $success;
border-bottom: hkey $success;
margin: 1 2;
text-style: bold;
align-horizontal: center;

View File

@@ -100,6 +100,8 @@ class BasicApp(App, css_path="basic.css"):
def on_mount(self):
"""Build layout here."""
self.scroll_to_target = Tweet(TweetBody())
self.mount(
header=Static(
Text.from_markup(
@@ -157,6 +159,9 @@ class BasicApp(App, css_path="basic.css"):
tweet_body = self.query("TweetBody").first()
tweet_body.short_lorem = not tweet_body.short_lorem
def key_v(self):
self.get_child(id="content").scroll_to_widget(self.scroll_to_target)
app = BasicApp()
@@ -176,5 +181,5 @@ if __name__ == "__main__":
print(Scalar.resolve_dimension.cache_info())
from rich.style import Style
print(Style._add_cache)