mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ide: IconDes now shows images as file icons when inserting files
git-svn-id: svn://ultimatepp.org/upp/trunk@8245 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d24186ef7e
commit
b16041c19d
2 changed files with 22 additions and 1 deletions
|
|
@ -38,7 +38,7 @@ ing[@(0.0.255) `&]_path, Image[@(0.0.255) `&]_result)&]
|
|||
for additional resolving of file icon. Note that FileSel, when
|
||||
closed/destroyed, does not wait for this function to finish,
|
||||
so it should not rely on any data outside of function. Only available
|
||||
when MT is active.&]
|
||||
when MT is active.devious &]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:FileSel`:`:Serialize`(Stream`&`): [@(0.0.255) void]_[* Serialize]([_^Stream^ Stream][@(0.0.255) `&
|
||||
|
|
|
|||
|
|
@ -179,6 +179,24 @@ struct ImgPreview : Display {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef _MULTITHREADED
|
||||
static void sLoadImage(const String& path, Image& result)
|
||||
{
|
||||
if(findarg(ToLower(GetFileExt(path)), ".png", ".gif", ".jpeg", ".jpg") < 0)
|
||||
return;
|
||||
FileIn in(path);
|
||||
if(!in)
|
||||
return;
|
||||
One<StreamRaster> r = StreamRaster::OpenAny(in);
|
||||
if(!r)
|
||||
return;
|
||||
Size sz = r->GetSize();
|
||||
if(sz.cx > 80 || sz.cy > 80)
|
||||
return;
|
||||
result = r->GetImage();
|
||||
}
|
||||
#endif
|
||||
|
||||
FileSel& IconDes::ImgFile()
|
||||
{
|
||||
static FileSel sel;
|
||||
|
|
@ -186,6 +204,9 @@ FileSel& IconDes::ImgFile()
|
|||
sel.Type("Image files", "*.png *.bmp *.jpg *.jpeg *.gif");
|
||||
sel.AllFilesType();
|
||||
sel.Multi();
|
||||
#ifdef _MULTITHREADED
|
||||
sel.WhenIconLazy = sLoadImage;
|
||||
#endif
|
||||
sel.Preview(Single<ImgPreview>());
|
||||
}
|
||||
return sel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue