Rename build_view
to new_view
and build_model
to new_model
The word "new" is shorter and blends in with `new` constructors that are common in Rust. Been meaning to do this for a while.
This commit is contained in:
parent
219999cd8d
commit
db1cf8f6e1
97 changed files with 470 additions and 494 deletions
|
@ -11,8 +11,8 @@ pub struct AutoHeightEditorStory {
|
|||
impl AutoHeightEditorStory {
|
||||
pub fn new(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.bind_keys([KeyBinding::new("enter", editor::Newline, Some("Editor"))]);
|
||||
cx.build_view(|cx| Self {
|
||||
editor: cx.build_view(|cx| {
|
||||
cx.new_view(|cx| Self {
|
||||
editor: cx.new_view(|cx| {
|
||||
let mut editor = Editor::auto_height(3, cx);
|
||||
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
|
||||
editor
|
||||
|
|
|
@ -20,7 +20,7 @@ impl FocusStory {
|
|||
KeyBinding::new("cmd-c", ActionC, None),
|
||||
]);
|
||||
|
||||
cx.build_view(move |cx| {
|
||||
cx.new_view(move |cx| {
|
||||
let parent_focus = cx.focus_handle();
|
||||
let child_1_focus = cx.focus_handle();
|
||||
let child_2_focus = cx.focus_handle();
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct KitchenSinkStory;
|
|||
|
||||
impl KitchenSinkStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|_cx| Self)
|
||||
cx.new_view(|_cx| Self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ impl PickerDelegate for Delegate {
|
|||
|
||||
impl PickerStory {
|
||||
pub fn new(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
cx.bind_keys([
|
||||
KeyBinding::new("up", menu::SelectPrev, Some("picker")),
|
||||
KeyBinding::new("pageup", menu::SelectFirst, Some("picker")),
|
||||
|
@ -136,7 +136,7 @@ impl PickerStory {
|
|||
]);
|
||||
|
||||
PickerStory {
|
||||
picker: cx.build_view(|cx| {
|
||||
picker: cx.new_view(|cx| {
|
||||
let mut delegate = Delegate::new(&[
|
||||
"Baguette (France)",
|
||||
"Baklava (Turkey)",
|
||||
|
|
|
@ -6,7 +6,7 @@ pub struct ScrollStory;
|
|||
|
||||
impl ScrollStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<ScrollStory> {
|
||||
cx.build_view(|_cx| ScrollStory)
|
||||
cx.new_view(|_cx| ScrollStory)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct TextStory;
|
|||
|
||||
impl TextStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|_cx| Self)
|
||||
cx.new_view(|_cx| Self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,30 +42,28 @@ impl ComponentStory {
|
|||
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
|
||||
match self {
|
||||
Self::AutoHeightEditor => AutoHeightEditorStory::new(cx).into(),
|
||||
Self::Avatar => cx.build_view(|_| ui::AvatarStory).into(),
|
||||
Self::Button => cx.build_view(|_| ui::ButtonStory).into(),
|
||||
Self::Checkbox => cx.build_view(|_| ui::CheckboxStory).into(),
|
||||
Self::ContextMenu => cx.build_view(|_| ui::ContextMenuStory).into(),
|
||||
Self::Cursor => cx.build_view(|_| crate::stories::CursorStory).into(),
|
||||
Self::Disclosure => cx.build_view(|_| ui::DisclosureStory).into(),
|
||||
Self::Avatar => cx.new_view(|_| ui::AvatarStory).into(),
|
||||
Self::Button => cx.new_view(|_| ui::ButtonStory).into(),
|
||||
Self::Checkbox => cx.new_view(|_| ui::CheckboxStory).into(),
|
||||
Self::ContextMenu => cx.new_view(|_| ui::ContextMenuStory).into(),
|
||||
Self::Cursor => cx.new_view(|_| crate::stories::CursorStory).into(),
|
||||
Self::Disclosure => cx.new_view(|_| ui::DisclosureStory).into(),
|
||||
Self::Focus => FocusStory::view(cx).into(),
|
||||
Self::Icon => cx.build_view(|_| ui::IconStory).into(),
|
||||
Self::IconButton => cx.build_view(|_| ui::IconButtonStory).into(),
|
||||
Self::Keybinding => cx.build_view(|_| ui::KeybindingStory).into(),
|
||||
Self::Label => cx.build_view(|_| ui::LabelStory).into(),
|
||||
Self::List => cx.build_view(|_| ui::ListStory).into(),
|
||||
Self::ListHeader => cx.build_view(|_| ui::ListHeaderStory).into(),
|
||||
Self::ListItem => cx.build_view(|_| ui::ListItemStory).into(),
|
||||
Self::OverflowScroll => cx
|
||||
.build_view(|_| crate::stories::OverflowScrollStory)
|
||||
.into(),
|
||||
Self::Icon => cx.new_view(|_| ui::IconStory).into(),
|
||||
Self::IconButton => cx.new_view(|_| ui::IconButtonStory).into(),
|
||||
Self::Keybinding => cx.new_view(|_| ui::KeybindingStory).into(),
|
||||
Self::Label => cx.new_view(|_| ui::LabelStory).into(),
|
||||
Self::List => cx.new_view(|_| ui::ListStory).into(),
|
||||
Self::ListHeader => cx.new_view(|_| ui::ListHeaderStory).into(),
|
||||
Self::ListItem => cx.new_view(|_| ui::ListItemStory).into(),
|
||||
Self::OverflowScroll => cx.new_view(|_| crate::stories::OverflowScrollStory).into(),
|
||||
Self::Scroll => ScrollStory::view(cx).into(),
|
||||
Self::Text => TextStory::view(cx).into(),
|
||||
Self::Tab => cx.build_view(|_| ui::TabStory).into(),
|
||||
Self::TabBar => cx.build_view(|_| ui::TabBarStory).into(),
|
||||
Self::ToggleButton => cx.build_view(|_| ui::ToggleButtonStory).into(),
|
||||
Self::ViewportUnits => cx.build_view(|_| crate::stories::ViewportUnitsStory).into(),
|
||||
Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),
|
||||
Self::Tab => cx.new_view(|_| ui::TabStory).into(),
|
||||
Self::TabBar => cx.new_view(|_| ui::TabBarStory).into(),
|
||||
Self::ToggleButton => cx.new_view(|_| ui::ToggleButtonStory).into(),
|
||||
Self::ViewportUnits => cx.new_view(|_| crate::stories::ViewportUnitsStory).into(),
|
||||
Self::ZIndex => cx.new_view(|_| ZIndexStory).into(),
|
||||
Self::Picker => PickerStory::new(cx).into(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ fn main() {
|
|||
let ui_font_size = ThemeSettings::get_global(cx).ui_font_size;
|
||||
cx.set_rem_size(ui_font_size);
|
||||
|
||||
cx.build_view(|cx| StoryWrapper::new(selector.story(cx)))
|
||||
cx.new_view(|cx| StoryWrapper::new(selector.story(cx)))
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue