Prevent panels from getting so small they can't be resized (#3788)
This also switches to using `Pixels` instead of `f32` to store the panel size everywhere. Release Notes: - N/A
This commit is contained in:
@@ -51,7 +51,7 @@ pub struct ChatPanel {
|
||||
input_editor: View<MessageEditor>,
|
||||
local_timezone: UtcOffset,
|
||||
fs: Arc<dyn Fs>,
|
||||
width: Option<f32>,
|
||||
width: Option<Pixels>,
|
||||
active: bool,
|
||||
pending_serialization: Task<Option<()>>,
|
||||
subscriptions: Vec<gpui::Subscription>,
|
||||
@@ -62,7 +62,7 @@ pub struct ChatPanel {
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct SerializedChatPanel {
|
||||
width: Option<f32>,
|
||||
width: Option<Pixels>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -584,12 +584,12 @@ impl Panel for ChatPanel {
|
||||
});
|
||||
}
|
||||
|
||||
fn size(&self, cx: &gpui::WindowContext) -> f32 {
|
||||
fn size(&self, cx: &gpui::WindowContext) -> Pixels {
|
||||
self.width
|
||||
.unwrap_or_else(|| ChatPanelSettings::get_global(cx).default_width)
|
||||
}
|
||||
|
||||
fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
|
||||
fn set_size(&mut self, size: Option<Pixels>, cx: &mut ViewContext<Self>) {
|
||||
self.width = size;
|
||||
self.serialize(cx);
|
||||
cx.notify();
|
||||
|
||||
@@ -2314,15 +2314,13 @@ impl Panel for CollabPanel {
|
||||
);
|
||||
}
|
||||
|
||||
fn size(&self, cx: &gpui::WindowContext) -> f32 {
|
||||
self.width.map_or_else(
|
||||
|| CollaborationPanelSettings::get_global(cx).default_width,
|
||||
|width| width.0,
|
||||
)
|
||||
fn size(&self, cx: &gpui::WindowContext) -> Pixels {
|
||||
self.width
|
||||
.unwrap_or_else(|| CollaborationPanelSettings::get_global(cx).default_width)
|
||||
}
|
||||
|
||||
fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
|
||||
self.width = size.map(|s| px(s));
|
||||
fn set_size(&mut self, size: Option<Pixels>, cx: &mut ViewContext<Self>) {
|
||||
self.width = size;
|
||||
self.serialize(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ pub struct NotificationPanel {
|
||||
channel_store: Model<ChannelStore>,
|
||||
notification_store: Model<NotificationStore>,
|
||||
fs: Arc<dyn Fs>,
|
||||
width: Option<f32>,
|
||||
width: Option<Pixels>,
|
||||
active: bool,
|
||||
notification_list: ListState,
|
||||
pending_serialization: Task<Option<()>>,
|
||||
@@ -51,7 +51,7 @@ pub struct NotificationPanel {
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct SerializedNotificationPanel {
|
||||
width: Option<f32>,
|
||||
width: Option<Pixels>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -639,12 +639,12 @@ impl Panel for NotificationPanel {
|
||||
);
|
||||
}
|
||||
|
||||
fn size(&self, cx: &gpui::WindowContext) -> f32 {
|
||||
fn size(&self, cx: &gpui::WindowContext) -> Pixels {
|
||||
self.width
|
||||
.unwrap_or_else(|| NotificationPanelSettings::get_global(cx).default_width)
|
||||
}
|
||||
|
||||
fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
|
||||
fn set_size(&mut self, size: Option<Pixels>, cx: &mut ViewContext<Self>) {
|
||||
self.width = size;
|
||||
self.serialize(cx);
|
||||
cx.notify();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use anyhow;
|
||||
use gpui::Pixels;
|
||||
use schemars::JsonSchema;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use settings::Settings;
|
||||
@@ -8,21 +9,21 @@ use workspace::dock::DockPosition;
|
||||
pub struct CollaborationPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: f32,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct ChatPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: f32,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct NotificationPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: f32,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user