cursor_description.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 
30 #pragma once
31 
32 #include "../Render/graphic_context.h"
33 #include "../Render/texture_2d.h"
34 #include "../Image/pixel_buffer.h"
35 #include <vector>
36 
37 namespace clan
38 {
41 
42 class CursorDescription_Impl;
43 class XMLResourceDocument;
44 
47 {
48 
49 public:
50 
56 
59  double delay;
60 
61 };
62 
71 {
74 public:
77 
82 
84 
86  static CursorDescription load(GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &doc, const ImageImportDescription &import_desc = ImageImportDescription());
87 
91 public:
93  const std::vector<CursorDescriptionFrame> &get_frames() const;
94 
96  Point get_hotspot() const;
97 
98  bool operator==(const CursorDescription &that) const { return impl == that.impl; }
99  bool operator!=(const CursorDescription &that) const { return impl != that.impl; }
100  bool operator<(const CursorDescription &that) const { return impl < that.impl; }
101  bool operator>(const CursorDescription &that) const { return impl > that.impl; }
102  bool operator<=(const CursorDescription &that) const { return impl <= that.impl; }
103  bool operator>=(const CursorDescription &that) const { return impl >= that.impl; }
104 
108 public:
111 
117  void add_frame(const PixelBuffer &pixelbuffer);
118 
122  void add_frame(const std::string &fullname, const ImageImportDescription &import_desc = ImageImportDescription ());
123 
128  void add_frame(IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc = ImageImportDescription ());
129 
134  void add_frame(const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc = ImageImportDescription ());
135 
137 
146  const PixelBuffer &pixelbuffer,
147  int xpos, int ypos,
148  int width, int height,
149  int xarray = 1, int yarray = 1,
150  int array_skipframes = 0,
151  int xspacing = 0, int yspacing = 0);
152 
154 
164  const PixelBuffer &pixelbuffer,
165  int xpos = 0, int ypos = 0,
166  float trans_limit = 0.05f);
167 
169 
178  const PixelBuffer &pixelbuffer,
179  int xpos = 0, int ypos = 0,
180  float trans_limit = 0.05f);
181 
183  void set_frame_delay(int frame, double delay);
184 
186  void set_hotspot(const Point &hotspot);
187 
191 private:
193  std::shared_ptr<CursorDescription_Impl> impl;
195 };
196 
197 }
198 
2D (x,y) point structure - Integer
Definition: point.h:63
void set_hotspot(const Point &hotspot)
Sets the offset of where the cursor is drawn relative to the cursor image.
bool operator>(const CursorDescription &that) const
Definition: cursor_description.h:101
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.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
Image Import Description Class.
Definition: image_import_description.h:49
CursorDescriptionFrame(PixelBuffer pixelbuffer, Rect rect)
Constructs a CursorDescriptionFrame.
Definition: cursor_description.h:55
bool operator>=(const CursorDescription &that) const
Definition: cursor_description.h:103
const std::vector< CursorDescriptionFrame > & get_frames() const
Returns a list over all available frames.
I/O Device interface.
Definition: iodevice.h:51
void add_frame(IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
void add_frame(const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
CursorDescription & operator=(const CursorDescription &copy)
Copy assignment operator.
bool operator<=(const CursorDescription &that) const
Definition: cursor_description.h:102
Rect rect
Definition: cursor_description.h:58
Interface to drawing graphics.
Definition: graphic_context.h:258
void set_frame_delay(int frame, double delay)
Sets the duration this frame is displayed, in seconds.
PixelBuffer pixelbuffer
Definition: cursor_description.h:57
This class contains everything to construct a cursor - its data, default settings etc.
Definition: cursor_description.h:71
Point get_hotspot() const
the offset of where the cursor is drawn relative to cursor image
double delay
Definition: cursor_description.h:59
bool operator!=(const CursorDescription &that) const
Definition: cursor_description.h:99
Definition: clanapp.h:36
Virtual File System (VFS).
Definition: file_system.h:48
XML Resource Document.
Definition: xml_resource_document.h:49
Pixel data container.
Definition: pixel_buffer.h:69
bool operator<(const CursorDescription &that) const
Definition: cursor_description.h:100
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.
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_frame(const std::string &fullname, const ImageImportDescription &import_desc=ImageImportDescription())
Add frame.
void add_frame(const PixelBuffer &pixelbuffer)
Adds a single image.
CursorDescription(const CursorDescription &copy)
Constructs a CursorDescription.
bool operator==(const CursorDescription &that) const
Definition: cursor_description.h:98
This class describes a single frame in a cursor description.
Definition: cursor_description.h:47
CursorDescription()
Constructs a cursor description.
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).