All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
ImageMovieExample.cpp

ImageMovieExample shows how to use the ImageMovieWidget class.

ImageMovieExample-screenshot.png
Screenshot of the ImageMovie example

We begin the application by including a header files that declare the standard Cornerstone application and the ImageMovieWidget:

#include <MultiWidgets/Application.hpp>
#include <MultiWidgets/ImageMovieWidget.hpp>

We then declare our main function which acts as the entry point for the application:

int main(int argc, char ** argv)
{

Next, we create an instance of our application and initialize it. We also add more command line argument to the application "&ndash;dir" for specifying the image directory and "&ndash;movie-fps".

Valuable::AttributeString dirpath(&app, "dir", "Images");
Valuable::AttributeFloat fps(&app, "movie-fps", 10.0f);
bool ok = app.init(argc, argv);
if(!ok)
return 1;

Now that we have an instance of the application, we create five squares that we place on the screen. The MultiWidgets library contains generic widgets that can be used to create MultiTouch applications. The core Widget class is a simple rectangle with an optional border. Here we also specify the size, location and color of each widget, so that they don't appear on top of each other. The widgets are added to the scene as children of the application main layer widget:

// Create ImageMovie widget
MultiWidgets::ImageMovieWidgetPtr imageMovie =
MultiWidgets::create<MultiWidgets::ImageMovieWidget>(app.mainLayer());
imageMovie->load(dirpath);
imageMovie->setFPS(fps);
// Set widget parameters:
imageMovie->setSize(Nimble::SizeF(300, 300));
imageMovie->setLocation(Nimble::Vector2(150, 150));

Finally, we are ready to run the application and finish the block making up the main function:

// Run the application:
return app.run();
}

The full source code for the complete application is listed below:

/* Copyright (C) 2007-2013 Multi Touch Oy, Finland, http://www.multitaction.com
*
* This file is part of MultiTouch Cornerstone.
*
* All rights reserved. You may use this file only for purposes for which you
* have a specific, written permission from Multi Touch Oy.
*
*/
#include <MultiWidgets/Application.hpp>
#include <MultiWidgets/ImageMovieWidget.hpp>
int main(int argc, char ** argv)
{
Valuable::AttributeString dirpath(&app, "dir", "Images");
Valuable::AttributeFloat fps(&app, "movie-fps", 10.0f);
bool ok = app.init(argc, argv);
if(!ok)
return 1;
// Create ImageMovie widget
MultiWidgets::ImageMovieWidgetPtr imageMovie =
MultiWidgets::create<MultiWidgets::ImageMovieWidget>(app.mainLayer());
imageMovie->load(dirpath);
imageMovie->setFPS(fps);
// Set widget parameters:
imageMovie->setSize(Nimble::SizeF(300, 300));
imageMovie->setLocation(Nimble::Vector2(150, 150));
// Run the application:
return app.run();
}