Slideshow Template

You can post your code snippets here for others to use and learn from
Post Reply
SamuraiCrow
Posts: 327
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Slideshow Template

Post by SamuraiCrow »

I've been trying to find a way to do dynamic layout that's font-sensitive and word-wrap aware. To that end, I've written a starter template to do a PowerPoint-style slideshow. The p_Slide1 function looks needlessly complex. Maybe the rest of you can improve on it or figure a way to make it abstract.

Here's the example code I've written:

Code: Select all

/*
** Hollywood Slideshow Template
**
** By Samuel D. Crow
*/

@VERSION 8,0

/* Add any plugins needed here */

/* Change the Title to something useful */
Const #TITLE="Template"

@DISPLAY 1,{
    Title=#TITLE,
    Mode="FullScreen",
    Width=#NATIVE,
    Height=#NATIVE,
    Fixed=True,
    Borderless=True,
    DisableBlanker=True
}

/* Establish grid layout increments and maximums */
Global size = GetAttribute(#DISPLAY, 1, #ATTRMAXHEIGHT)/24
Global vert = size * 22
Global hsize = GetAttribute(#DISPLAY, 1, #ATTRMAXWIDTH)/32
Global horiz = hsize*30
AddTab(hsize*4)
AddTab(hsize*7)

CreateGradientBGPic(1, #LINEAR, #BLUE, #BLACK)

Function p_Title()
    Local Object
    SetFontColor(#YELLOW)
    SetFont(#SANS, size*4)
    Object=CreateTextObject(Nil, "My Slideshow Template", {
        Align=#CENTER,
        Wordwrap=horiz
    })
    DisplayTextObjectFX(Object, #CENTER, #CENTER, {
        Type=#WATER1,
        Speed=#FASTSPEED
        })
EndFunction

Function p_Slide1()
    Local Object, Object2, vspace, o1size
    SetFontColor(#WHITE)
    SetFont(#SANS, size*4)
    Object=CreateTextObject(Nil, "Title", {
        Align=#CENTER,
        Wordwrap=horiz})
    SetFont(#SANS, size*3)
    Object2=CreateTextObject(Nil, "- Body\n- Body2\n\t* Body3", {Wordwrap=horiz})
    o1size=GetAttribute(#TEXTOBJECT, Object, #ATTRHEIGHT)
    vspace=(vert-o1size-GetAttribute(#TEXTOBJECT, Object2, #ATTRHEIGHT))/2
    DisplayTextObject(Object, #CENTER, size)
    DisplayTextObject(Object2, hsize, o1size+vspace+size)
EndFunction

Function p_TheEnd()
    Local Object
    SetFont(#SANS, size * 8)
    Object=CreateTextObject(Nil, "The End", {
        Align=#CENTER,
        Wordwrap=horiz})
    DisplayTextObjectFX(Object, #CENTER, #CENTER, {
        Type=#WATER1,
        Speed=#FASTSPEED
    })
EndFunction

Global CurrentSlide=0
Global Slides={
    p_Title,
    p_Slide1,
    p_TheEnd,
    0}

CreateDisplay(0, {
        Title=#TITLE,
        Mode="FullScreen",
        Borderless=True,
        Fixed=True,
        Width=#NATIVE,
        Height=#NATIVE
    })

Function p_AdvanceSlide()
    Local fn=Slides[CurrentSlide]
    If (fn = Nil) Then End
    CurrentSlide=CurrentSlide+1
    SelectDisplay(CurrentSlide And 1, True)
    ActivateDisplay((CurrentSlide+1 And 1), True)
    DisplayBGPic(1)
    fn()
EndFunction

Function p_Handler(msg)
    Switch msg.Action Fallthrough
    Case "OnKeyDown":
        If(msg.Key="ESC") Then End
    Case "OnMouseUp":
        p_AdvanceSlide()
        Break
    Default:
    EndSwitch
EndFunction

InstallEventHandler({
    OnMouseUp=p_Handler,
    OnKeyDown=p_Handler
    })

DisplayBGPic(1)
HidePointer()
p_AdvanceSlide()

Repeat
    WaitEvent
Forever
I'm on registered MorphOS using FlowStudio.

User avatar
airsoftsoftwair
Posts: 4386
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slideshow Template

Post by airsoftsoftwair »

Nice! However, I can also recommend Hollywood Designer to everybody who would like to do something PowerPoint-ish with Hollywood :D

SamuraiCrow
Posts: 327
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Slideshow Template

Post by SamuraiCrow »

airsoftsoftwair wrote:
Sun Aug 30, 2020 10:25 pm
Nice! However, I can also recommend Hollywood Designer to everybody who would like to do something PowerPoint-ish with Hollywood :D
I was writing this from my Linux desktop. Wouldn't Hollywood Designer only work from the Amiga-like operating systems?

Also, I put this in the wrong forum. I think it goes in the code snippets section rather than tutorials. Would you please move it?
I'm on registered MorphOS using FlowStudio.

User avatar
airsoftsoftwair
Posts: 4386
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slideshow Template

Post by airsoftsoftwair »

Moved.

Post Reply