-
Notifications
You must be signed in to change notification settings - Fork 6
animation & frameset
[nana::animation
] (http://qpcr4vir.github.io/nana-docs/nana-doxy/html/dd/d57/classnana_1_1animation.html)
The class animation provides an easy way to display an animation or create an animated GUI.
Set the number of frames per second in the constructor animation (std::size_t fps=23)
or with fps (std::size_t n)
, if have to play repeatedly looped (bool enable)
and self the frames to play with push_back (frameset frms)
.
Set where to output (window wd, const nana::point &pos)
and play()
. Optionaly pause()
.
[nana::frameset
] (http://qpcr4vir.github.io/nana-docs/nana-doxy/html/dc/d2f/classnana_1_1frameset.html)
The class frameset holds the frames and frame builders. This class have reference semantics for efficiency.
Images (the frames) can be set directly with push_back (paint::image img)
and using a builder function with: push_back (framebuilder fb, std::size_t length)
, where lenght
is the number of frames to generate.
That builder function have the type:
using framebuilder = std::function< bool(std::size_t pos, paint::graphics &gr, nana::size &sz)>
#include <nana/gui/wvl.hpp>
#include <nana/gui/animation.hpp>
int main()
{
using namespace nana;
//Build frames
frameset fset;
fset.push_back(nana::paint::image("../Examples/a_pic0.bmp"));
fset.push_back(nana::paint::image("../Examples/a_pic1.bmp"));
fset.push_back(nana::paint::image("../Examples/a_pic2.bmp"));
//A widget to display animation.
form fm;
fm.show();
animation ani;
ani.push_back(fset);
ani.output(fm, nana::point(5,5));
ani.looped(true);
ani.play();
exec();
}