fix: Use show_animated with width persistence for file panel
- Use show_animated instead of show() to maintain egui's animation - Add .default_width() from config - Update config when panel width changes - This should allow the panel to maintain its width after resizing Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
+7
-10
@@ -164,13 +164,11 @@ impl App {
|
|||||||
/// editor rather than leaving an empty column.
|
/// editor rather than leaving an empty column.
|
||||||
pub(super) fn left_pane(&mut self, ctx: &egui::Context) {
|
pub(super) fn left_pane(&mut self, ctx: &egui::Context) {
|
||||||
let show_files = self.config.show_file_panel;
|
let show_files = self.config.show_file_panel;
|
||||||
if show_files {
|
if let Some(response) = egui::SidePanel::left("files")
|
||||||
let panel = egui::SidePanel::left("files")
|
.resizable(true)
|
||||||
.resizable(true)
|
.default_width(self.config.file_panel_width)
|
||||||
.default_width(self.config.file_panel_width)
|
.width_range(260.0..=600.0)
|
||||||
.width_range(260.0..=600.0);
|
.show_animated(ctx, show_files, |ui| {
|
||||||
|
|
||||||
let response = panel.show(ctx, |ui| {
|
|
||||||
// The default theme renders unselected list rows fairly dim; bump
|
// The default theme renders unselected list rows fairly dim; bump
|
||||||
// the widget text colours so file names stay legible (especially in
|
// the widget text colours so file names stay legible (especially in
|
||||||
// dark mode) without affecting the rest of the app.
|
// dark mode) without affecting the rest of the app.
|
||||||
@@ -605,9 +603,8 @@ impl App {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}) {
|
||||||
|
// Update the config with the current panel width
|
||||||
// Update the config with the current panel width if it changed
|
|
||||||
let new_width = response.response.rect.width();
|
let new_width = response.response.rect.width();
|
||||||
if (new_width - self.config.file_panel_width).abs() > 0.1 {
|
if (new_width - self.config.file_panel_width).abs() > 0.1 {
|
||||||
self.config.file_panel_width = new_width;
|
self.config.file_panel_width = new_width;
|
||||||
|
|||||||
Reference in New Issue
Block a user