wip
This commit is contained in:
parent
8d0905e479
commit
efce38fce2
5 changed files with 32 additions and 26 deletions
|
@ -164,6 +164,11 @@ impl AnyModel {
|
||||||
self.entity_id
|
self.entity_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo!() added for populating `ProjectItemBuilders` in `load_path` method
|
||||||
|
pub fn type_id(&self) -> TypeId {
|
||||||
|
self.entity_type
|
||||||
|
}
|
||||||
|
|
||||||
pub fn downgrade(&self) -> AnyWeakModel {
|
pub fn downgrade(&self) -> AnyWeakModel {
|
||||||
AnyWeakModel {
|
AnyWeakModel {
|
||||||
entity_id: self.entity_id,
|
entity_id: self.entity_id,
|
||||||
|
|
|
@ -18,7 +18,10 @@ use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
cmp, fmt, mem,
|
cmp, fmt, mem,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{atomic::AtomicUsize, Arc},
|
sync::{
|
||||||
|
atomic::{AtomicUsize, Ordering},
|
||||||
|
Arc,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]
|
#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]
|
||||||
|
@ -168,7 +171,7 @@ pub struct Pane {
|
||||||
// zoomed: bool,
|
// zoomed: bool,
|
||||||
active_item_index: usize,
|
active_item_index: usize,
|
||||||
// last_focused_view_by_item: HashMap<usize, AnyWeakViewHandle>,
|
// last_focused_view_by_item: HashMap<usize, AnyWeakViewHandle>,
|
||||||
// autoscroll: bool,
|
autoscroll: bool,
|
||||||
nav_history: NavHistory,
|
nav_history: NavHistory,
|
||||||
toolbar: View<Toolbar>,
|
toolbar: View<Toolbar>,
|
||||||
// tab_bar_context_menu: TabBarContextMenu,
|
// tab_bar_context_menu: TabBarContextMenu,
|
||||||
|
@ -327,7 +330,7 @@ impl Pane {
|
||||||
// zoomed: false,
|
// zoomed: false,
|
||||||
active_item_index: 0,
|
active_item_index: 0,
|
||||||
// last_focused_view_by_item: Default::default(),
|
// last_focused_view_by_item: Default::default(),
|
||||||
// autoscroll: false,
|
autoscroll: false,
|
||||||
nav_history: NavHistory(Arc::new(Mutex::new(NavHistoryState {
|
nav_history: NavHistory(Arc::new(Mutex::new(NavHistoryState {
|
||||||
mode: NavigationMode::Normal,
|
mode: NavigationMode::Normal,
|
||||||
backward_stack: Default::default(),
|
backward_stack: Default::default(),
|
||||||
|
@ -607,9 +610,9 @@ impl Pane {
|
||||||
cx.emit(Event::AddItem { item });
|
cx.emit(Event::AddItem { item });
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn items_len(&self) -> usize {
|
pub fn items_len(&self) -> usize {
|
||||||
// self.items.len()
|
self.items.len()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn items(&self) -> impl Iterator<Item = &Box<dyn ItemHandle>> + DoubleEndedIterator {
|
// pub fn items(&self) -> impl Iterator<Item = &Box<dyn ItemHandle>> + DoubleEndedIterator {
|
||||||
// self.items.iter()
|
// self.items.iter()
|
||||||
|
@ -621,9 +624,9 @@ impl Pane {
|
||||||
// .filter_map(|item| item.as_any().clone().downcast())
|
// .filter_map(|item| item.as_any().clone().downcast())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn active_item(&self) -> Option<Box<dyn ItemHandle>> {
|
pub fn active_item(&self) -> Option<Box<dyn ItemHandle>> {
|
||||||
// self.items.get(self.active_item_index).cloned()
|
self.items.get(self.active_item_index).cloned()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Vector2F> {
|
// pub fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Vector2F> {
|
||||||
// self.items
|
// self.items
|
||||||
|
@ -749,7 +752,8 @@ impl Pane {
|
||||||
save_intent: SaveIntent,
|
save_intent: SaveIntent,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
self.close_items(cx, save_intent, move |view_id| view_id == item_id_to_close)
|
// self.close_items(cx, save_intent, move |view_id| view_id == item_id_to_close)
|
||||||
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn close_inactive_items(
|
// pub fn close_inactive_items(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{AppState, FollowerState, Pane, Workspace};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use call2::ActiveCall;
|
use call2::ActiveCall;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui2::{size, AnyElement, AnyView, Bounds, Handle, Pixels, Point, View, ViewContext};
|
use gpui2::{size, AnyElement, AnyView, Bounds, Handle, Model, Pixels, Point, View, ViewContext};
|
||||||
use project2::Project;
|
use project2::Project;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||||
|
@ -91,10 +91,10 @@ impl PaneGroup {
|
||||||
|
|
||||||
pub(crate) fn render(
|
pub(crate) fn render(
|
||||||
&self,
|
&self,
|
||||||
project: &Handle<Project>,
|
project: &Model<Project>,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
follower_states: &HashMap<View<Pane>, FollowerState>,
|
follower_states: &HashMap<View<Pane>, FollowerState>,
|
||||||
active_call: Option<&Handle<ActiveCall>>,
|
active_call: Option<&Model<ActiveCall>>,
|
||||||
active_pane: &View<Pane>,
|
active_pane: &View<Pane>,
|
||||||
zoomed: Option<&AnyView>,
|
zoomed: Option<&AnyView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
|
@ -120,7 +120,7 @@ impl PaneGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub(crate) enum Member {
|
pub(crate) enum Member {
|
||||||
Axis(PaneAxis),
|
Axis(PaneAxis),
|
||||||
Pane(View<Pane>),
|
Pane(View<Pane>),
|
||||||
|
@ -153,11 +153,11 @@ impl Member {
|
||||||
|
|
||||||
pub fn render(
|
pub fn render(
|
||||||
&self,
|
&self,
|
||||||
project: &Handle<Project>,
|
project: &Model<Project>,
|
||||||
basis: usize,
|
basis: usize,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
follower_states: &HashMap<View<Pane>, FollowerState>,
|
follower_states: &HashMap<View<Pane>, FollowerState>,
|
||||||
active_call: Option<&Handle<ActiveCall>>,
|
active_call: Option<&Model<ActiveCall>>,
|
||||||
active_pane: &View<Pane>,
|
active_pane: &View<Pane>,
|
||||||
zoomed: Option<&AnyView>,
|
zoomed: Option<&AnyView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
|
@ -470,11 +470,11 @@ impl PaneAxis {
|
||||||
|
|
||||||
fn render(
|
fn render(
|
||||||
&self,
|
&self,
|
||||||
project: &Handle<Project>,
|
project: &Model<Project>,
|
||||||
basis: usize,
|
basis: usize,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
follower_states: &HashMap<View<Pane>, FollowerState>,
|
follower_states: &HashMap<View<Pane>, FollowerState>,
|
||||||
active_call: Option<&Handle<ActiveCall>>,
|
active_call: Option<&Model<ActiveCall>>,
|
||||||
active_pane: &View<Pane>,
|
active_pane: &View<Pane>,
|
||||||
zoomed: Option<&AnyView>,
|
zoomed: Option<&AnyView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use db2::sqlez::{
|
||||||
bindable::{Bind, Column, StaticColumnCount},
|
bindable::{Bind, Column, StaticColumnCount},
|
||||||
statement::Statement,
|
statement::Statement,
|
||||||
};
|
};
|
||||||
use gpui2::{AsyncAppContext, AsyncWindowContext, Handle, Task, View, WeakView, WindowBounds};
|
use gpui2::{AsyncAppContext, AsyncWindowContext, Model, Task, View, WeakView, WindowBounds};
|
||||||
use project2::Project;
|
use project2::Project;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -151,7 +151,7 @@ impl SerializedPaneGroup {
|
||||||
#[async_recursion(?Send)]
|
#[async_recursion(?Send)]
|
||||||
pub(crate) async fn deserialize(
|
pub(crate) async fn deserialize(
|
||||||
self,
|
self,
|
||||||
project: &Handle<Project>,
|
project: &Model<Project>,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
workspace: &WeakView<Workspace>,
|
workspace: &WeakView<Workspace>,
|
||||||
cx: &mut AsyncWindowContext,
|
cx: &mut AsyncWindowContext,
|
||||||
|
@ -200,10 +200,7 @@ impl SerializedPaneGroup {
|
||||||
.await
|
.await
|
||||||
.log_err()?;
|
.log_err()?;
|
||||||
|
|
||||||
if pane
|
if pane.update(cx, |pane, _| pane.items_len() != 0).log_err()? {
|
||||||
.read_with(cx, |pane, _| pane.items_len() != 0)
|
|
||||||
.log_err()?
|
|
||||||
{
|
|
||||||
let pane = pane.upgrade()?;
|
let pane = pane.upgrade()?;
|
||||||
Some((Member::Pane(pane.clone()), active.then(|| pane), new_items))
|
Some((Member::Pane(pane.clone()), active.then(|| pane), new_items))
|
||||||
} else {
|
} else {
|
||||||
|
@ -231,7 +228,7 @@ impl SerializedPane {
|
||||||
|
|
||||||
pub async fn deserialize_to(
|
pub async fn deserialize_to(
|
||||||
&self,
|
&self,
|
||||||
project: &Handle<Project>,
|
project: &Model<Project>,
|
||||||
pane: &WeakView<Pane>,
|
pane: &WeakView<Pane>,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
workspace: &WeakView<Workspace>,
|
workspace: &WeakView<Workspace>,
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Settings for WorkspaceSettings {
|
||||||
fn load(
|
fn load(
|
||||||
default_value: &Self::FileContent,
|
default_value: &Self::FileContent,
|
||||||
user_values: &[&Self::FileContent],
|
user_values: &[&Self::FileContent],
|
||||||
_: &gpui2::AppContext,
|
_: &mut gpui2::AppContext,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
Self::load_via_json_merge(default_value, user_values)
|
Self::load_via_json_merge(default_value, user_values)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue