cursor_description.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 "../api_display.h"
33 #include "../Render/graphic_context.h"
34 #include "../Render/texture_2d.h"
35 #include "../Image/pixel_buffer.h"
36 #include <vector>
37 
38 namespace clan
39 {
42 
43 class CursorDescription_Impl;
44 class XMLResourceDocument;
45 
48 {
49 
50 public:
51 
56  CursorDescriptionFrame(PixelBuffer pixelbuffer, Rect rect) : pixelbuffer(pixelbuffer), rect(rect), delay(1.0) { }
57 
60  double delay;
61 
62 };
63 
71 class CL_API_DISPLAY CursorDescription
72 {
75 public:
81 
87  CursorDescription(GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &resources, const ImageImportDescription &import_desc = ImageImportDescription ());
88 
93 
95 
99 public:
101  const std::vector<CursorDescriptionFrame> &get_frames() const;
102 
106 public:
108  CursorDescription &operator =(const CursorDescription &copy);
109 
115  void add_frame(const PixelBuffer &pixelbuffer);
116 
120  void add_frame(const std::string &fullname, const ImageImportDescription &import_desc = ImageImportDescription ());
121 
126  void add_frame(IODevice &file, const std::string &image_type, const ImageImportDescription &import_desc = ImageImportDescription ());
127 
132  void add_frame(const std::string &filename, FileSystem &fs, const ImageImportDescription &import_desc = ImageImportDescription ());
133 
135 
143  void add_gridclipped_frames(
144  const PixelBuffer &pixelbuffer,
145  int xpos, int ypos,
146  int width, int height,
147  int xarray = 1, int yarray = 1,
148  int array_skipframes = 0,
149  int xspacing = 0, int yspacing = 0);
150 
152 
161  void add_alphaclipped_frames(
162  const PixelBuffer &pixelbuffer,
163  int xpos = 0, int ypos = 0,
164  float trans_limit = 0.05f);
165 
167 
175  void add_alphaclipped_frames_free(
176  const PixelBuffer &pixelbuffer,
177  int xpos = 0, int ypos = 0,
178  float trans_limit = 0.05f);
179 
181  void set_frame_delay(int frame, double delay);
182 
186 private:
188  std::shared_ptr<CursorDescription_Impl> impl;
190 };
191 
192 }
193 
I/O Device interface.
Definition: iodevice.h:51
Pixel data container.
Definition: pixel_buffer.h:69
Image Import Description Class.
Definition: image_import_description.h:49
CursorDescriptionFrame(PixelBuffer pixelbuffer, Rect rect)
Constructs a CursorDescriptionFrame.
Definition: cursor_description.h:56
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
Rect rect
Definition: cursor_description.h:59
Virtual File System (VFS).
Definition: file_system.h:48
This class contains everything to construct a cursor - its data, default settings etc...
Definition: cursor_description.h:71
Interface to drawing graphics.
Definition: graphic_context.h:257
XML Resource Document.
Definition: xml_resource_document.h:49
PixelBuffer pixelbuffer
Definition: cursor_description.h:58
This class describes a single frame in a cursor description.
Definition: cursor_description.h:47
double delay
Definition: cursor_description.h:60