This class contains everything to construct a cursor - its data, default settings etc. More...

#include <cursor_description.h>

Public Member Functions

 CursorDescription ()
 Constructs a cursor description.
 
 CursorDescription (const CursorDescription &copy)
 Constructs a CursorDescription.
 
 ~CursorDescription ()
 
void add_alphaclipped_frames (const PixelBuffer &pixelbuffer, int xpos=0, int ypos=0, float trans_limit=0.05f)
 Adds images separated with pure alpha (within trans_limit).
 
void add_alphaclipped_frames_free (const PixelBuffer &pixelbuffer, int xpos=0, int ypos=0, float trans_limit=0.05f)
 Adds images separated with pure alpha (within trans_limit).
 
void add_frame (const PixelBuffer &pixelbuffer)
 Adds a single image.
 
void add_frame (const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame.
 
void add_frame (const std::string &fullname, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame.
 
void add_frame (IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc=ImageImportDescription())
 Add frame.
 
void add_gridclipped_frames (const PixelBuffer &pixelbuffer, int xpos, int ypos, int width, int height, int xarray=1, int yarray=1, int array_skipframes=0, int xspacing=0, int yspacing=0)
 Adds images formed in a grid.
 
const std::vector< CursorDescriptionFrame > & get_frames () const
 Returns a list over all available frames.
 
Point get_hotspot () const
 the offset of where the cursor is drawn relative to cursor image
 
bool operator!= (const CursorDescription &that) const
 
bool operator< (const CursorDescription &that) const
 
bool operator<= (const CursorDescription &that) const
 
CursorDescriptionoperator= (const CursorDescription &copy)
 Copy assignment operator.
 
bool operator== (const CursorDescription &that) const
 
bool operator> (const CursorDescription &that) const
 
bool operator>= (const CursorDescription &that) const
 
void set_frame_delay (int frame, double delay)
 Sets the duration this frame is displayed, in seconds.
 
void set_hotspot (const Point &hotspot)
 Sets the offset of where the cursor is drawn relative to the cursor image.
 

Static Public Member Functions

static CursorDescription load (GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &doc, const ImageImportDescription &import_desc=ImageImportDescription())
 Loads a CursorDescription from a XML resource definition.
 

Detailed Description

This class contains everything to construct a cursor - its data, default settings etc.

CursorDescription is used by Cursor to construct itself based on the description. The description class give a big flexibility creating a cursor, individual frames can come from different image sources, or be cut out from an image source using various different techniques.

Constructor & Destructor Documentation

◆ CursorDescription() [1/2]

clan::CursorDescription::CursorDescription ( )

Constructs a cursor description.

◆ CursorDescription() [2/2]

clan::CursorDescription::CursorDescription ( const CursorDescription & copy)

Constructs a CursorDescription.

Parameters
copy= Cursor Description

◆ ~CursorDescription()

clan::CursorDescription::~CursorDescription ( )

Member Function Documentation

◆ add_alphaclipped_frames()

void clan::CursorDescription::add_alphaclipped_frames ( const PixelBuffer & pixelbuffer,
int xpos = 0,
int ypos = 0,
float trans_limit = 0.05f )

Adds images separated with pure alpha (within trans_limit).

The alpha clipper will cut out frames from an image based on the transparency in the picture. It first determines the height of a row by searching for the first line that it considers completely transparent. Then it finds the width of each frame on this line by looking for columns that are completely transparency.

Parameters
pixelbufferImage source.
textureImage source.
xpos,yposUpper left position where alpha cutting should begin.
trans_limitAmount of non-transparent alpha allowed before a pixel is not considered transparent.

◆ add_alphaclipped_frames_free()

void clan::CursorDescription::add_alphaclipped_frames_free ( const PixelBuffer & pixelbuffer,
int xpos = 0,
int ypos = 0,
float trans_limit = 0.05f )

Adds images separated with pure alpha (within trans_limit).

The alpha clipper will cut out frames from an image based on the transparency in the picture. It scans the lines horizontally from top to bottom. As soon as a non-transarent pixel is discovered, the clipper finds the bounding box for that region and then moves on.

Parameters
pixelbufferImage source.
textureImage source.
xpos,yposUpper left position where alpha cutting should begin.
trans_limitAmount of non-transparent alpha allowed before a pixel is not considered transparent.

◆ add_frame() [1/4]

void clan::CursorDescription::add_frame ( const PixelBuffer & pixelbuffer)

Adds a single image.

Parameters
pixelbufferImage source.
filenameFilename of image.
vfsVirtual File System to load image from.

◆ add_frame() [2/4]

void clan::CursorDescription::add_frame ( const std::string & filename,
FileSystem & fs,
const ImageImportDescription & import_desc = ImageImportDescription() )

Add frame.

Parameters
filename= String Ref
dir= Virtual Directory

◆ add_frame() [3/4]

void clan::CursorDescription::add_frame ( const std::string & fullname,
const ImageImportDescription & import_desc = ImageImportDescription() )

Add frame.

Parameters
fullname= String Ref

◆ add_frame() [4/4]

void clan::CursorDescription::add_frame ( IODevice & file,
const std::string & image_type,
const ImageImportDescription & import_desc = ImageImportDescription() )

Add frame.

Parameters
file= IODevice
image_type= String

◆ add_gridclipped_frames()

void clan::CursorDescription::add_gridclipped_frames ( const PixelBuffer & pixelbuffer,
int xpos,
int ypos,
int width,
int height,
int xarray = 1,
int yarray = 1,
int array_skipframes = 0,
int xspacing = 0,
int yspacing = 0 )

Adds images formed in a grid.

This function will cut out a grid of frames from one image.

Parameters
pixelbufferImage source.
textureImage source.
xpos,yposPosition of where image grid starts.
width,heightSize of a frame in the grid.
xarray,yarrayNumber of columns and rows in grid.
array_skipframesNumber of frames to skip at last gridline.
xspacing,yspacingPixel interspacing between grid frames.

◆ get_frames()

const std::vector< CursorDescriptionFrame > & clan::CursorDescription::get_frames ( ) const

Returns a list over all available frames.

◆ get_hotspot()

Point clan::CursorDescription::get_hotspot ( ) const

the offset of where the cursor is drawn relative to cursor image

◆ load()

static CursorDescription clan::CursorDescription::load ( GraphicContext & gc,
const std::string & resource_id,
const XMLResourceDocument & doc,
const ImageImportDescription & import_desc = ImageImportDescription() )
static

Loads a CursorDescription from a XML resource definition.

◆ operator!=()

bool clan::CursorDescription::operator!= ( const CursorDescription & that) const
inline

◆ operator<()

bool clan::CursorDescription::operator< ( const CursorDescription & that) const
inline

◆ operator<=()

bool clan::CursorDescription::operator<= ( const CursorDescription & that) const
inline

◆ operator=()

CursorDescription & clan::CursorDescription::operator= ( const CursorDescription & copy)

Copy assignment operator.

◆ operator==()

bool clan::CursorDescription::operator== ( const CursorDescription & that) const
inline

◆ operator>()

bool clan::CursorDescription::operator> ( const CursorDescription & that) const
inline

◆ operator>=()

bool clan::CursorDescription::operator>= ( const CursorDescription & that) const
inline

◆ set_frame_delay()

void clan::CursorDescription::set_frame_delay ( int frame,
double delay )

Sets the duration this frame is displayed, in seconds.

◆ set_hotspot()

void clan::CursorDescription::set_hotspot ( const Point & hotspot)

Sets the offset of where the cursor is drawn relative to the cursor image.


The documentation for this class was generated from the following file: