tabs names fix

This commit is contained in:
2025-12-09 18:31:25 +01:00
parent 8360d0d9b4
commit cc4fad4532

View File

@@ -29,16 +29,36 @@ pub fn render_tabs_panel(
ui.horizontal(|ui| { ui.horizontal(|ui| {
for (idx, tab) in tabs.iter().enumerate() { for (idx, tab) in tabs.iter().enumerate() {
let is_active = idx == *active_tab_index; let is_active = idx == *active_tab_index;
let button_text = if is_active { let filename = tab.filename();
egui::RichText::new(format!("📄 {}", tab.filename())).strong()
// Truncate filename if too long (max 20 characters)
let display_name = if filename.len() > 20 {
format!("{}...", &filename[..17])
} else { } else {
egui::RichText::new(format!("📄 {}", tab.filename())) filename.clone()
}; };
if ui.selectable_label(is_active, button_text).clicked() { let button_text = if is_active {
egui::RichText::new(format!("📄 {}", display_name)).strong()
} else {
egui::RichText::new(format!("📄 {}", display_name))
};
// Fixed width for tab label (150 pixels)
let tab_response = ui.add_sized(
[150.0, ui.available_height()],
egui::SelectableLabel::new(is_active, button_text)
);
if tab_response.clicked() {
*active_tab_index = idx; *active_tab_index = idx;
} }
// Show full filename on hover
if filename.len() > 20 {
tab_response.on_hover_text(&filename);
}
if ui.small_button("").clicked() { if ui.small_button("").clicked() {
*on_close_tab = Some(idx); *on_close_tab = Some(idx);
} }