Make the tabs scrollable when they overflow

This adds the ability to make a Flex element scrollable by passing a type tag and instance id, which we use to store the scroll position in an ElementStateHandle.

Still need to allow the element to auto-scroll.
This commit is contained in:
Nathan Sobo 2022-04-05 19:58:15 -06:00
parent 025d857be8
commit ab3bbe1e17
2 changed files with 72 additions and 5 deletions

View file

@ -633,7 +633,7 @@ impl Pane {
enum Tabs {}
let pane = cx.handle();
let tabs = MouseEventHandler::new::<Tabs, _, _>(0, cx, |mouse_state, cx| {
let mut row = Flex::row();
let mut row = Flex::row().scrollable::<Tabs, _>(1, cx);
for (ix, item) in self.items.iter().enumerate() {
let is_active = ix == self.active_item_index;