Remove initialize from the Element trait (#3338)
Initially, we imagined registering keyboard handlers in the initialize phase so we would understand the relationships between focus handles during the layout pass, which would allow us to assign assign `focus_in` styles that impact layout. However, we soon realized that many elements aren't created until paint time anyway, such as within the uniform list. Since it's impossible to know prior to paint whether an element contains the focused element, it makes more sense to eliminate the `focus_in` styling helper. Release Notes: - N/A
This commit is contained in:
commit
e5ada92b7b
10 changed files with 147 additions and 316 deletions
|
@ -2398,21 +2398,14 @@ impl Element<Editor> for EditorElement {
|
|||
Some(self.editor_id.into())
|
||||
}
|
||||
|
||||
fn initialize(
|
||||
fn layout(
|
||||
&mut self,
|
||||
editor: &mut Editor,
|
||||
element_state: Option<Self::ElementState>,
|
||||
cx: &mut gpui::ViewContext<Editor>,
|
||||
) -> Self::ElementState {
|
||||
) -> (gpui::LayoutId, Self::ElementState) {
|
||||
editor.style = Some(self.style.clone()); // Long-term, we'd like to eliminate this.
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
editor: &mut Editor,
|
||||
element_state: &mut Self::ElementState,
|
||||
cx: &mut gpui::ViewContext<Editor>,
|
||||
) -> gpui::LayoutId {
|
||||
let rem_size = cx.rem_size();
|
||||
let mut style = Style::default();
|
||||
style.size.width = relative(1.).into();
|
||||
|
@ -2421,7 +2414,8 @@ impl Element<Editor> for EditorElement {
|
|||
EditorMode::AutoHeight { .. } => todo!(),
|
||||
EditorMode::Full => relative(1.).into(),
|
||||
};
|
||||
cx.request_layout(&style, None)
|
||||
let layout_id = cx.request_layout(&style, None);
|
||||
(layout_id, ())
|
||||
}
|
||||
|
||||
fn paint(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue