cursor_description.h Source File - ClanLib SDK
Description: cursor_description.h Source File

cursor_description.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Kenneth Gangstoe
27*/
28
29#pragma once
30
31#include "../Render/graphic_context.h"
32#include "../Render/texture_2d.h"
33#include "../Image/pixel_buffer.h"
34#include <vector>
35
36namespace clan
37{
40
41 class CursorDescription_Impl;
42 class XMLResourceDocument;
43
45 class CursorDescriptionFrame
46 {
47
48 public:
49
54 CursorDescriptionFrame(PixelBuffer pixelbuffer, Rect rect) : pixelbuffer(pixelbuffer), rect(rect), delay(1.0) { }
55
56 PixelBuffer pixelbuffer;
57 Rect rect;
58 double delay;
59
60 };
61
69 class CursorDescription
70 {
71 public:
73 CursorDescription();
74
78 CursorDescription(const CursorDescription &copy);
79
80 ~CursorDescription();
81
83 static CursorDescription load(GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &doc, const ImageImportDescription &import_desc = ImageImportDescription());
84
86 const std::vector<CursorDescriptionFrame> &get_frames() const;
87
89 Point get_hotspot() const;
90
91 bool operator==(const CursorDescription &that) const { return impl == that.impl; }
92 bool operator!=(const CursorDescription &that) const { return impl != that.impl; }
93 bool operator<(const CursorDescription &that) const { return impl < that.impl; }
94 bool operator>(const CursorDescription &that) const { return impl > that.impl; }
95 bool operator<=(const CursorDescription &that) const { return impl <= that.impl; }
96 bool operator>=(const CursorDescription &that) const { return impl >= that.impl; }
97
99 CursorDescription &operator =(const CursorDescription &copy);
100
106 void add_frame(const PixelBuffer &pixelbuffer);
107
111 void add_frame(const std::string &fullname, const ImageImportDescription &import_desc = ImageImportDescription());
112
117 void add_frame(IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc = ImageImportDescription());
118
123 void add_frame(const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc = ImageImportDescription());
124
126
134 void add_gridclipped_frames(
135 const PixelBuffer &pixelbuffer,
136 int xpos, int ypos,
137 int width, int height,
138 int xarray = 1, int yarray = 1,
139 int array_skipframes = 0,
140 int xspacing = 0, int yspacing = 0);
141
143
152 void add_alphaclipped_frames(
153 const PixelBuffer &pixelbuffer,
154 int xpos = 0, int ypos = 0,
155 float trans_limit = 0.05f);
156
158
166 void add_alphaclipped_frames_free(
167 const PixelBuffer &pixelbuffer,
168 int xpos = 0, int ypos = 0,
169 float trans_limit = 0.05f);
170
172 void set_frame_delay(int frame, double delay);
173
175 void set_hotspot(const Point &hotspot);
176
177 private:
178 std::shared_ptr<CursorDescription_Impl> impl;
179 };
180
182}
clan::CursorDescriptionFrame::delay
double delay
Definition cursor_description.h:58
clan::CursorDescriptionFrame::pixelbuffer
PixelBuffer pixelbuffer
Definition cursor_description.h:56
clan::CursorDescriptionFrame::rect
Rect rect
Definition cursor_description.h:57
clan::CursorDescriptionFrame::CursorDescriptionFrame
CursorDescriptionFrame(PixelBuffer pixelbuffer, Rect rect)
Constructs a CursorDescriptionFrame.
Definition cursor_description.h:54
clan::CursorDescription::operator=
CursorDescription & operator=(const CursorDescription &copy)
Copy assignment operator.
clan::CursorDescription::get_hotspot
Point get_hotspot() const
the offset of where the cursor is drawn relative to cursor image
clan::CursorDescription::add_alphaclipped_frames_free
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).
clan::CursorDescription::set_frame_delay
void set_frame_delay(int frame, double delay)
Sets the duration this frame is displayed, in seconds.
clan::CursorDescription::CursorDescription
CursorDescription()
Constructs a cursor description.
clan::CursorDescription::add_frame
void add_frame(const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
clan::CursorDescription::add_frame
void add_frame(const PixelBuffer &pixelbuffer)
Adds a single image.
clan::CursorDescription::CursorDescription
CursorDescription(const CursorDescription &copy)
Constructs a CursorDescription.
clan::CursorDescription::operator>
bool operator>(const CursorDescription &that) const
Definition cursor_description.h:94
clan::CursorDescription::load
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.
clan::CursorDescription::operator>=
bool operator>=(const CursorDescription &that) const
Definition cursor_description.h:96
clan::CursorDescription::operator==
bool operator==(const CursorDescription &that) const
Definition cursor_description.h:91
clan::CursorDescription::operator<=
bool operator<=(const CursorDescription &that) const
Definition cursor_description.h:95
clan::CursorDescription::get_frames
const std::vector< CursorDescriptionFrame > & get_frames() const
Returns a list over all available frames.
clan::CursorDescription::~CursorDescription
~CursorDescription()
clan::CursorDescription::add_alphaclipped_frames
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).
clan::CursorDescription::set_hotspot
void set_hotspot(const Point &hotspot)
Sets the offset of where the cursor is drawn relative to the cursor image.
clan::CursorDescription::add_frame
void add_frame(const std::string &fullname, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
clan::CursorDescription::operator!=
bool operator!=(const CursorDescription &that) const
Definition cursor_description.h:92
clan::CursorDescription::operator<
bool operator<(const CursorDescription &that) const
Definition cursor_description.h:93
clan::CursorDescription::add_frame
void add_frame(IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
clan::CursorDescription::add_gridclipped_frames
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.
clan::FileSystem
Virtual File System (VFS).
Definition file_system.h:47
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::IODevice
I/O Device interface.
Definition iodevice.h:50
clan::ImageImportDescription
Image Import Description Class.
Definition image_import_description.h:48
clan::PixelBuffer
Pixel data container.
Definition pixel_buffer.h:68
clan::Point
2D (x,y) point structure - Integer
Definition point.h:62
clan::Rect
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
clan::XMLResourceDocument
XML Resource Document.
Definition xml_resource_document.h:48
clan
Definition clanapp.h:36