This PR adds a `map` method to the `Component` trait.
`map` is a fully-generalized form of `when`, as `when` can be expressed
in terms of `map`:
```rs
div().map(|this| if condition { then(this) } else { this })
```
This allows us to take advantage of Rust's pattern matching when
building up conditions:
```rs
// Before
div()
.when(self.current_side == PanelSide::Left, |this| this.border_r())
.when(self.current_side == PanelSide::Right, |this| {
this.border_l()
})
.when(self.current_side == PanelSide::Bottom, |this| {
this.border_b().w_full().h(current_size)
})
// After
div()
.map(|this| match self.current_side {
PanelSide::Left => this.border_r(),
PanelSide::Right => this.border_l(),
PanelSide::Bottom => this.border_b().w_full().h(current_size),
})
```
Release Notes:
- N/A
This PR adds a new `ui_font_size` setting that can be used to control
the scale of the entire UI.
We use the value in this setting to set the base rem size of the window.
Release Notes:
- N/A
The entity map needs to be able to distinguish between the case when
the entity_id is waiting to be dropped, and when it is completely gone.
Before 8bc207141, it assumed that entity_ids in dropped_entity_ids could
be re-used. This caused `take_dropped` to error because the slot had
been overwritten. The fix there caused weak handles to allow upgrading
a reference count from 0, which could resurrect items in
`dropped_entity_ids` which caused them to be dropped twice.
We could allow weak items to upgrade from 0, and delete from
dropped_entity_ids, but that seemed more complicated than necessary.
Adds an `Entity` trait for abstracting over `View`s and `Model`s, and
implements it for the `subscribe()` and `observe()` APIs.
The last commit also includes a fun experiment I added, using the
`Result` type to return the owned model handles back to the caller in
the case of downcast failure, inspired by the `binary_search*` methods.
Don't pass a render function separately from the view.
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Antonio <as-cii@zed.dev>