refactor of compositor

This commit is contained in:
Will McGugan
2022-03-02 15:39:26 +00:00
parent 7c64c7813c
commit 237c556673
50 changed files with 429 additions and 342 deletions

View File

@@ -26,9 +26,9 @@ class SmoothApp(App):
footer = Footer()
self.bar = Placeholder(name="left")
await self.view.dock(footer, edge="bottom")
await self.view.dock(Placeholder(), Placeholder(), edge="top")
await self.view.dock(self.bar, edge="left", size=40, z=1)
await self.screen.dock(footer, edge="bottom")
await self.screen.dock(Placeholder(), Placeholder(), edge="top")
await self.screen.dock(self.bar, edge="left", size=40, z=1)
self.bar.layout_offset_x = -40

View File

@@ -2,7 +2,7 @@
$primary: #20639b;
App > View {
App > Screen {
layout: dock;
docks: side=left/1;
text: on $primary;
@@ -13,6 +13,7 @@ App > View {
dock: side;
width: 30;
offset-x: -100%;
transition: offset 500ms in_out_cubic;
border-right: outer #09312e;
}

View File

@@ -15,7 +15,7 @@ class MyApp(App):
self.body = body = ScrollView(auto_width=True)
await self.view.dock(body)
await self.screen.dock(body)
async def add_content():
table = Table(title="Demo")

View File

@@ -209,7 +209,7 @@ class CalculatorApp(App):
async def on_mount(self) -> None:
"""Mount the calculator widget."""
await self.view.dock(Calculator())
await self.screen.dock(Calculator())
CalculatorApp.run(title="Calculator Test", log="textual.log")

View File

@@ -36,14 +36,14 @@ class MyApp(App):
self.directory = DirectoryTree(self.path, "Code")
# Dock our widgets
await self.view.dock(Header(), edge="top")
await self.view.dock(Footer(), edge="bottom")
await self.screen.dock(Header(), edge="top")
await self.screen.dock(Footer(), edge="bottom")
# Note the directory is also in a scroll view
await self.view.dock(
await self.screen.dock(
ScrollView(self.directory), edge="left", size=48, name="sidebar"
)
await self.view.dock(self.body, edge="top")
await self.screen.dock(self.body, edge="top")
async def handle_file_click(self, message: FileClick) -> None:
"""A message sent by the directory tree when a file is clicked."""

View File

@@ -32,8 +32,8 @@ class EasingApp(App):
await tree.add(tree.root.id, easing_key, {"easing": easing_key})
await tree.root.expand()
await self.view.dock(ScrollView(tree), edge="left", size=32)
await self.view.dock(self.easing_view)
await self.screen.dock(ScrollView(tree), edge="left", size=32)
await self.screen.dock(self.easing_view)
await self.easing_view.dock(self.placeholder, edge="left", size=32)
async def handle_tree_click(self, message: TreeClick[dict]) -> None:

View File

@@ -6,7 +6,7 @@ class GridTest(App):
async def on_mount(self) -> None:
"""Make a simple grid arrangement."""
grid = await self.view.dock_grid(edge="left", name="left")
grid = await self.screen.dock_grid(edge="left", name="left")
grid.add_column(fraction=1, name="left", min_size=20)
grid.add_column(size=30, name="center")

View File

@@ -7,7 +7,7 @@ class GridTest(App):
async def on_mount(self, event: events.Mount) -> None:
"""Create a grid with auto-arranging cells."""
grid = await self.view.dock_grid()
grid = await self.screen.dock_grid()
grid.add_column("col", fraction=1, max_size=20)
grid.add_row("row", fraction=1, max_size=10)

View File

@@ -33,7 +33,7 @@ class MyApp(App):
"""Create and dock the widgets."""
body = ScrollView()
await self.view.mount(
await self.screen.mount(
Header(),
Footer(),
body=body,