diff --git a/book/src/todo_4.md b/book/src/todo_4.md index 55d97e7c6fc8..99d8f2d5f881 100644 --- a/book/src/todo_4.md +++ b/book/src/todo_4.md @@ -11,9 +11,9 @@ We will start by adding an empty sidebar without any functionality. There are a couple of steps we have to go through to get to this state. First, we have to replace [`gtk::ApplicationWindow`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.ApplicationWindow.html) with [`adw::ApplicationWindow`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.ApplicationWindow.html). -The only difference between those two is that `adw::ApplicationWindow` has no titlebar area. -That comes in handy when we build up our interface with [`adw::Leaflet`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.Leaflet.html). -In the screenshot above, the `Leaflet` behaves like a [`gtk::Box`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Box.html) and contains the collection view on the left, a separator in the middle and the task view on the right. +The main difference between those two is that `adw::ApplicationWindow` has no titlebar area. +That comes in handy when we build up our interface with [`adw::NavigationSplitView`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.NavigationSplitView.html). +In the screenshot above, the `NavigationSplitView` adds a sidebar for the collection view to the left, while the task view occupies the space on the right. When using `adw::ApplicationWindow` the collection view and task view have their own [`adw::HeaderBar`](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/struct.HeaderBar.html) and the separator spans over the whole window. @@ -56,12 +56,10 @@ Filename: @@ -73,85 +71,99 @@ The adaptive behavior of the leaflet allows the To-Do app to work on smaller scr We add the necessary UI elements for the collection view, such as a header bar with a button to add a new collection, as well as the list box `collections_list` to display the collections later on. - -As you can see in the screencast above, the header bar also displays a close button if the leaflet is folded. -We include this logic with an expression which can be built up in the UI file with the tag [`lookup`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Expression.html#gtkexpression-in-ui-files). +We also add the style [navigations-sidebar](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/style-classes.html#sidebars) to `collections_list`. Filename: listings/todo/7/resources/window.ui ```xml - - vertical - 200 - - - - leaflet - - - - list-add-symbolic - New Collection - win.new-collection + + + + + + + + + list-add-symbolic + New Collection + win.new-collection + + - - - - - True - - - + + + + + + + - - ``` We also add a header bar to the task view. -We don't have to worry about the close button here: it will always be displayed. -However, we will need a way to go back to the collection view when the leaflet is folded. -That is why we add `back_button` which can be used to return to the collection view and which is only visible when the leaflet is folded. Filename: listings/todo/7/resources/window.ui ```xml - - vertical - True - 250 - - - - - - - - - leaflet - - go-previous-symbolic - Back + + Tasks + + + + + False + + + open-menu-symbolic + main-menu + Main Menu + + - - - open-menu-symbolic - main-menu - Main Menu + + + + + 400 + 300 + + + vertical + 12 + 12 + 12 + + + Enter a Taskā€¦ + list-add-symbolic + + + + + False + none + + + + + + + - + - - - - + ``` @@ -207,14 +219,20 @@ Filename: To-Do - 650 - 550 + 360 + 200 + + + max-width: 500sp + True + + crossfade - empty + placeholder @@ -226,7 +244,7 @@ Filename: main - + @@ -413,11 +431,10 @@ Filename: listings/todo/8/window/mod.rs diff --git a/book/src/vid/todo_8_adaptive_sidebar.webm b/book/src/vid/todo_8_adaptive_sidebar.webm index fad93154a504..f4c7cf7c040f 100644 Binary files a/book/src/vid/todo_8_adaptive_sidebar.webm and b/book/src/vid/todo_8_adaptive_sidebar.webm differ diff --git a/book/src/vid/todo_8_dialog.webm b/book/src/vid/todo_8_dialog.webm index 85c9757035ee..887d9b066862 100644 Binary files a/book/src/vid/todo_8_dialog.webm and b/book/src/vid/todo_8_dialog.webm differ