Add image resolution to details
This commit is contained in:
parent
c3658dba5b
commit
eda1189f08
1 changed files with 17 additions and 4 deletions
21
src/tab.rs
21
src/tab.rs
|
|
@ -916,7 +916,7 @@ impl ItemMetadata {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum ItemThumbnail {
|
pub enum ItemThumbnail {
|
||||||
NotImage,
|
NotImage,
|
||||||
Rgba(image::RgbaImage),
|
Rgba(image::RgbaImage, (u32, u32)),
|
||||||
Svg,
|
Svg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -962,7 +962,7 @@ impl Item {
|
||||||
.unwrap_or(&ItemThumbnail::NotImage)
|
.unwrap_or(&ItemThumbnail::NotImage)
|
||||||
{
|
{
|
||||||
ItemThumbnail::NotImage => icon,
|
ItemThumbnail::NotImage => icon,
|
||||||
ItemThumbnail::Rgba(_) => {
|
ItemThumbnail::Rgba(_, _) => {
|
||||||
if let Some(Location::Path(path)) = &self.location_opt {
|
if let Some(Location::Path(path)) = &self.location_opt {
|
||||||
widget::image(widget::image::Handle::from_path(path)).into()
|
widget::image(widget::image::Handle::from_path(path)).into()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1130,6 +1130,16 @@ impl Item {
|
||||||
//TODO: other metadata types
|
//TODO: other metadata types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
match self
|
||||||
|
.thumbnail_opt
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(&ItemThumbnail::NotImage)
|
||||||
|
{
|
||||||
|
ItemThumbnail::Rgba(_, (width, height)) => {
|
||||||
|
details = details.push(widget::text(format!("{}x{}", width, height)));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
column = column.push(details);
|
column = column.push(details);
|
||||||
|
|
||||||
if let Some(path) = self.path_opt() {
|
if let Some(path) = self.path_opt() {
|
||||||
|
|
@ -2168,7 +2178,7 @@ impl Tab {
|
||||||
let location = Location::Path(path);
|
let location = Location::Path(path);
|
||||||
for item in items.iter_mut() {
|
for item in items.iter_mut() {
|
||||||
if item.location_opt.as_ref() == Some(&location) {
|
if item.location_opt.as_ref() == Some(&location) {
|
||||||
if let ItemThumbnail::Rgba(rgba) = &thumbnail {
|
if let ItemThumbnail::Rgba(rgba, _) = &thumbnail {
|
||||||
//TODO: pass handles already generated to avoid blocking main thread
|
//TODO: pass handles already generated to avoid blocking main thread
|
||||||
let handle = widget::icon::from_raster_pixels(
|
let handle = widget::icon::from_raster_pixels(
|
||||||
rgba.width(),
|
rgba.width(),
|
||||||
|
|
@ -3691,7 +3701,10 @@ impl Tab {
|
||||||
(ICON_SIZE_GRID * ICON_SCALE_MAX) as u32;
|
(ICON_SIZE_GRID * ICON_SCALE_MAX) as u32;
|
||||||
let thumbnail =
|
let thumbnail =
|
||||||
image.thumbnail(thumbnail_size, thumbnail_size);
|
image.thumbnail(thumbnail_size, thumbnail_size);
|
||||||
ItemThumbnail::Rgba(thumbnail.to_rgba8())
|
ItemThumbnail::Rgba(
|
||||||
|
thumbnail.to_rgba8(),
|
||||||
|
(image.width(), image.height()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to decode {:?}: {}", path, err);
|
log::warn!("failed to decode {:?}: {}", path, err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue