@@ -2,7 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | use crate::core::{EntryType, FileEntry, SortDirection, SortOrder}; |
| 4 | 4 | use gartk_core::{Color, Modifiers, Point, Rect}; |
| 5 | | -use gartk_render::{Renderer, TextStyle}; |
| 5 | +use gartk_render::{Renderer, TextAlign, TextStyle}; |
| 6 | 6 | use std::collections::HashSet; |
| 7 | 7 | |
| 8 | 8 | /// Size of each grid cell. |
@@ -452,18 +452,20 @@ impl GridView { |
| 452 | 452 | .font_size(theme.font_size - 1.0) |
| 453 | 453 | .color(name_color); |
| 454 | 454 | |
| 455 | | - // Truncate name if too long |
| 456 | | - let max_chars = (cell.width / 7) as usize; |
| 457 | | - let display_name = if entry.name.len() > max_chars { |
| 458 | | - format!("{}...", &entry.name[..max_chars.saturating_sub(3)]) |
| 459 | | - } else { |
| 460 | | - entry.name.clone() |
| 461 | | - }; |
| 462 | | - |
| 463 | | - // Center text horizontally below icon |
| 464 | | - let center_x = cell.x + cell.width as i32 / 2; |
| 465 | | - let center_y = cell.y + ICON_SIZE as i32 + 16; |
| 466 | | - renderer.text_centered(&display_name, Point::new(center_x, center_y), &name_style)?; |
| 455 | + // Use Pango CENTER alignment for proper text centering (like Dolphin/Nautilus) |
| 456 | + let name_style = name_style.clone() |
| 457 | + .align(TextAlign::Center) |
| 458 | + .ellipsize(true) |
| 459 | + .max_width((cell.width - 8) as i32); |
| 460 | + |
| 461 | + // Rectangle for the text area below the icon |
| 462 | + let text_rect = Rect::new( |
| 463 | + cell.x + 4, |
| 464 | + cell.y + ICON_SIZE as i32 + 8, |
| 465 | + cell.width - 8, |
| 466 | + cell.height - ICON_SIZE - 12, |
| 467 | + ); |
| 468 | + renderer.text_in_rect(&entry.name, text_rect, &name_style)?; |
| 467 | 469 | } |
| 468 | 470 | |
| 469 | 471 | // Draw rubber band selection rectangle |