From b16041c19dbd0bfa48a43935830517a2e259abed Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 8 Mar 2015 19:50:20 +0000 Subject: [PATCH] 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 --- uppsrc/CtrlLib/src.tpp/FileSel$en-us.tpp | 2 +- uppsrc/IconDes/List.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/uppsrc/CtrlLib/src.tpp/FileSel$en-us.tpp b/uppsrc/CtrlLib/src.tpp/FileSel$en-us.tpp index 52303bb51..410c846f7 100644 --- a/uppsrc/CtrlLib/src.tpp/FileSel$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/FileSel$en-us.tpp @@ -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) `& diff --git a/uppsrc/IconDes/List.cpp b/uppsrc/IconDes/List.cpp index 5a90192cb..010b9b49b 100644 --- a/uppsrc/IconDes/List.cpp +++ b/uppsrc/IconDes/List.cpp @@ -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 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()); } return sel;