Adjust list view sizing to match designs
This commit is contained in:
parent
143aa6d32b
commit
61fe3c093d
2 changed files with 8 additions and 30 deletions
|
|
@ -11,8 +11,7 @@ use serde::{Deserialize, Serialize};
|
|||
pub const CONFIG_VERSION: u64 = 1;
|
||||
|
||||
// Default icon sizes
|
||||
const ICON_SIZE_DIALOG: u16 = 16;
|
||||
const ICON_SIZE_LIST: u16 = 32;
|
||||
const ICON_SIZE_LIST: u16 = 24;
|
||||
const ICON_SIZE_GRID: u16 = 64;
|
||||
// TODO: 5 is an arbitrary number. Maybe there's a better icon size max
|
||||
const ICON_SCALE_MAX: u16 = 5;
|
||||
|
|
@ -81,7 +80,6 @@ macro_rules! percent {
|
|||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, CosmicConfigEntry, Deserialize, Serialize)]
|
||||
pub struct IconSizes {
|
||||
pub dialog: NonZeroU16,
|
||||
pub list: NonZeroU16,
|
||||
pub grid: NonZeroU16,
|
||||
}
|
||||
|
|
@ -89,7 +87,6 @@ pub struct IconSizes {
|
|||
impl Default for IconSizes {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
dialog: 100.try_into().unwrap(),
|
||||
list: 100.try_into().unwrap(),
|
||||
grid: 100.try_into().unwrap(),
|
||||
}
|
||||
|
|
@ -97,10 +94,6 @@ impl Default for IconSizes {
|
|||
}
|
||||
|
||||
impl IconSizes {
|
||||
pub fn dialog(&self) -> u16 {
|
||||
percent!(self.dialog, ICON_SIZE_DIALOG) as _
|
||||
}
|
||||
|
||||
pub fn list(&self) -> u16 {
|
||||
percent!(self.list, ICON_SIZE_LIST) as _
|
||||
}
|
||||
|
|
|
|||
29
src/tab.rs
29
src/tab.rs
|
|
@ -237,16 +237,13 @@ pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
|||
|
||||
let mime_guess = MimeGuess::from_path(&path);
|
||||
|
||||
let (icon_handle_dialog, icon_handle_grid, icon_handle_list) = if metadata.is_dir()
|
||||
{
|
||||
let (icon_handle_grid, icon_handle_list) = if metadata.is_dir() {
|
||||
(
|
||||
folder_icon(&path, sizes.dialog()),
|
||||
folder_icon(&path, sizes.grid()),
|
||||
folder_icon(&path, sizes.list()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
mime_icon(&path, sizes.dialog()),
|
||||
mime_icon(&path, sizes.grid()),
|
||||
mime_icon(&path, sizes.list()),
|
||||
)
|
||||
|
|
@ -271,7 +268,6 @@ pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
|||
hidden,
|
||||
path,
|
||||
mime_guess,
|
||||
icon_handle_dialog,
|
||||
icon_handle_grid,
|
||||
icon_handle_list,
|
||||
thumbnail_res_opt: match mime_guess.first() {
|
||||
|
|
@ -338,14 +334,12 @@ pub fn scan_trash(sizes: IconSizes) -> Vec<Item> {
|
|||
|
||||
let mime_guess = MimeGuess::from_path(&path);
|
||||
|
||||
let (icon_handle_dialog, icon_handle_grid, icon_handle_list) = match metadata.size {
|
||||
let (icon_handle_grid, icon_handle_list) = match metadata.size {
|
||||
trash::TrashItemSize::Entries(_) => (
|
||||
folder_icon(&path, sizes.dialog()),
|
||||
folder_icon(&path, sizes.grid()),
|
||||
folder_icon(&path, sizes.list()),
|
||||
),
|
||||
trash::TrashItemSize::Bytes(_) => (
|
||||
mime_icon(&path, sizes.dialog()),
|
||||
mime_icon(&path, sizes.grid()),
|
||||
mime_icon(&path, sizes.list()),
|
||||
),
|
||||
|
|
@ -357,7 +351,6 @@ pub fn scan_trash(sizes: IconSizes) -> Vec<Item> {
|
|||
hidden: false,
|
||||
path,
|
||||
mime_guess,
|
||||
icon_handle_dialog,
|
||||
icon_handle_grid,
|
||||
icon_handle_list,
|
||||
thumbnail_res_opt: Some(Err(())),
|
||||
|
|
@ -439,7 +432,6 @@ pub struct Item {
|
|||
pub hidden: bool,
|
||||
pub path: PathBuf,
|
||||
pub mime_guess: MimeGuess,
|
||||
pub icon_handle_dialog: widget::icon::Handle,
|
||||
pub icon_handle_grid: widget::icon::Handle,
|
||||
pub icon_handle_list: widget::icon::Handle,
|
||||
pub thumbnail_res_opt: Option<Result<image::RgbaImage, ()>>,
|
||||
|
|
@ -698,7 +690,6 @@ impl Tab {
|
|||
thumbnail.height(),
|
||||
thumbnail.as_raw().clone(),
|
||||
);
|
||||
item.icon_handle_dialog = handle.clone();
|
||||
item.icon_handle_grid = handle.clone();
|
||||
item.icon_handle_list = handle;
|
||||
}
|
||||
|
|
@ -1051,17 +1042,10 @@ impl Tab {
|
|||
//TODO: align columns
|
||||
let button = widget::button(
|
||||
widget::row::with_children(vec![
|
||||
if self.dialog.is_some() {
|
||||
widget::icon::icon(item.icon_handle_dialog.clone())
|
||||
.content_fit(ContentFit::Contain)
|
||||
.size(icon_sizes.dialog())
|
||||
.into()
|
||||
} else {
|
||||
widget::icon::icon(item.icon_handle_list.clone())
|
||||
.content_fit(ContentFit::Contain)
|
||||
.size(icon_sizes.list())
|
||||
.into()
|
||||
},
|
||||
widget::icon::icon(item.icon_handle_list.clone())
|
||||
.content_fit(ContentFit::Contain)
|
||||
.size(icon_sizes.list())
|
||||
.into(),
|
||||
widget::text(item.name.clone()).width(Length::Fill).into(),
|
||||
widget::text(modified_text).width(modified_width).into(),
|
||||
widget::text(size_text).width(size_width).into(),
|
||||
|
|
@ -1069,6 +1053,7 @@ impl Tab {
|
|||
.align_items(Alignment::Center)
|
||||
.spacing(space_xxs),
|
||||
)
|
||||
.padding(space_xxs)
|
||||
.style(button_style(item.selected))
|
||||
.on_press(Message::Click(Some(i)));
|
||||
if self.context_menu.is_some() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue