Jump to content

Slideshow UDF


Andreik
 Share

Recommended Posts

Posted (edited)

@van_renier Check out SlideshowEx.au3 in the first post. Using this version there are no preloaded images. This means ImageType property is no longer used (or available) and as a side efect $avImage can contain now a mix of local files, image URLs or raw binary data. Here is an example with 1000 slides and memory used it's around 10 MB:

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 4 -w 5 -w 6 -w 7
#Au3Stripper_Parameters=/sf /sv /mo /rm /rsln

#include <SlideshowEx.au3>

Global $avImage[1000], $asLabel[1000]
For $Index = 0 To 999
    Switch Mod($Index, 4)
        Case 0
            $avImage[$Index] = 'https://lh5.googleusercontent.com/p/AF1QipM3jIOsqrISfcKwgYLYF8-9DyAzQiUyWmB35nBj=w540-h312-n-k-no'
        Case 1
            $avImage[$Index] = 'https://lh5.googleusercontent.com/p/AF1QipMPb5fGtzZz2ZJFd20CV2trNzmxNOYLv4abJSfi=w540-h312-n-k-no'
        Case 2
            $avImage[$Index] = 'https://lh5.googleusercontent.com/p/AF1QipPLOXRwTpKbFxNNLTmiLrIJlG_H3h4VU6HShLwf=w540-h312-n-k-no'
        Case 3
            $avImage[$Index] = 'https://lh5.googleusercontent.com/p/AF1QipPNiwx1lGPxcHJzKTMRl5Cyr1SOjS05yHbif8BE=w540-h312-n-k-no'
    EndSwitch
    $asLabel[$Index] = 'Slide ' & $Index + 1
Next

Global $mOptions[]
$mOptions['Captions'] = $asLabel
$mOptions['ShowSlides'] = False
$mOptions['ShowCaptions'] = True

Global $sTitle = 'Cape Verde'
Global $sText = 'Cape Verde or Cabo Verde, officially the Republic of Cabo Verde, is an archipelago and island country of West Africa in the central Atlantic Ocean, ' & _
'consisting of ten volcanic islands with a combined land area of about 4,033 square kilometres (1,557 sq mi). These islands lie between 600 and 850 kilometres ' & _
'(320 and 460 nautical miles) west of Cap-Vert, the westernmost point of continental Africa. The Cape Verde islands form part of the Macaronesia ecoregion, ' & _
'along with the Azores, the Canary Islands, Madeira, and the Savage Isles.'
Global $sExtraText = "Cape Verde's official language is Portuguese. The recognized national language is Cape Verdean Creole, which is spoken by the vast " & _
"majority of the population. As of the 2021 census the most populated islands were Santiago, where the capital Praia is located (269,370), São Vicente (74,016), " & _
"Santo Antão (36,632), Fogo (33,519) and Sal (33,347). The largest cities are Praia (137,868), Mindelo (69,013), Espargos (24,500) and Assomada (21,297)."
Global $sCopyright = 'Sources for pictures and data are from google.com and wikipedia.com'

Global $hGUI, $cTitle, $cText, $cExtra, $cCopyright, $mSlideshow

_GDIPlus_Startup()
$hGUI = GUICreate('Slideshow', 870, 450)
$cTitle = GUICtrlCreateLabel($sTitle, 10, 10, 300, 60)
$cText = GUICtrlCreateLabel($sText, 10, 90, 300, 240)
$cExtra = GUICtrlCreateLabel($sExtraText, 10, 330, 850, 80)
$cCopyright = GUICtrlCreateLabel($sCopyright, 10, 420, 850, 20)
$mSlideshow = _GUICtrlSlideshow_Create($hGUI, 320, 10, 540, 312, $avImage, $mOptions)
GUICtrlSetFont($cTitle, 35, 600, 0, 'Segoe UI')
GUICtrlSetFont($cText, 11, 500, 0, 'Segoe UI')
GUICtrlSetFont($cExtra, 11, 500, 0, 'Segoe UI')
GUICtrlSetFont($cCopyright, 11, 500, 2, 'Segoe UI')
GUICtrlSetColor($cTitle, 0x000060)
GUICtrlSetColor($cCopyright, 0x800000)
GUISetState(@SW_SHOW, $hGUI)

While True
    If _GUICtrlSlideshow_ButtonEvent($mSlideshow, $SLIDESHOW_PREV_BTN) Then _GUICtrlSlideshow_ShowSlide($mSlideshow, $BTN_EVENT_PREV)
    If _GUICtrlSlideshow_ButtonEvent($mSlideshow, $SLIDESHOW_NEXT_BTN) Then _GUICtrlSlideshow_ShowSlide($mSlideshow, $BTN_EVENT_NEXT)
    Switch GUIGetMsg()
        Case -3
            ExitLoop
    EndSwitch
WEnd

_GUICtrlSlideshow_Delete($mSlideshow)
_GDIPlus_Shutdown()
Edited by Andreik
Better example

When the words fail... music speaks.

Link to comment
Share on other sites

Hey Andreik,

I thought I had posted earlier on your updated code for not pre-caching the images/slides, but can't find any record of it. Sorry.

Anyhoo.... This updated code works great! Thank you!
At 953 movie posters now, and the compiled script is only taking up about ~7-8MB or so.
I did add hotkeys support to my code, so we can control the forward and back using a non-mouse remote control (gyro-sensor, and buttons), or the left/right arrow keys, as well as similar 'next/previous' buttons on the controller.  (I have noticed that until the transition to the 'new' slide is completed that any additional keypresses or clicks on the slidecontrols, it reset/restart the in-progress transition to the next slide. As long as we wait until the transition is completed, everything works fine, though.) 

Thanks again for posting that code, and your most-excellent support !!

Sincerely,

 

Van

 

Edited by van_renier
added some additional content to post
Link to comment
Share on other sites

Posted (edited)

I'm glad it works fine for your project. Indeed, hotkeys would be a nice addition so I might add this to the UDF soon.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

1 hour ago, UEZ said:

Can you exclude the progress bar at the top of the images from the fading effect?

Are you talking about the slides indicators?

Untitled.jpg

When the words fail... music speaks.

Link to comment
Share on other sites

Well, it's just a matter of drawing order. For me it looks kinda weird visually to draw these indicators after the transition it's done but it's definitely possible.

Just switch the order of these two block of codes in __Slide() function.

If $mCurrent['ShowSlides'] Then
   ...
EndIf
...
If $mCurrent['Transition'] Then
   ...
EndIf

to

If $mCurrent['Transition'] Then
   ...
EndIf
If $mCurrent['ShowSlides'] Then
   ...
EndIf

 

When the words fail... music speaks.

Link to comment
Share on other sites

If you didn't set your own colors in options, these colors should be by default:

SlideColor - Color of the slides indicators in AARRGGBB format [Default: 0x80FFFFFF]
SlideActive - Color of the active slide indicator in AARRGGBB format [Default: 0xFFFFFFFF]

 

When the words fail... music speaks.

Link to comment
Share on other sites

Yes, I saw that, too but still the indicators fading regardless if I swap Transition with ShowSlides and make pen opaque.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Posted (edited)

If you switched the order of drawing the indicators won't fade. See the video below.

https://streamable.com/16wmtg

If the transition it's fast it might look like the indicators fades but if you increase TransitionFrames you can see the indicators are not rendered during transition.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

@van_renier Added keys support to change slides - first post updated. Two more properties are available: EnableKeys (True or False) and Keys (a map with two mandatory keys Prev/Next) and a new function that process key events _GUICtrlSlideshow_KeyEvent().Here is an example:

#include <SlideshowEx.au3>

Global $avImage[4] = [ _
    'https://lh5.googleusercontent.com/p/AF1QipM3jIOsqrISfcKwgYLYF8-9DyAzQiUyWmB35nBj=w540-h312-n-k-no', _
    'https://lh5.googleusercontent.com/p/AF1QipMPb5fGtzZz2ZJFd20CV2trNzmxNOYLv4abJSfi=w540-h312-n-k-no', _
    'https://lh5.googleusercontent.com/p/AF1QipPLOXRwTpKbFxNNLTmiLrIJlG_H3h4VU6HShLwf=w540-h312-n-k-no', _
    'https://lh5.googleusercontent.com/p/AF1QipPNiwx1lGPxcHJzKTMRl5Cyr1SOjS05yHbif8BE=w540-h312-n-k-no' _
]

Global $asCaptions[4] = ['Pico do Fogo', 'Praia da Chave', 'Buracona - Blue Eye Cave', 'Deserto de Viana']

Global $mKeys[]         ; Check _IsPressed() in help file for more virtual key codes
$mKeys['Prev'] = '25'   ; Left arrow button
$mKeys['Next'] = '27'   ; Right arrow button

Global $mOptions[]
$mOptions['ShowSlides'] = True
$mOptions['ShowCaptions'] = True
$mOptions['Captions'] = $asCaptions
$mOptions['EnableKeys'] = True
$mOptions['Keys'] = $mKeys

Global $sTitle = 'Cape Verde'
Global $sText = 'Cape Verde or Cabo Verde, officially the Republic of Cabo Verde, is an archipelago and island country of West Africa in the central Atlantic Ocean, ' & _
'consisting of ten volcanic islands with a combined land area of about 4,033 square kilometres (1,557 sq mi). These islands lie between 600 and 850 kilometres ' & _
'(320 and 460 nautical miles) west of Cap-Vert, the westernmost point of continental Africa. The Cape Verde islands form part of the Macaronesia ecoregion, ' & _
'along with the Azores, the Canary Islands, Madeira, and the Savage Isles.'
Global $sExtraText = "Cape Verde's official language is Portuguese. The recognized national language is Cape Verdean Creole, which is spoken by the vast " & _
"majority of the population. As of the 2021 census the most populated islands were Santiago, where the capital Praia is located (269,370), São Vicente (74,016), " & _
"Santo Antão (36,632), Fogo (33,519) and Sal (33,347). The largest cities are Praia (137,868), Mindelo (69,013), Espargos (24,500) and Assomada (21,297)."
Global $sCopyright = 'Sources for pictures and data are from google.com and wikipedia.com'

Global $hGUI, $cTitle, $cText, $cExtra, $cCopyright, $mSlideshow

_GDIPlus_Startup()
$hGUI = GUICreate('Slideshow', 870, 450)
$cTitle = GUICtrlCreateLabel($sTitle, 10, 10, 300, 60)
$cText = GUICtrlCreateLabel($sText, 10, 90, 300, 240)
$cExtra = GUICtrlCreateLabel($sExtraText, 10, 330, 850, 80)
$cCopyright = GUICtrlCreateLabel($sCopyright, 10, 420, 850, 20)
$mSlideshow = _GUICtrlSlideshow_Create($hGUI, 320, 10, 540, 312, $avImage, $mOptions)
GUICtrlSetFont($cTitle, 35, 600, 0, 'Segoe UI')
GUICtrlSetFont($cText, 11, 500, 0, 'Segoe UI')
GUICtrlSetFont($cExtra, 11, 500, 0, 'Segoe UI')
GUICtrlSetFont($cCopyright, 11, 500, 2, 'Segoe UI')
GUICtrlSetColor($cTitle, 0x000060)
GUICtrlSetColor($cCopyright, 0x800000)
GUISetState(@SW_SHOW, $hGUI)

While True
    _GUICtrlSlideshow_KeyEvent($mSlideshow)
    If _GUICtrlSlideshow_ButtonEvent($mSlideshow, $SLIDESHOW_PREV_BTN) Then _GUICtrlSlideshow_ShowSlide($mSlideshow, $BTN_EVENT_PREV)
    If _GUICtrlSlideshow_ButtonEvent($mSlideshow, $SLIDESHOW_NEXT_BTN) Then _GUICtrlSlideshow_ShowSlide($mSlideshow, $BTN_EVENT_NEXT)
    Switch GUIGetMsg()
        Case -3
            ExitLoop
    EndSwitch
WEnd

_GUICtrlSlideshow_Delete($mSlideshow)
_GDIPlus_Shutdown()

 

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...