Extract columns into separate objects.

Co-authored-by: Kyle <kyle@zed.dev>
This commit is contained in:
Piotr Osiewicz 2023-08-14 15:13:17 +02:00
parent f4121b42da
commit 4aa5df4cda
2 changed files with 110 additions and 121 deletions

View file

@ -219,29 +219,30 @@ impl View for BufferSearchBar {
cx, cx,
) )
}; };
let icon_style = theme.search.editor_icon.clone();
Flex::row() let nav_column = Flex::column()
.with_child( .with_child(
Flex::column() Flex::row()
.align_children_center()
.with_child( .with_child(
Flex::row() Flex::row()
.align_children_center() .with_child(nav_button_for_direction("<", Direction::Prev, cx))
.with_child( .with_child(nav_button_for_direction(">", Direction::Next, cx))
Flex::row() .aligned(),
.with_child(nav_button_for_direction("<", Direction::Prev, cx))
.with_child(nav_button_for_direction(">", Direction::Next, cx))
.aligned(),
)
.with_children(match_count)
.aligned()
.left()
.top()
.flex(1., true)
.constrained()
.with_max_height(theme.search.search_bar_row_height),
) )
.contained(), .with_children(match_count)
.aligned()
.left()
.top()
.flex(1., true)
.constrained()
.with_max_height(theme.search.search_bar_row_height),
) )
.contained();
let icon_style = theme.search.editor_icon.clone();
Flex::row()
.with_child(nav_column)
.with_child( .with_child(
Flex::column() Flex::column()
.align_children_center() .align_children_center()
@ -263,18 +264,23 @@ impl View for BufferSearchBar {
.left() .left()
.flex(1., true), .flex(1., true),
) )
.with_children(render_search_option( .with_child(
supported_options.case, Flex::row()
"icons/case_insensitive_12.svg", .with_children(render_search_option(
SearchOptions::CASE_SENSITIVE, supported_options.case,
cx, "icons/case_insensitive_12.svg",
)) SearchOptions::CASE_SENSITIVE,
.with_children(render_search_option( cx,
supported_options.word, ))
"icons/word_search_12.svg", .with_children(render_search_option(
SearchOptions::WHOLE_WORD, supported_options.word,
cx, "icons/word_search_12.svg",
)) SearchOptions::WHOLE_WORD,
cx,
))
.flex(1., true)
.contained(),
)
.contained() .contained()
.with_style(editor_container) .with_style(editor_container)
.aligned() .aligned()

View file

@ -1551,113 +1551,96 @@ impl View for ProjectSearchBar {
cx, cx,
) )
}; };
let nav_column = Flex::column()
Flex::row()
.with_child( .with_child(
Flex::column() Flex::row()
.with_child(
Flex::row()
.align_children_center()
.with_child(
Flex::row()
.with_child(nav_button_for_direction(
"<",
Direction::Prev,
cx,
))
.with_child(nav_button_for_direction(
">",
Direction::Next,
cx,
))
.aligned(),
)
.with_children(matches)
.aligned()
.top()
.left()
.constrained()
.with_height(theme.search.search_bar_row_height),
)
.flex(1., true),
)
.with_child(
Flex::column()
.align_children_center() .align_children_center()
.with_child( .with_child(
Flex::row() Flex::row()
.with_child( .with_child(nav_button_for_direction("<", Direction::Prev, cx))
Flex::row() .with_child(nav_button_for_direction(">", Direction::Next, cx))
.with_child(query) .aligned(),
.contained()
.with_style(query_container_style)
.aligned()
.constrained()
.with_min_width(theme.search.editor.min_width)
.with_max_width(theme.search.editor.max_width)
.with_max_height(theme.search.search_bar_row_height)
.flex(1., false),
)
.contained()
.with_margin_bottom(row_spacing),
) )
.with_children(filters) .with_children(matches)
.contained()
.aligned() .aligned()
.top() .top()
.flex(1., false), .left()
.constrained()
.with_height(theme.search.search_bar_row_height),
) )
.flex(1., true);
let editor_column = Flex::column()
.align_children_center()
.with_child( .with_child(
Flex::column() Flex::row()
.with_child( .with_child(
Flex::row() Flex::row()
.align_children_center() .with_child(query)
.with_child( .contained()
Flex::row() .with_style(query_container_style)
.with_child(search_button_for_mode(SearchMode::Text, cx))
.with_children(semantic_index)
.with_child(search_button_for_mode(SearchMode::Regex, cx))
.constrained()
.with_height(theme.search.search_bar_row_height)
.aligned()
.left()
.contained()
.with_style(theme.search.modes_container),
)
.with_child(
super::search_bar::render_close_button(
"Dismiss Project Search",
&theme.search,
cx,
|_, this, cx| {
if let Some(search) =
this.active_project_search.as_mut()
{
search
.update(cx, |_, cx| cx.emit(ViewEvent::Dismiss))
}
},
None,
)
.aligned()
.right(),
)
.constrained()
.with_height(theme.search.search_bar_row_height)
.aligned() .aligned()
.right() .constrained()
.top() .with_min_width(theme.search.editor.min_width)
.flex(1., true), .with_max_width(theme.search.editor.max_width)
) .with_max_height(theme.search.search_bar_row_height)
.with_children( .flex(1., false),
_search
.read(cx)
.filters_enabled
.then(|| Flex::row().flex(1., true)),
) )
.contained() .contained()
.with_margin_bottom(row_spacing),
)
.with_children(filters)
.contained()
.aligned()
.top()
.flex(1., false);
let mode_column = Flex::column()
.with_child(
Flex::row()
.align_children_center()
.with_child(
Flex::row()
.with_child(search_button_for_mode(SearchMode::Text, cx))
.with_children(semantic_index)
.with_child(search_button_for_mode(SearchMode::Regex, cx))
.aligned()
.left()
.contained()
.with_style(theme.search.modes_container),
)
.with_child(
super::search_bar::render_close_button(
"Dismiss Project Search",
&theme.search,
cx,
|_, this, cx| {
if let Some(search) = this.active_project_search.as_mut() {
search.update(cx, |_, cx| cx.emit(ViewEvent::Dismiss))
}
},
None,
)
.aligned()
.right(),
)
.constrained()
.with_height(theme.search.search_bar_row_height)
.aligned()
.right()
.top()
.flex(1., true), .flex(1., true),
) )
.with_children(
_search
.read(cx)
.filters_enabled
.then(|| Flex::row().flex(1., true)),
)
.contained()
.flex(1., true);
Flex::row()
.with_child(nav_column)
.with_child(editor_column)
.with_child(mode_column)
.contained() .contained()
.with_style(theme.search.container) .with_style(theme.search.container)
.flex_float() .flex_float()