WIP working on resizable dock
This commit is contained in:
parent
1dfa711d2e
commit
f2b72eb6d2
15 changed files with 435 additions and 160 deletions
|
@ -1960,6 +1960,7 @@ impl MutableAppContext {
|
|||
{
|
||||
let mut app = self.upgrade();
|
||||
let presenter = Rc::downgrade(&presenter);
|
||||
|
||||
window.on_event(Box::new(move |event| {
|
||||
app.update(|cx| {
|
||||
if let Some(presenter) = presenter.upgrade() {
|
||||
|
@ -4089,9 +4090,10 @@ impl<'a, V: View> RenderContext<'a, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn element_state<Tag: 'static, T: 'static + Default>(
|
||||
pub fn element_state<Tag: 'static, T: 'static>(
|
||||
&mut self,
|
||||
element_id: usize,
|
||||
initial: T,
|
||||
) -> ElementStateHandle<T> {
|
||||
let id = ElementStateId {
|
||||
view_id: self.view_id(),
|
||||
|
@ -4101,9 +4103,16 @@ impl<'a, V: View> RenderContext<'a, V> {
|
|||
self.cx
|
||||
.element_states
|
||||
.entry(id)
|
||||
.or_insert_with(|| Box::new(T::default()));
|
||||
.or_insert_with(|| Box::new(initial));
|
||||
ElementStateHandle::new(id, self.frame_count, &self.cx.ref_counts)
|
||||
}
|
||||
|
||||
pub fn default_element_state<Tag: 'static, T: 'static + Default>(
|
||||
&mut self,
|
||||
element_id: usize,
|
||||
) -> ElementStateHandle<T> {
|
||||
self.element_state::<Tag, T>(element_id, T::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<AppContext> for &AppContext {
|
||||
|
@ -5226,6 +5235,10 @@ impl<T: 'static> ElementStateHandle<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> ElementStateId {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn read<'a>(&self, cx: &'a AppContext) -> &'a T {
|
||||
cx.element_states
|
||||
.get(&self.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue