@@ -125,7 +125,7 @@ impl Default for InformationPanel {
125125 Box :: new ( |ui : & mut Ui , item : & InfoPanelEntry | {
126126 if let Some ( mut content) = item. content ( ) {
127127 egui:: ScrollArea :: vertical ( )
128- . max_height ( 100.0 )
128+ . max_height ( ui . available_height ( ) )
129129 . show ( ui, |ui| {
130130 ui. add ( egui:: TextEdit :: multiline ( & mut content) . code_editor ( ) ) ;
131131 } ) ;
@@ -180,23 +180,12 @@ impl InformationPanel {
180180 item : & InfoPanelEntry ,
181181 stored_images : & mut IndexSet < String > ,
182182 ) {
183- ui. label ( "Image" ) ;
184183 stored_images. insert ( format ! ( "{}" , item. directory_entry. as_path( ) . display( ) ) ) ;
185184 let image = egui:: Image :: new ( format ! (
186185 "file://{}" ,
187186 item. directory_entry. as_path( ) . display( )
188187 ) ) ;
189- let size = Vec2 {
190- x : ui. available_width ( ) ,
191- y : ui. available_width ( ) / 4.0 * 3.0 ,
192- } ;
193- ui. allocate_ui_with_layout (
194- size,
195- Layout :: centered_and_justified ( Direction :: TopDown ) ,
196- |ui| {
197- ui. add ( image) ;
198- } ,
199- ) ;
188+ ui. add ( image) ;
200189 }
201190
202191 /// Adds support for previewing a custom file type.
@@ -299,49 +288,58 @@ impl InformationPanel {
299288 }
300289
301290 fn display_preview ( & mut self , ui : & mut Ui , item : & DirectoryEntry ) {
302- if item. is_dir ( ) {
303- // show folder icon
304- ui. vertical_centered ( |ui| {
305- ui. label ( egui:: RichText :: from ( item. icon ( ) ) . size ( ui. available_width ( ) / 3.0 ) ) ;
306- } ) ;
307- } else {
308- // Display file content preview based on its extension
309- if let Some ( ext) = item. as_path ( ) . extension ( ) . and_then ( |ext| ext. to_str ( ) ) {
310- if let Some ( panel_entry) = & self . panel_entry {
311- if let Some ( preview_handler) =
312- self . supported_preview_files . get_mut ( & ext. to_lowercase ( ) )
313- {
314- preview_handler ( ui, panel_entry) ;
315- } else if let Some ( preview_handler) =
316- self . supported_preview_images . get_mut ( & ext. to_lowercase ( ) )
317- {
318- preview_handler ( ui, panel_entry, & mut self . stored_images ) ;
319- let number_of_stored_images = self . stored_images . len ( ) ;
320- if number_of_stored_images > 10 {
321- self . forget_last_stored_image ( ui) ;
291+ let size = Vec2 {
292+ x : ui. available_width ( ) ,
293+ y : ui. available_width ( ) / 4.0 * 3.0 ,
294+ } ;
295+ ui. allocate_ui_with_layout (
296+ size,
297+ Layout :: centered_and_justified ( Direction :: TopDown ) ,
298+ |ui| {
299+ if item. is_dir ( ) {
300+ // show folder icon
301+ ui. label ( egui:: RichText :: from ( item. icon ( ) ) . size ( ui. available_width ( ) / 3.0 ) ) ;
302+ } else {
303+ // Display file content preview based on its extension
304+ if let Some ( ext) = item. as_path ( ) . extension ( ) . and_then ( |ext| ext. to_str ( ) ) {
305+ if let Some ( panel_entry) = & self . panel_entry {
306+ if let Some ( preview_handler) =
307+ self . supported_preview_files . get_mut ( & ext. to_lowercase ( ) )
308+ {
309+ preview_handler ( ui, panel_entry) ;
310+ } else if let Some ( preview_handler) =
311+ self . supported_preview_images . get_mut ( & ext. to_lowercase ( ) )
312+ {
313+ preview_handler ( ui, panel_entry, & mut self . stored_images ) ;
314+ let number_of_stored_images = self . stored_images . len ( ) ;
315+ if number_of_stored_images > 10 {
316+ self . forget_last_stored_image ( ui) ;
317+ }
318+ } else if let Some ( mut content) = panel_entry. content ( ) {
319+ egui:: ScrollArea :: vertical ( )
320+ . max_height ( ui. available_height ( ) )
321+ . show ( ui, |ui| {
322+ ui. add (
323+ egui:: TextEdit :: multiline ( & mut content) . code_editor ( ) ,
324+ ) ;
325+ } ) ;
326+ } else {
327+ // if no preview is available, show icon
328+ ui. label (
329+ egui:: RichText :: from ( item. icon ( ) )
330+ . size ( ui. available_width ( ) / 3.0 ) ,
331+ ) ;
332+ }
322333 }
323- } else if let Some ( mut content) = panel_entry. content ( ) {
324- egui:: ScrollArea :: vertical ( )
325- . max_height ( ui. available_width ( ) / 3.0 )
326- . show ( ui, |ui| {
327- ui. add ( egui:: TextEdit :: multiline ( & mut content) . code_editor ( ) ) ;
328- } ) ;
329334 } else {
330- // if now preview is available, show icon
331- ui. vertical_centered ( |ui| {
332- ui. label (
333- egui:: RichText :: from ( item. icon ( ) ) . size ( ui. available_width ( ) / 3.0 ) ,
334- ) ;
335- } ) ;
335+ // if no ext is available, show icon anyway
336+ ui. label (
337+ egui:: RichText :: from ( item. icon ( ) ) . size ( ui. available_width ( ) / 3.0 ) ,
338+ ) ;
336339 }
337340 }
338- } else {
339- // if now ext is available, show icon anyway
340- ui. vertical_centered ( |ui| {
341- ui. label ( egui:: RichText :: from ( item. icon ( ) ) . size ( ui. available_width ( ) / 3.0 ) ) ;
342- } ) ;
343- }
344- }
341+ } ,
342+ ) ;
345343 }
346344
347345 fn forget_last_stored_image ( & mut self , ui : & Ui ) {
0 commit comments