Rename Drawable::boxed to into_element and make containers generic
Multi-element are now generic over any drawable child, which can be converted into an element. Co-Authored-By: Nathan Sobo <nathan@zed.dev> Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
4d433663bd
commit
03619dfa55
80 changed files with 1132 additions and 1434 deletions
|
@ -114,8 +114,7 @@ impl View for BufferSearchBar {
|
|||
ChildView::new(&self.query_editor, cx)
|
||||
.aligned()
|
||||
.left()
|
||||
.flex(1., true)
|
||||
.boxed(),
|
||||
.flex(1., true),
|
||||
)
|
||||
.with_children(self.active_searchable_item.as_ref().and_then(
|
||||
|searchable_item| {
|
||||
|
@ -132,8 +131,7 @@ impl View for BufferSearchBar {
|
|||
Label::new(message, theme.search.match_index.text.clone())
|
||||
.contained()
|
||||
.with_style(theme.search.match_index.container)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
},
|
||||
))
|
||||
|
@ -143,15 +141,13 @@ impl View for BufferSearchBar {
|
|||
.constrained()
|
||||
.with_min_width(theme.search.editor.min_width)
|
||||
.with_max_width(theme.search.editor.max_width)
|
||||
.flex(1., false)
|
||||
.boxed(),
|
||||
.flex(1., false),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
|
@ -175,16 +171,14 @@ impl View for BufferSearchBar {
|
|||
))
|
||||
.contained()
|
||||
.with_style(theme.search.option_button_group)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.flex(1., true)
|
||||
.boxed(),
|
||||
.flex(1., true),
|
||||
)
|
||||
.with_child(self.render_close_button(&theme.search, cx))
|
||||
.contained()
|
||||
.with_style(theme.search.container)
|
||||
.named("search bar")
|
||||
.into_named_element("search bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +337,6 @@ impl BufferSearchBar {
|
|||
Label::new(icon, style.text.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, move |_, _, cx| {
|
||||
cx.dispatch_any_action(option.to_toggle_action())
|
||||
|
@ -356,7 +349,7 @@ impl BufferSearchBar {
|
|||
tooltip_style,
|
||||
cx,
|
||||
)
|
||||
.boxed(),
|
||||
.into_element(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -391,7 +384,6 @@ impl BufferSearchBar {
|
|||
Label::new(icon, style.text.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, {
|
||||
let action = action.boxed_clone();
|
||||
|
@ -405,7 +397,7 @@ impl BufferSearchBar {
|
|||
tooltip_style,
|
||||
cx,
|
||||
)
|
||||
.boxed()
|
||||
.into_element()
|
||||
}
|
||||
|
||||
fn render_close_button(
|
||||
|
@ -429,7 +421,6 @@ impl BufferSearchBar {
|
|||
.with_width(style.button_width)
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, {
|
||||
let action = action.boxed_clone();
|
||||
|
@ -437,7 +428,7 @@ impl BufferSearchBar {
|
|||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.with_tooltip::<CloseButton>(0, tooltip.to_string(), Some(action), tooltip_style, cx)
|
||||
.boxed()
|
||||
.into_element()
|
||||
}
|
||||
|
||||
fn deploy(pane: &mut Pane, action: &Deploy, cx: &mut ViewContext<Pane>) {
|
||||
|
|
|
@ -197,16 +197,15 @@ impl View for ProjectSearchView {
|
|||
.contained()
|
||||
.with_background_color(theme.editor.background)
|
||||
.flex(1., true)
|
||||
.boxed()
|
||||
})
|
||||
.on_down(MouseButton::Left, |_, _, cx| {
|
||||
cx.focus_parent_view();
|
||||
})
|
||||
.boxed()
|
||||
.into_named_element("project search view")
|
||||
} else {
|
||||
ChildView::new(&self.results_editor, cx)
|
||||
.flex(1., true)
|
||||
.boxed()
|
||||
.into_named_element("project search view")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,17 +262,14 @@ impl Item for ProjectSearchView {
|
|||
.with_width(tab_theme.type_icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(tab_theme.spacing)
|
||||
.boxed(),
|
||||
.with_margin_right(tab_theme.spacing),
|
||||
)
|
||||
.with_children(self.model.read(cx).active_query.as_ref().map(|query| {
|
||||
let query_text = util::truncate_and_trailoff(query.as_str(), MAX_TAB_TITLE_LEN);
|
||||
|
||||
Label::new(query_text, tab_theme.label.clone())
|
||||
.aligned()
|
||||
.boxed()
|
||||
Label::new(query_text, tab_theme.label.clone()).aligned()
|
||||
}))
|
||||
.boxed()
|
||||
.into_element()
|
||||
}
|
||||
|
||||
fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) {
|
||||
|
@ -778,7 +774,6 @@ impl ProjectSearchBar {
|
|||
Label::new(icon, style.text.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, {
|
||||
let action = action.boxed_clone();
|
||||
|
@ -792,7 +787,7 @@ impl ProjectSearchBar {
|
|||
tooltip_style,
|
||||
cx,
|
||||
)
|
||||
.boxed()
|
||||
.into_element()
|
||||
}
|
||||
|
||||
fn render_option_button(
|
||||
|
@ -813,7 +808,6 @@ impl ProjectSearchBar {
|
|||
Label::new(icon, style.text.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(MouseButton::Left, move |_, _, cx| {
|
||||
cx.dispatch_any_action(option.to_toggle_action())
|
||||
|
@ -826,7 +820,7 @@ impl ProjectSearchBar {
|
|||
tooltip_style,
|
||||
cx,
|
||||
)
|
||||
.boxed()
|
||||
.into_element()
|
||||
}
|
||||
|
||||
fn is_option_enabled(&self, option: SearchOption, cx: &AppContext) -> bool {
|
||||
|
@ -868,8 +862,7 @@ impl View for ProjectSearchBar {
|
|||
ChildView::new(&search.query_editor, cx)
|
||||
.aligned()
|
||||
.left()
|
||||
.flex(1., true)
|
||||
.boxed(),
|
||||
.flex(1., true),
|
||||
)
|
||||
.with_children(search.active_match_index.map(|match_ix| {
|
||||
Label::new(
|
||||
|
@ -883,7 +876,6 @@ impl View for ProjectSearchBar {
|
|||
.contained()
|
||||
.with_style(theme.search.match_index.container)
|
||||
.aligned()
|
||||
.boxed()
|
||||
}))
|
||||
.contained()
|
||||
.with_style(editor_container)
|
||||
|
@ -891,15 +883,13 @@ impl View for ProjectSearchBar {
|
|||
.constrained()
|
||||
.with_min_width(theme.search.editor.min_width)
|
||||
.with_max_width(theme.search.editor.max_width)
|
||||
.flex(1., false)
|
||||
.boxed(),
|
||||
.flex(1., false),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
|
@ -912,16 +902,15 @@ impl View for ProjectSearchBar {
|
|||
.with_child(self.render_option_button("Regex", SearchOption::Regex, cx))
|
||||
.contained()
|
||||
.with_style(theme.search.option_button_group)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
.aligned(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.search.container)
|
||||
.aligned()
|
||||
.left()
|
||||
.named("project search")
|
||||
.into_named_element("project search")
|
||||
} else {
|
||||
Empty::new().boxed()
|
||||
Empty::new().into_element()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue