AnimatedClip
Multi image formats (GIF and TIFF) demo using RasterPlayer
AnimatedClip.h
#ifndef _AnimatedClipDemo_AnimatedClipDemo_h
#define _AnimatedClipDemo_AnimatedClipDemo_h
#define LAYOUTFILE <AnimatedClip/AnimatedClip.lay>
#include <CtrlCore/lay.h>
class AnimatedClip : public WithAnimatedClipLayout<TopWindow> {
public:
typedef AnimatedClip CLASSNAME;
AnimatedClip();
void Browse();
void Play();
void Stop();
void OpenNext();
void ChangeThreads();
void OnShown();
};
#endif
main.cpp
#include <CtrlLib/CtrlLib.h>
#include <RasterPlayer/RasterPlayer.h>
using namespace Upp;
#include "AnimatedClip.h"
#include "AnimatedClip.brc"
AnimatedClip::AnimatedClip() {
CtrlLayout(*this, "RasterPlayer demo");
browse <<= THISBACK(Browse);
play <<= THISBACK(Play);
stop <<= THISBACK(Stop);
openNext <<= THISBACK(OpenNext);
numThreads = 0;
numThreads <<= THISBACK(ChangeThreads);
#ifndef _MULTITHREADED
numThreads.EnableCase(1, false);
#endif
clip.WhenShown = THISBACK(OnShown);
arrows.LoadBuffer(String(animatedArrow, animatedArrow_length));
arrows.Play();
earth.LoadBuffer(String(animatedEarth, animatedEarth_length));
earth.Play();
Sizeable().Zoomable();
}
void AnimatedClip::Browse() {
FileSel fs;
fs.PreSelect(fileName);
fs.Type("Animation type", "*.gif, *.tif, *.tiff");
if (fs.ExecuteOpen("Choose animation file"))
fileName <<= ~fs;
if (!clip.Load(fileName)) {
Exclamation("Invalid input");
return;
}
numberPages = FormatInt(clip.GetPageCount());
openedPage = FormatInt(clip.GetPage());
}
void AnimatedClip::Play() {
clip.Play();
}
void AnimatedClip::Stop() {
clip.Stop();
}
void AnimatedClip::OpenNext() {
clip.NextFrame();
}
void AnimatedClip::OnShown() {
openedPage = FormatInt(clip.GetPage());
}
void AnimatedClip::ChangeThreads() {
clip.SetMT(numThreads == 1);
}
GUI_APP_MAIN {
AnimatedClip().Run();
}
AnimatedClip.lay
LAYOUT(AnimatedClipLayout, 540, 280)
ITEM(RasterPlayer, clip, SetFrame(InsetFrame()).HSizePosZ(8, 8).VSizePosZ(92, 32))
ITEM(Label, openedPage, SetLabel(t_("0")).LeftPosZ(204, 24).TopPosZ(68, 19))
ITEM(Label, dv___2, SetLabel(t_("Opened Page:")).LeftPosZ(132, 68).TopPosZ(68, 19))
ITEM(Label, numberPages, SetLabel(t_("1")).LeftPosZ(100, 24).TopPosZ(68, 19))
ITEM(Label, dv___4, SetLabel(t_("Number of Pages:")).LeftPosZ(8, 88).TopPosZ(68, 19))
ITEM(EditString, fileName, HSizePosZ(68, 232).TopPosZ(40, 19))
ITEM(Button, openNext, SetLabel(t_("Open Next")).RightPosZ(164, 64).TopPosZ(68, 20))
ITEM(Button, stop, SetLabel(t_("Stop")).RightPosZ(232, 36).TopPosZ(68, 20))
ITEM(Button, play, SetLabel(t_("Play")).RightPosZ(272, 36).TopPosZ(68, 20))
ITEM(Button, browse, SetLabel(t_("Browse")).RightPosZ(164, 64).TopPosZ(40, 20))
ITEM(Label, dv___10, SetLabel(t_("Load and animate GIF and TIFF files")).HSizePosZ(8, 84).TopPosZ(8, 19))
ITEM(Label, dv___11, SetLabel(t_("Image file:")).LeftPosZ(8, 56).TopPosZ(40, 19))
ITEM(RasterPlayer, earth, RightPosZ(12, 52).TopPosZ(8, 52))
ITEM(RasterPlayer, arrows, SetSpeed(2).HSizePosZ(8, 8).BottomPosZ(8, 20))
ITEM(Switch, numThreads, SetLabel(t_("Single thread\nMultithreaded")).RightPosZ(68, 88).VSizePosZ(56, 192))
END_LAYOUT
AnimatedClip.brc
BINARY(animatedArrow, "arrtan_e0.gif")
BINARY(animatedEarth, "arkearth_e0.gif")
|