Add SetThumbsDisplayStyle()
This commit is contained in:
@@ -433,6 +433,7 @@ DeclareModule Thumbs
|
||||
Declare FreeThumbsGadget(GadgetId.i) ; Frees all resources associated with the gadget. / Libère toutes les ressources associées au gadget.
|
||||
Declare ForceUpdate(GadgetId.i) ; Forces a complete refresh of the gadget. / Force un rafraîchissement complet du gadget.
|
||||
Declare SetThumbsSize(GadgetId.i, Size.l) ; Change Thumb size / Change la taille des vignettes
|
||||
Declare SetThumbsDisplayStyle(GadgetId.i, Style.l) ; Change fill style image / change le style de rempissage de l'image
|
||||
EndDeclareModule
|
||||
|
||||
Module Thumbs
|
||||
@@ -491,7 +492,8 @@ Module Thumbs
|
||||
DrawSemaphore.i ; Semaphore to signal the drawing thread to redraw the canvas. / Sémaphore pour signaler au thread de dessin de redessiner le canvas.
|
||||
Quit.b ; Flag to signal the background threads to terminate. / Indicateur pour signaler aux threads d'arrière-plan de se terminer.
|
||||
ThreadDrawCanvasImage.i ; Thread handle for the canvas drawing thread. / Handle du thread pour le thread de dessin du canvas.
|
||||
EndStructure
|
||||
DisplayStyle.l ; style (Fit, Fill, Stretch)
|
||||
EndStructure
|
||||
|
||||
; Global structure for the Thumbs module. / Structure globale pour le module Thumbs.
|
||||
Structure param
|
||||
@@ -729,7 +731,7 @@ Module Thumbs
|
||||
FileName.s = GetFilePart(*Ptr\FilePath)
|
||||
|
||||
Protected result.ImgTools::DefDisplayImage
|
||||
ImgTools::ImageToContainer(@result, Image, *Gdt\_Size, *Gdt\_Size, ImgTools::#Image_Style_Fit)
|
||||
ImgTools::ImageToContainer(@result, Image, *Gdt\_Size, *Gdt\_Size, *Gdt\DisplayStyle)
|
||||
|
||||
Protected _Border.l, _BorderX2.l
|
||||
; Draw a green border if the item is selected. / Dessine une bordure verte si l'élément est sélectionné.
|
||||
@@ -959,6 +961,7 @@ Module Thumbs
|
||||
*Gdt\GadgetId = GadgetId
|
||||
*Gdt\Size = Size
|
||||
*Gdt\LastIndexSelected = -1 ; Initialize with no selection. / Initialise sans sélection.
|
||||
*Gdt\DisplayStyle = ImgTools::#Image_Style_Fit ; default fit style
|
||||
Debug *Gdt\Size
|
||||
SetGadgetData(GadgetId, *Gdt)
|
||||
InitGadgetValue(GadgetId)
|
||||
@@ -1046,7 +1049,18 @@ Module Thumbs
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
|
||||
; Procédure : SetThumbsDisplayStyle - Permet de changer le style d'affichage des vignettes.
|
||||
Procedure SetThumbsDisplayStyle(GadgetId.i, Style.l)
|
||||
Protected *Gdt.gdt
|
||||
*Gdt = GetGadgetData(GadgetId)
|
||||
If *Gdt
|
||||
; Met à jour la variable de style dans la structure du gadget
|
||||
*Gdt\DisplayStyle = Style
|
||||
|
||||
; Force le redessin du gadget pour que le changement soit visible immédiatement
|
||||
SignalSemaphore(*Gdt\DrawSemaphore)
|
||||
EndIf
|
||||
EndProcedure
|
||||
EndModule
|
||||
|
||||
; =================================================
|
||||
@@ -1065,6 +1079,10 @@ CompilerIf #PB_Compiler_IsMainFile
|
||||
#Gdt_ThumbA
|
||||
#Gdt_ThumbB
|
||||
#Gdt_ThumbSize
|
||||
#Gdt_FrameStyle ; <--- Ajoutez
|
||||
#Gdt_OptionFit ; <--- Ajoutez
|
||||
#Gdt_OptionFill ; <--- Ajoutez
|
||||
#Gdt_OptionStretch ; <--- Ajoutez
|
||||
EndEnumeration
|
||||
|
||||
Global NewList CurrentList.s() ; A global list to hold the file paths of the images to be displayed. / Une liste globale pour contenir les chemins des fichiers des images à afficher.
|
||||
@@ -1116,7 +1134,13 @@ CompilerIf #PB_Compiler_IsMainFile
|
||||
If OpenWindow(#Win_main, 0, 0, 1024, 600, "Thumbnails", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
|
||||
ButtonGadget(#Gdt_Folder, 10, 10, 120, 25, "Choose Folder")
|
||||
TrackBarGadget(#Gdt_ThumbSize, 140, 10, 200, 25, 64, 256) ; Min: 64px, Max: 256px
|
||||
SetGadgetState(#Gdt_ThumbSize, 128) ; On règle la taille initiale à 128px
|
||||
SetGadgetState(#Gdt_ThumbSize, 128) ; On règle la taille initiale à 128px
|
||||
FrameGadget(#Gdt_FrameStyle, 350, 5, 280, 35, "Display Style")
|
||||
OptionGadget(#Gdt_OptionFit, 360, 20, 80, 15, "Fit")
|
||||
OptionGadget(#Gdt_OptionFill, 450, 20, 80, 15, "Fill")
|
||||
OptionGadget(#Gdt_OptionStretch, 540, 20, 80, 15, "Stretch")
|
||||
SetGadgetState(#Gdt_OptionFit, #True) ; On coche "Fit" par défaut
|
||||
|
||||
Cache::InitCache() ; Initialize the caching system. / Initialise le système de cache.
|
||||
; Create the thumbnail gadget, passing our callback function. / Crée le gadget de vignettes, en passant notre fonction de callback.
|
||||
Thumbs::ThumbsGadget(#Gdt_ThumbA, 0, 50, WindowWidth(#Win_main), WindowHeight(#Win_main) - 50, 128, @CallBackLoadFromIndexB())
|
||||
@@ -1157,7 +1181,16 @@ CompilerIf #PB_Compiler_IsMainFile
|
||||
Thumbs::SetThumbsSize(#Gdt_ThumbA, NewSize)
|
||||
Debug NewSize
|
||||
;EndIf
|
||||
|
||||
|
||||
Case #Gdt_OptionFit
|
||||
Thumbs::SetThumbsDisplayStyle(#Gdt_ThumbA, ImgTools::#Image_Style_Fit)
|
||||
|
||||
Case #Gdt_OptionFill
|
||||
Thumbs::SetThumbsDisplayStyle(#Gdt_ThumbA, ImgTools::#Image_Style_Fill)
|
||||
|
||||
Case #Gdt_OptionStretch
|
||||
Thumbs::SetThumbsDisplayStyle(#Gdt_ThumbA, ImgTools::#Image_Style_Stretch)
|
||||
|
||||
EndSelect
|
||||
EndIf
|
||||
|
||||
@@ -1181,8 +1214,8 @@ CompilerEndIf
|
||||
; EnableXP
|
||||
; DPIAware
|
||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||
; CursorPosition = 1158
|
||||
; FirstLine = 1126
|
||||
; CursorPosition = 1192
|
||||
; FirstLine = 1149
|
||||
; Folding = -------
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
|
Reference in New Issue
Block a user