Rename h_stack and v_stack to h_flex and v_flex, respectively (#4053)

This PR renames the `h_stack` and `v_stack` to `h_flex` and `v_flex`,
respectively.

We were previously using `h_stack` and `v_stack` to match SwiftUI, but
`h_flex` and `v_flex` fit better with the web/flexbox terminology that
the rest of GPUI uses.

Additionally, we were already calling the utility functions used to
implement `h_stack` and `v_stack` by the new names.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-01-15 11:34:06 -05:00 committed by GitHub
parent b136d21ebf
commit 90f4c70a82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 271 additions and 271 deletions

View file

@ -325,13 +325,13 @@ impl ChatPanel {
};
let this = cx.view().clone();
v_stack()
v_flex()
.w_full()
.relative()
.overflow_hidden()
.when(!is_continuation_from_previous, |this| {
this.pt_3().child(
h_stack()
h_flex()
.child(
div().absolute().child(
Avatar::new(message.sender.avatar_uri.clone())
@ -358,7 +358,7 @@ impl ChatPanel {
})
.when(is_continuation_from_previous, |this| this.pt_1())
.child(
v_stack()
v_flex()
.w_full()
.text_ui_sm()
.id(element_id)
@ -514,14 +514,14 @@ impl ChatPanel {
impl Render for ChatPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
v_flex()
.track_focus(&self.focus_handle)
.full()
.on_action(cx.listener(Self::send))
.child(
h_stack().z_index(1).child(
h_flex().z_index(1).child(
TabBar::new("chat_header").child(
h_stack()
h_flex()
.w_full()
.h(rems(ui::Tab::HEIGHT_IN_REMS))
.px_2()
@ -567,7 +567,7 @@ impl Render for ChatPanel {
}
}))
.child(
h_stack()
h_flex()
.when(!self.is_scrolled_to_bottom, |el| {
el.border_t_1().border_color(cx.theme().colors().border)
})

View file

@ -887,7 +887,7 @@ impl CollabPanel {
.ok();
}))
.start_slot(
h_stack()
h_flex()
.gap_1()
.child(render_tree_branch(is_last, false, cx))
.child(IconButton::new(0, IconName::Folder)),
@ -908,7 +908,7 @@ impl CollabPanel {
ListItem::new(("screen", id))
.selected(is_selected)
.start_slot(
h_stack()
h_flex()
.gap_1()
.child(render_tree_branch(is_last, false, cx))
.child(IconButton::new(0, IconName::Screen)),
@ -949,7 +949,7 @@ impl CollabPanel {
this.open_channel_notes(channel_id, cx);
}))
.start_slot(
h_stack()
h_flex()
.gap_1()
.child(render_tree_branch(false, true, cx))
.child(IconButton::new(0, IconName::File)),
@ -970,7 +970,7 @@ impl CollabPanel {
this.join_channel_chat(channel_id, cx);
}))
.start_slot(
h_stack()
h_flex()
.gap_1()
.child(render_tree_branch(false, false, cx))
.child(IconButton::new(0, IconName::MessageBubbles)),
@ -1726,12 +1726,12 @@ impl CollabPanel {
fn render_signed_out(&mut self, cx: &mut ViewContext<Self>) -> Div {
let collab_blurb = "Work with your team in realtime with collaborative editing, voice, shared notes and more.";
v_stack()
v_flex()
.gap_6()
.p_4()
.child(Label::new(collab_blurb))
.child(
v_stack()
v_flex()
.gap_2()
.child(
Button::new("sign_in", "Sign in")
@ -1832,14 +1832,14 @@ impl CollabPanel {
}
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
v_stack()
v_flex()
.size_full()
.child(list(self.list_state.clone()).full())
.child(
v_stack()
v_flex()
.child(div().mx_2().border_primary(cx).border_t())
.child(
v_stack()
v_flex()
.p_2()
.child(self.render_filter_input(&self.filter_editor, cx)),
),
@ -1961,7 +1961,7 @@ impl CollabPanel {
| Section::Offline => true,
};
h_stack()
h_flex()
.w_full()
.group("section-header")
.child(
@ -2007,7 +2007,7 @@ impl CollabPanel {
.selected(is_selected)
.on_click(cx.listener(move |this, _, cx| this.call(user_id, cx)))
.child(
h_stack()
h_flex()
.w_full()
.justify_between()
.child(Label::new(github_login.clone()))
@ -2105,11 +2105,11 @@ impl CollabPanel {
.indent_step_size(px(20.))
.selected(is_selected)
.child(
h_stack()
h_flex()
.w_full()
.justify_between()
.child(Label::new(github_login.clone()))
.child(h_stack().children(controls)),
.child(h_flex().children(controls)),
)
.start_slot(Avatar::new(user.avatar_uri.clone()))
}
@ -2149,11 +2149,11 @@ impl CollabPanel {
ListItem::new(("channel-invite", channel.id as usize))
.selected(is_selected)
.child(
h_stack()
h_flex()
.w_full()
.justify_between()
.child(Label::new(channel.name.clone()))
.child(h_stack().children(controls)),
.child(h_flex().children(controls)),
)
.start_slot(
Icon::new(IconName::Hash)
@ -2289,21 +2289,21 @@ impl CollabPanel {
.color(Color::Muted),
)
.child(
h_stack()
h_flex()
.id(channel_id as usize)
.child(Label::new(channel.name.clone()))
.children(face_pile.map(|face_pile| face_pile.render(cx))),
),
)
.child(
h_stack()
h_flex()
.absolute()
.right(rems(0.))
.h_full()
// HACK: Without this the channel name clips on top of the icons, but I'm not sure why.
.z_index(10)
.child(
h_stack()
h_flex()
.h_full()
.gap_1()
.px_1()
@ -2410,7 +2410,7 @@ fn render_tree_branch(is_last: bool, overdraw: bool, cx: &mut WindowContext) ->
impl Render for CollabPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
v_flex()
.key_context("CollabPanel")
.on_action(cx.listener(CollabPanel::cancel))
.on_action(cx.listener(CollabPanel::select_next))
@ -2603,7 +2603,7 @@ struct DraggedChannelView {
impl Render for DraggedChannelView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
h_stack()
h_flex()
.font(ui_font)
.bg(cx.theme().colors().background)
.w(self.width)

View file

@ -152,19 +152,19 @@ impl Render for ChannelModal {
let visibility = channel.visibility;
let mode = self.picker.read(cx).delegate.mode;
v_stack()
v_flex()
.key_context("ChannelModal")
.on_action(cx.listener(Self::toggle_mode))
.on_action(cx.listener(Self::dismiss))
.elevation_3(cx)
.w(rems(34.))
.child(
v_stack()
v_flex()
.px_2()
.py_1()
.gap_2()
.child(
h_stack()
h_flex()
.w_px()
.flex_1()
.gap_1()
@ -172,13 +172,13 @@ impl Render for ChannelModal {
.child(Label::new(channel_name)),
)
.child(
h_stack()
h_flex()
.w_full()
.h(rems(22. / 16.))
.justify_between()
.line_height(rems(1.25))
.child(
h_stack()
h_flex()
.gap_2()
.child(
Checkbox::new(
@ -212,7 +212,7 @@ impl Render for ChannelModal {
),
)
.child(
h_stack()
h_flex()
.child(
div()
.id("manage-members")
@ -391,7 +391,7 @@ impl PickerDelegate for ChannelModalDelegate {
.selected(selected)
.start_slot(Avatar::new(user.avatar_uri.clone()))
.child(Label::new(user.github_login.clone()))
.end_slot(h_stack().gap_2().map(|slot| {
.end_slot(h_flex().gap_2().map(|slot| {
match self.mode {
Mode::ManageMembers => slot
.children(

View file

@ -36,17 +36,17 @@ impl ContactFinder {
impl Render for ContactFinder {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
v_flex()
.elevation_3(cx)
.child(
v_stack()
v_flex()
.px_2()
.py_1()
.bg(cx.theme().colors().element_background)
// HACK: Prevent the background color from overflowing the parent container.
.rounded_t(px(8.))
.child(Label::new("Contacts"))
.child(h_stack().child(Label::new("Invite new contacts"))),
.child(h_flex().child(Label::new("Invite new contacts"))),
)
.child(self.picker.clone())
.w(rems(34.))

View file

@ -14,7 +14,7 @@ use rpc::proto;
use std::sync::Arc;
use theme::{ActiveTheme, PlayerColors};
use ui::{
h_stack, popover_menu, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
h_flex, popover_menu, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
IconButton, IconName, TintColor, Tooltip,
};
use util::ResultExt;
@ -58,7 +58,7 @@ impl Render for CollabTitlebarItem {
let client = self.client.clone();
let project_id = self.project.read(cx).remote_id();
h_stack()
h_flex()
.id("titlebar")
.justify_between()
.w_full()
@ -83,7 +83,7 @@ impl Render for CollabTitlebarItem {
})
// left side
.child(
h_stack()
h_flex()
.gap_1()
.children(self.render_project_host(cx))
.child(self.render_project_name(cx))
@ -128,7 +128,7 @@ impl Render for CollabTitlebarItem {
)?;
Some(
v_stack()
v_flex()
.id(("collaborator", collaborator.user.id))
.child(face_pile)
.child(render_color_ribbon(
@ -160,7 +160,7 @@ impl Render for CollabTitlebarItem {
)
// right side
.child(
h_stack()
h_flex()
.gap_1()
.pr_1()
.when_some(room, |this, room| {
@ -634,7 +634,7 @@ impl CollabTitlebarItem {
.trigger(
ButtonLike::new("user-menu")
.child(
h_stack()
h_flex()
.gap_0p5()
.child(Avatar::new(user.avatar_uri.clone()))
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
@ -657,7 +657,7 @@ impl CollabTitlebarItem {
.trigger(
ButtonLike::new("user-menu")
.child(
h_stack()
h_flex()
.gap_0p5()
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
)

View file

@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsStore};
use std::{sync::Arc, time::Duration};
use time::{OffsetDateTime, UtcOffset};
use ui::{h_stack, prelude::*, v_stack, Avatar, Button, Icon, IconButton, IconName, Label};
use ui::{h_flex, prelude::*, v_flex, Avatar, Button, Icon, IconButton, IconName, Label};
use util::{ResultExt, TryFutureExt};
use workspace::{
dock::{DockPosition, Panel, PanelEvent},
@ -251,13 +251,13 @@ impl NotificationPanel {
.rounded_full()
}))
.child(
v_stack()
v_flex()
.gap_1()
.size_full()
.overflow_hidden()
.child(Label::new(text.clone()))
.child(
h_stack()
h_flex()
.child(
Label::new(format_timestamp(
timestamp,
@ -276,7 +276,7 @@ impl NotificationPanel {
)))
} else if needs_response {
Some(
h_stack()
h_flex()
.flex_grow()
.justify_end()
.child(Button::new("decline", "Decline").on_click({
@ -541,10 +541,10 @@ impl NotificationPanel {
impl Render for NotificationPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
v_flex()
.size_full()
.child(
h_stack()
h_flex()
.justify_between()
.px_2()
.py_1()
@ -558,7 +558,7 @@ impl Render for NotificationPanel {
.map(|this| {
if self.client.user_id().is_none() {
this.child(
v_stack()
v_flex()
.gap_2()
.p_4()
.child(
@ -592,7 +592,7 @@ impl Render for NotificationPanel {
)
} else if self.notification_list.item_count() == 0 {
this.child(
v_stack().p_4().child(
v_flex().p_4().child(
div().flex().w_full().items_center().child(
Label::new("You have no notifications.")
.color(Color::Muted)
@ -711,7 +711,7 @@ impl Render for NotificationToast {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let user = self.actor.clone();
h_stack()
h_flex()
.id("notification_panel_toast")
.children(user.map(|user| Avatar::new(user.avatar_uri.clone())))
.child(Label::new(self.text.clone()))

View file

@ -33,7 +33,7 @@ impl ParentElement for CollabNotification {
impl RenderOnce for CollabNotification {
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
h_stack()
h_flex()
.text_ui()
.justify_between()
.size_full()
@ -42,9 +42,9 @@ impl RenderOnce for CollabNotification {
.p_2()
.gap_2()
.child(img(self.avatar_uri).w_12().h_12().rounded_full())
.child(v_stack().overflow_hidden().children(self.children))
.child(v_flex().overflow_hidden().children(self.children))
.child(
v_stack()
v_flex()
.child(self.accept_button)
.child(self.dismiss_button),
)

View file

@ -137,7 +137,7 @@ impl Render for IncomingCallNotification {
move |_, cx| state.respond(false, cx)
}),
)
.child(v_stack().overflow_hidden().child(Label::new(format!(
.child(v_flex().overflow_hidden().child(Label::new(format!(
"{} is sharing a project in Zed",
self.state.call.calling_user.github_login
)))),

View file

@ -24,7 +24,7 @@ impl Render for CollabNotificationStory {
Button::new("decline", "Decline"),
)
.child(
v_stack()
v_flex()
.overflow_hidden()
.child(Label::new("maxdeviant is sharing a project in Zed")),
),