Add SetThumbsSize()
This commit is contained in:
101
Thumbnails.pb
101
Thumbnails.pb
@@ -431,7 +431,8 @@ DeclareModule Thumbs
|
|||||||
Declare LimitIndex(GadgetId.i, IndexMax.i = -1) ; Sets the maximum scrollable index. / Définit l'index maximal de défilement.
|
Declare LimitIndex(GadgetId.i, IndexMax.i = -1) ; Sets the maximum scrollable index. / Définit l'index maximal de défilement.
|
||||||
Declare ThumbsGadget(GadgetId.i, X.l, Y.l, Width.l, Height.l, Size.l, CallBack.i = 0) ; Creates the thumbnail gadget. / Crée le gadget de vignettes.
|
Declare ThumbsGadget(GadgetId.i, X.l, Y.l, Width.l, Height.l, Size.l, CallBack.i = 0) ; Creates the thumbnail gadget. / Crée le gadget de vignettes.
|
||||||
Declare FreeThumbsGadget(GadgetId.i) ; Frees all resources associated with the gadget. / Libère toutes les ressources associées au gadget.
|
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 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
|
||||||
EndDeclareModule
|
EndDeclareModule
|
||||||
|
|
||||||
Module Thumbs
|
Module Thumbs
|
||||||
@@ -1025,7 +1026,27 @@ Module Thumbs
|
|||||||
Next
|
Next
|
||||||
UnlockMutex(*Gdt\ThumbPointerlistMutex)
|
UnlockMutex(*Gdt\ThumbPointerlistMutex)
|
||||||
UpdateIndexs(GadgetId) ; Trigger a reload from index 0. / Déclenche un rechargement à partir de l'index 0.
|
UpdateIndexs(GadgetId) ; Trigger a reload from index 0. / Déclenche un rechargement à partir de l'index 0.
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; Procédure : SetThumbsSize - Permet de changer la taille des vignettes dynamiquement.
|
||||||
|
Procedure SetThumbsSize(GadgetId.i, Size.l)
|
||||||
|
Protected *Gdt.gdt
|
||||||
|
*Gdt = GetGadgetData(GadgetId)
|
||||||
|
If *Gdt
|
||||||
|
*Gdt\Size = Size ; Met à jour la taille de base
|
||||||
|
|
||||||
|
; Recalcule toutes les dimensions du gadget en fonction de la nouvelle taille
|
||||||
|
InitGadgetValue(GadgetId)
|
||||||
|
|
||||||
|
; Demande le rechargement des images pour la nouvelle disposition
|
||||||
|
UpdateIndexs(GadgetId)
|
||||||
|
|
||||||
|
; Force le redessin du gadget pour afficher le changement
|
||||||
|
SignalSemaphore(*Gdt\DrawSemaphore)
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
|
||||||
EndModule
|
EndModule
|
||||||
|
|
||||||
; =================================================
|
; =================================================
|
||||||
@@ -1043,6 +1064,7 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
#Gdt_Folder
|
#Gdt_Folder
|
||||||
#Gdt_ThumbA
|
#Gdt_ThumbA
|
||||||
#Gdt_ThumbB
|
#Gdt_ThumbB
|
||||||
|
#Gdt_ThumbSize
|
||||||
EndEnumeration
|
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.
|
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.
|
||||||
@@ -1092,45 +1114,59 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
CurrentListMutex = CreateMutex()
|
CurrentListMutex = CreateMutex()
|
||||||
|
|
||||||
If OpenWindow(#Win_main, 0, 0, 1024, 600, "Thumbnails", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
|
If OpenWindow(#Win_main, 0, 0, 1024, 600, "Thumbnails", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
|
||||||
ButtonGadget(#Gdt_Folder, 0, 0, 100, 25, "Choose Folder")
|
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
|
||||||
Cache::InitCache() ; Initialize the caching system. / Initialise le système de cache.
|
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.
|
; 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())
|
Thumbs::ThumbsGadget(#Gdt_ThumbA, 0, 50, WindowWidth(#Win_main), WindowHeight(#Win_main) - 50, 128, @CallBackLoadFromIndexB())
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
Event = WaitWindowEvent()
|
Event = WaitWindowEvent()
|
||||||
If Event = #PB_Event_Gadget
|
If Event = #PB_Event_Gadget
|
||||||
If EventGadget() = #Gdt_Folder
|
Select EventGadget() ; <--- On utilise un Select pour plus de clarté
|
||||||
Repertoire$ = PathRequester("Chose Directory", "G:\Documents\Photos\Photos a trier")
|
Case #Gdt_Folder
|
||||||
If Repertoire$ <> ""
|
Repertoire$ = PathRequester("Chose Directory", "G:\Documents\Photos\Photos a trier")
|
||||||
If ExamineDirectory(0, Repertoire$, "*.jpg")
|
|
||||||
; Safely clear the old list and fill it with new file paths. / Vide de manière sécurisée l'ancienne liste et la remplit avec les nouveaux chemins de fichiers.
|
|
||||||
LockMutex(CurrentListMutex)
|
|
||||||
ClearList(CurrentList())
|
|
||||||
While NextDirectoryEntry(0)
|
|
||||||
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
|
|
||||||
AddElement(CurrentList())
|
|
||||||
CurrentList() = Repertoire$ + DirectoryEntryName(0)
|
|
||||||
EndIf
|
|
||||||
Wend
|
|
||||||
FinishDirectory(0)
|
|
||||||
UnlockMutex(CurrentListMutex)
|
|
||||||
|
|
||||||
Debug "LISTSIZE=" + Str(ListSize(CurrentList()))
|
If Repertoire$ <> ""
|
||||||
; Update the gadget with the new list size and force it to reload. / Met à jour le gadget avec la nouvelle taille de liste et force son rechargement.
|
If ExamineDirectory(0, Repertoire$, "*.jpg")
|
||||||
Thumbs::LimitIndex(#Gdt_ThumbA, ListSize(CurrentList()))
|
; ... (le reste du code reste inchangé)
|
||||||
Thumbs::ForceUpdate(#Gdt_ThumbA)
|
LockMutex(CurrentListMutex)
|
||||||
EndIf
|
ClearList(CurrentList())
|
||||||
|
While NextDirectoryEntry(0)
|
||||||
|
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
|
||||||
|
AddElement(CurrentList())
|
||||||
|
CurrentList() = Repertoire$ + DirectoryEntryName(0)
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
FinishDirectory(0)
|
||||||
|
UnlockMutex(CurrentListMutex)
|
||||||
|
|
||||||
|
Debug "LISTSIZE=" + Str(ListSize(CurrentList()))
|
||||||
|
Thumbs::LimitIndex(#Gdt_ThumbA, ListSize(CurrentList()))
|
||||||
|
Thumbs::ForceUpdate(#Gdt_ThumbA)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
|
||||||
|
|
||||||
If Event = #PB_Event_SizeWindow
|
Case #Gdt_ThumbSize ; <--- Voici notre nouvelle gestion d'événement
|
||||||
Debug "coucou"
|
|
||||||
ResizeGadget(#Gdt_ThumbA, 0, 50, WindowWidth(#Win_main), WindowHeight(#Win_main) - 50)
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
Until Event = #PB_Event_CloseWindow
|
;If EventType() = #PB_EventType_Change
|
||||||
|
Debug "coucou"
|
||||||
|
Define NewSize.l = GetGadgetState(#Gdt_ThumbSize)
|
||||||
|
; On appelle notre nouvelle fonction pour mettre à jour la taille !
|
||||||
|
Thumbs::SetThumbsSize(#Gdt_ThumbA, NewSize)
|
||||||
|
Debug NewSize
|
||||||
|
;EndIf
|
||||||
|
|
||||||
|
EndSelect
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
If Event = #PB_Event_SizeWindow
|
||||||
|
Debug "coucou"
|
||||||
|
ResizeGadget(#Gdt_ThumbA, 0, 50, WindowWidth(#Win_main), WindowHeight(#Win_main) - 50)
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
Until Event = #PB_Event_CloseWindow
|
||||||
|
|
||||||
; Clean up all resources before exiting. / Nettoie toutes les ressources avant de quitter.
|
; Clean up all resources before exiting. / Nettoie toutes les ressources avant de quitter.
|
||||||
Thumbs::FreeThumbsGadget(#Gdt_ThumbA)
|
Thumbs::FreeThumbsGadget(#Gdt_ThumbA)
|
||||||
@@ -1145,7 +1181,8 @@ CompilerEndIf
|
|||||||
; EnableXP
|
; EnableXP
|
||||||
; DPIAware
|
; DPIAware
|
||||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||||
; CursorPosition = 3
|
; CursorPosition = 1158
|
||||||
|
; FirstLine = 1126
|
||||||
; Folding = -------
|
; Folding = -------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
|
Reference in New Issue
Block a user