Skip to content

Commit

Permalink
Rename lists to stacks (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc authored Jan 2, 2024
1 parent fbe7964 commit 4eeef28
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 80 deletions.
10 changes: 5 additions & 5 deletions examples/layout/src/draggable_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use floem::{
style::{CursorStyle, Position},
view::View,
views::{
container, h_stack, label, scroll, virtual_list, Decorators, VirtualListDirection,
VirtualListItemSize,
container, h_stack, label, scroll, virtual_stack, Decorators, VirtualStackDirection,
VirtualStackItemSize,
},
EventPropagation,
};
Expand All @@ -20,9 +20,9 @@ pub fn draggable_sidebar_view() -> impl View {
let is_sidebar_dragging = create_rw_signal(false);

let side_bar = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 22.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 22.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand Down
16 changes: 8 additions & 8 deletions examples/layout/src/holy_grail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use floem::{
style::Position,
view::View,
views::{
container, h_stack, label, scroll, v_stack, virtual_list, Decorators, VirtualListDirection,
VirtualListItemSize,
container, h_stack, label, scroll, v_stack, virtual_stack, Decorators,
VirtualStackDirection, VirtualStackItemSize,
},
};

Expand All @@ -21,9 +21,9 @@ pub fn holy_grail_view() -> impl View {
.style(|s| s.padding(10.0).width_full().height(TOPBAR_HEIGHT));

let side_bar_right = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 22.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 22.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand All @@ -48,9 +48,9 @@ pub fn holy_grail_view() -> impl View {
});

let side_bar_left = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 22.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 22.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand Down
10 changes: 5 additions & 5 deletions examples/layout/src/left_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use floem::{
style::Position,
view::View,
views::{
container, h_stack, label, scroll, v_stack, virtual_list, Decorators, VirtualListDirection,
VirtualListItemSize,
container, h_stack, label, scroll, v_stack, virtual_stack, Decorators,
VirtualStackDirection, VirtualStackItemSize,
},
};

Expand All @@ -21,9 +21,9 @@ pub fn left_sidebar_view() -> impl View {
.style(|s| s.padding(10.0).width_full().height(TOPBAR_HEIGHT));

let side_bar = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 22.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 22.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand Down
10 changes: 5 additions & 5 deletions examples/layout/src/right_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use floem::{
style::Position,
view::View,
views::{
container, h_stack, label, scroll, v_stack, virtual_list, Decorators, VirtualListDirection,
VirtualListItemSize,
container, h_stack, label, scroll, v_stack, virtual_stack, Decorators,
VirtualStackDirection, VirtualStackItemSize,
},
};

Expand All @@ -21,9 +21,9 @@ pub fn right_sidebar_view() -> impl View {
.style(|s| s.padding(10.0).width_full().height(TOPBAR_HEIGHT));

let side_bar = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 22.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 22.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand Down
10 changes: 5 additions & 5 deletions examples/virtual_list/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use floem::{
reactive::create_signal,
unit::UnitExt,
view::View,
views::virtual_list,
views::virtual_stack,
views::Decorators,
views::{container, label, scroll, VirtualListDirection, VirtualListItemSize},
views::{container, label, scroll, VirtualStackDirection, VirtualStackItemSize},
};

fn app_view() -> impl View {
Expand All @@ -13,9 +13,9 @@ fn app_view() -> impl View {

container(
scroll(
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 20.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 20.0)),
move || long_list.get(),
move |item| *item,
move |item| label(move || item.to_string()).style(|s| s.height(20.0)),
Expand Down
16 changes: 8 additions & 8 deletions examples/widget-gallery/src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use floem::{
style::{CursorStyle, JustifyContent},
view::View,
views::{
container, label, scroll, stack, virtual_list, Decorators, VirtualListDirection,
VirtualListItemSize,
container, label, scroll, stack, virtual_stack, Decorators, VirtualStackDirection,
VirtualStackItemSize,
},
widgets::checkbox,
EventPropagation,
Expand All @@ -29,9 +29,9 @@ fn simple_list() -> impl View {
let long_list: im::Vector<i32> = (0..100).collect();
let (long_list, _set_long_list) = create_signal(long_list);
scroll(
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 20.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 20.0)),
move || long_list.get(),
move |item| *item,
move |item| label(move || item.to_string()).style(|s| s.height(24.0)),
Expand All @@ -49,9 +49,9 @@ fn enhanced_list() -> impl View {
let list_width = 180.0;
let item_height = 32.0;
scroll(
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 32.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 32.0)),
move || long_list.get(),
move |item| *item,
move |item| {
Expand Down
10 changes: 5 additions & 5 deletions examples/widget-gallery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use floem::{
unit::UnitExt,
view::View,
views::{
container, container_box, h_stack, label, scroll, stack, tab, v_stack, virtual_list,
Decorators, VirtualListDirection, VirtualListItemSize,
container, container_box, h_stack, label, scroll, stack, tab, v_stack, virtual_stack,
Decorators, VirtualStackDirection, VirtualStackItemSize,
},
widgets::button,
EventPropagation,
Expand All @@ -44,9 +44,9 @@ fn app_view() -> impl View {
let (active_tab, set_active_tab) = create_signal(0);

let list = scroll({
virtual_list(
VirtualListDirection::Vertical,
VirtualListItemSize::Fixed(Box::new(|| 36.0)),
virtual_stack(
VirtualStackDirection::Vertical,
VirtualStackItemSize::Fixed(Box::new(|| 36.0)),
move || tabs.get(),
move |item| *item,
move |item| {
Expand Down
10 changes: 5 additions & 5 deletions src/views/list.rs → src/views/dyn_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) type FxIndexSet<T> = indexmap::IndexSet<T, BuildHasherDefault<FxHashe
#[educe(Debug)]
pub(crate) struct HashRun<T>(#[educe(Debug(ignore))] pub(crate) T);

pub struct List<V, T>
pub struct DynStack<V, T>
where
V: View,
T: 'static,
Expand All @@ -30,7 +30,7 @@ where
phantom: PhantomData<T>,
}

pub fn list<IF, I, T, KF, K, VF, V>(each_fn: IF, key_fn: KF, view_fn: VF) -> List<V, T>
pub fn dyn_stack<IF, I, T, KF, K, VF, V>(each_fn: IF, key_fn: KF, view_fn: VF) -> DynStack<V, T>
where
IF: Fn() -> I + 'static,
I: IntoIterator<Item = T>,
Expand Down Expand Up @@ -69,15 +69,15 @@ where
HashRun(hashed_items)
});
let view_fn = Box::new(as_child_of_current_scope(view_fn));
List {
DynStack {
data: ViewData::new(id),
children: Vec::new(),
view_fn,
phantom: PhantomData,
}
}

impl<V: View + 'static, T> View for List<V, T> {
impl<V: View + 'static, T> View for DynStack<V, T> {
fn view_data(&self) -> &ViewData {
&self.data
}
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<V: View + 'static, T> View for List<V, T> {
}

fn debug_name(&self) -> std::borrow::Cow<'static, str> {
"List".into()
"DynStack".into()
}

fn update(&mut self, cx: &mut UpdateCx, state: Box<dyn std::any::Any>) {
Expand Down
8 changes: 4 additions & 4 deletions src/views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub use label::*;
mod rich_text;
pub use rich_text::*;

mod list;
pub use list::*;
mod dyn_stack;
pub use dyn_stack::*;

mod svg;
pub use svg::*;
Expand All @@ -30,8 +30,8 @@ pub use dyn_container::*;
mod decorator;
pub use decorator::*;

mod virtual_list;
pub use virtual_list::*;
mod virtual_stack;
pub use virtual_stack::*;

pub mod scroll;
pub use scroll::{scroll, Scroll};
Expand Down
Loading

0 comments on commit 4eeef28

Please sign in to comment.