Use Pixels instead of f32 for panel size

This commit is contained in:
Antonio Scandurra 2023-12-22 18:26:33 +01:00
parent 54e45306c5
commit 3715ddfa74
12 changed files with 69 additions and 72 deletions

View file

@ -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();