Introduce Panel::can_zoom

This commit is contained in:
Antonio Scandurra 2023-05-15 17:10:30 +02:00
parent ba50b35de6
commit c03e470fe6
3 changed files with 26 additions and 6 deletions

View file

@ -9,11 +9,16 @@ use serde::Deserialize;
use settings::Settings;
use std::rc::Rc;
pub fn init(cx: &mut AppContext) {
cx.capture_action(Dock::toggle_zoom);
}
pub trait Panel: View {
fn position(&self, cx: &WindowContext) -> DockPosition;
fn position_is_valid(&self, position: DockPosition) -> bool;
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>);
fn default_size(&self, cx: &WindowContext) -> f32;
fn can_zoom(&self, cx: &WindowContext) -> bool;
fn icon_path(&self) -> &'static str;
fn icon_tooltip(&self) -> String;
fn icon_label(&self, _: &AppContext) -> Option<String> {
@ -30,6 +35,7 @@ pub trait PanelHandle {
fn position_is_valid(&self, position: DockPosition, cx: &WindowContext) -> bool;
fn set_position(&self, position: DockPosition, cx: &mut WindowContext);
fn default_size(&self, cx: &WindowContext) -> f32;
fn can_zoom(&self, cx: &WindowContext) -> bool;
fn icon_path(&self, cx: &WindowContext) -> &'static str;
fn icon_tooltip(&self, cx: &WindowContext) -> String;
fn icon_label(&self, cx: &WindowContext) -> Option<String>;
@ -61,6 +67,10 @@ where
self.read(cx).default_size(cx)
}
fn can_zoom(&self, cx: &WindowContext) -> bool {
self.read(cx).can_zoom(cx)
}
fn icon_path(&self, cx: &WindowContext) -> &'static str {
self.read(cx).icon_path()
}
@ -313,9 +323,7 @@ impl View for Dock {
.resizable(
self.position.to_resize_handle_side(),
size,
|dock: &mut Self, size, cx| {
dock.resize_active_panel(size, cx);
},
|dock: &mut Self, size, cx| dock.resize_active_panel(size, cx),
)
.into_any()
} else {
@ -526,6 +534,10 @@ pub(crate) mod test {
}
}
fn can_zoom(&self, _cx: &WindowContext) -> bool {
unimplemented!()
}
fn icon_path(&self) -> &'static str {
"icons/test_panel.svg"
}