Skip to content
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

Scroll behavior component #1107

Merged
merged 21 commits into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c305d53
Naive first step to refactor out scroll logic into separate component
ForLoveOfCats Jul 28, 2020
b00cdca
Move a bunch of event logic to `scroll_component` from `Scroll`
ForLoveOfCats Jul 28, 2020
d4f390e
Add method to coordinate painting with `scroll_component`
ForLoveOfCats Jul 28, 2020
a19f58e
Move a bunch of lifecycle logic to `scroll_component` from `Scroll`
ForLoveOfCats Jul 28, 2020
b5703a9
Documentation pass on `scroll_component`
ForLoveOfCats Jul 28, 2020
3a230a3
Rename `Scroll` to `AbsoluteScroll` & add scroll functionality to `List`
ForLoveOfCats Jul 28, 2020
bab2157
Add ability to change layout axis for `List` with builder fn
ForLoveOfCats Jul 29, 2020
803ab74
Scroll behavior component changelog
ForLoveOfCats Jul 29, 2020
7f6ea8f
Pass `BarHoveredState` by value and add impl Default for ScrollComponent
ForLoveOfCats Jul 29, 2020
47077a9
`ScrollComponent` review changes
ForLoveOfCats Aug 13, 2020
10899f4
Manually merge 'master' into 'ScrollComponent' to fix merge conflicts
ForLoveOfCats Aug 13, 2020
26a9ea5
Add some missing information to `ScrollComponent` documentation
ForLoveOfCats Aug 13, 2020
c4f8a32
`ScrollContainer` review take 2
ForLoveOfCats Aug 27, 2020
5f7c985
Changes from #1057
ForLoveOfCats Aug 27, 2020
78b7700
Update ScrollComponent to master & fix conflicts
ForLoveOfCats Aug 27, 2020
49b7928
ScrollComponent clippy
ForLoveOfCats Aug 27, 2020
2c31314
Remove List changes (updated to master) & fix Scroll regression
ForLoveOfCats Sep 6, 2020
83e9f2f
Merge 'master' into ScrollComponent (pls squash me)
ForLoveOfCats Sep 6, 2020
4ba7fc8
Add missing doc comments
ForLoveOfCats Sep 6, 2020
16b5846
Be a bit more careful about event consuming
ForLoveOfCats Sep 6, 2020
d027d27
Fix dup changelog entry & doc comment misspelling
ForLoveOfCats Sep 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Kaiyin Zhong
Kaur Kuut
Leopold Luley
Andrey Kabylin
Garrett Risley
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ You can find its changes [documented below](#060---2020-06-01).
- Re-export `druid_shell::Scalable` under `druid` namespace. ([#1075] by [@ForLoveOfCats])
- `TextBox` now supports ctrl and shift hotkeys. ([#1076] by [@vkahl])
- Added selection text color to textbox. ([#1093] by [@sysint64])
ForLoveOfCats marked this conversation as resolved.
Show resolved Hide resolved
- `scroll_component` for ease of adding consistant, customized, scrolling behavior to a widget. ([#1107] by [@ForLoveOfCats])
ForLoveOfCats marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- `Scale::from_scale` to `Scale::new`, and `Scale` methods `scale_x` / `scale_y` to `x` / `y`. ([#1042] by [@xStrom])
- Major rework of keyboard event handling. ([#1049] by [@raphlinus])
- `Container::rounded` takes `KeyOrValue<f64>` instead of `f64`. ([#1054] by [@binomial0])
- `List` handles its own scrolling on either the vertical or horizontal axis. ([#1107] by [@ForLoveOfCats])

### Deprecated

Expand Down Expand Up @@ -382,6 +384,7 @@ Last release without a changelog :(
[#1093]: https://github.com/linebender/druid/pull/1093
[#1100]: https://github.com/linebender/druid/pull/1100
[#1103]: https://github.com/linebender/druid/pull/1103
[#1107]: https://github.com/linebender/druid/pull/1107
[#1119]: https://github.com/linebender/druid/pull/1119
[#1120]: https://github.com/linebender/druid/pull/1120

Expand Down
12 changes: 5 additions & 7 deletions druid/examples/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use druid::im::{vector, Vector};
use druid::lens::{self, LensExt};
use druid::widget::{Button, CrossAxisAlignment, Flex, Label, List, Scroll};
use druid::widget::{Button, CrossAxisAlignment, Flex, Label, List};
use druid::{
AppLauncher, Color, Data, Lens, LocalizedString, UnitPoint, Widget, WidgetExt, WindowDesc,
};
Expand Down Expand Up @@ -64,22 +64,21 @@ fn ui_builder() -> impl Widget<AppData> {

// Build a simple list
lists.add_flex_child(
Scroll::new(List::new(|| {
List::new(|| {
Label::new(|item: &u32, _env: &_| format!("List item #{}", item))
.align_vertical(UnitPoint::LEFT)
.padding(10.0)
.expand()
.height(50.0)
.background(Color::rgb(0.5, 0.5, 0.5))
}))
.vertical()
})
.lens(AppData::left),
1.0,
);

// Build a list with shared data
lists.add_flex_child(
Scroll::new(List::new(|| {
List::new(|| {
Flex::row()
.with_child(
Label::new(|(_, item): &(Vector<u32>, u32), _env: &_| {
Expand All @@ -101,8 +100,7 @@ fn ui_builder() -> impl Widget<AppData> {
.padding(10.0)
.background(Color::rgb(0.5, 0.0, 0.5))
.fix_height(50.0)
}))
.vertical()
})
.lens(lens::Id.map(
// Expose shared data with children data
|d: &AppData| (d.right.clone(), d.right.clone()),
Expand Down
1 change: 1 addition & 0 deletions druid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pub mod lens;
mod localization;
mod menu;
mod mouse;
pub mod scroll_component;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(test)]
mod tests;
Expand Down
Loading