wip
This commit is contained in:
parent
6c60853842
commit
ba50b35de6
9 changed files with 634 additions and 525 deletions
|
@ -69,6 +69,7 @@ actions!(
|
|||
SplitUp,
|
||||
SplitRight,
|
||||
SplitDown,
|
||||
ToggleZoom,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -91,6 +92,7 @@ const MAX_NAVIGATION_HISTORY_LEN: usize = 1024;
|
|||
pub type BackgroundActions = fn() -> &'static [(&'static str, &'static dyn Action)];
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Pane::toggle_zoom);
|
||||
cx.add_action(|pane: &mut Pane, action: &ActivateItem, cx| {
|
||||
pane.activate_item(action.0, true, true, cx);
|
||||
});
|
||||
|
@ -132,12 +134,15 @@ pub enum Event {
|
|||
Split(SplitDirection),
|
||||
ChangeItemTitle,
|
||||
Focus,
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
}
|
||||
|
||||
pub struct Pane {
|
||||
items: Vec<Box<dyn ItemHandle>>,
|
||||
activation_history: Vec<usize>,
|
||||
is_active: bool,
|
||||
zoomed: bool,
|
||||
active_item_index: usize,
|
||||
last_focused_view_by_item: HashMap<usize, AnyWeakViewHandle>,
|
||||
autoscroll: bool,
|
||||
|
@ -236,6 +241,7 @@ impl Pane {
|
|||
items: Vec::new(),
|
||||
activation_history: Vec::new(),
|
||||
is_active: true,
|
||||
zoomed: false,
|
||||
active_item_index: 0,
|
||||
last_focused_view_by_item: Default::default(),
|
||||
autoscroll: false,
|
||||
|
@ -655,6 +661,14 @@ impl Pane {
|
|||
self.items.iter().position(|i| i.id() == item.id())
|
||||
}
|
||||
|
||||
pub fn toggle_zoom(&mut self, _: &ToggleZoom, cx: &mut ViewContext<Self>) {
|
||||
if self.zoomed {
|
||||
cx.emit(Event::ZoomOut);
|
||||
} else {
|
||||
cx.emit(Event::ZoomIn);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn activate_item(
|
||||
&mut self,
|
||||
index: usize,
|
||||
|
@ -1546,6 +1560,15 @@ impl Pane {
|
|||
.with_background_color(background)
|
||||
.into_any()
|
||||
}
|
||||
|
||||
pub fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
|
||||
self.zoomed = zoomed;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn is_zoomed(&self) -> bool {
|
||||
self.zoomed
|
||||
}
|
||||
}
|
||||
|
||||
impl Entity for Pane {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue