cursor_description.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore 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 "UICore/Display/Render/graphic_context.h"
32 #include "UICore/Display/Render/texture_2d.h"
33 #include "../Image/pixel_buffer.h"
34 #include <vector>
35 
36 namespace uicore
37 {
38  class CursorDescription_Impl;
39 
42  {
43 
44  public:
45 
50  CursorDescriptionFrame(PixelBufferPtr pixelbuffer, Rect rect) : pixelbuffer(pixelbuffer), rect(rect), delay(1.0) { }
51 
54  double delay;
55 
56  };
57 
66  {
67  public:
70 
75 
77 
79  const std::vector<CursorDescriptionFrame> &frames() const;
80 
82  Point hotspot() const;
83 
84  bool operator==(const CursorDescription &that) const { return impl == that.impl; }
85  bool operator!=(const CursorDescription &that) const { return impl != that.impl; }
86  bool operator<(const CursorDescription &that) const { return impl < that.impl; }
87  bool operator>(const CursorDescription &that) const { return impl > that.impl; }
88  bool operator<=(const CursorDescription &that) const { return impl <= that.impl; }
89  bool operator>=(const CursorDescription &that) const { return impl >= that.impl; }
90 
93 
99  void add_frame(const PixelBufferPtr &pixelbuffer);
100 
102  void add_frame(const std::string &filename, const ImageImportDescription &import_desc = ImageImportDescription());
103 
108  void add_frame(const IODevicePtr &file, const std::string &image_type, const ImageImportDescription &import_desc = ImageImportDescription());
109 
111 
120  const PixelBufferPtr &pixelbuffer,
121  int xpos, int ypos,
122  int width, int height,
123  int xarray = 1, int yarray = 1,
124  int array_skipframes = 0,
125  int xspacing = 0, int yspacing = 0);
126 
128 
138  const PixelBufferPtr &pixelbuffer,
139  int xpos = 0, int ypos = 0,
140  float trans_limit = 0.05f);
141 
143 
152  const PixelBufferPtr &pixelbuffer,
153  int xpos = 0, int ypos = 0,
154  float trans_limit = 0.05f);
155 
157  void set_frame_delay(int frame, double delay);
158 
160  void set_hotspot(const Point &hotspot);
161 
162  private:
163  std::shared_ptr<CursorDescription_Impl> impl;
164  };
165 }
void add_gridclipped_frames(const PixelBufferPtr &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.
bool operator==(const CursorDescription &that) const
Definition: cursor_description.h:84
bool operator>=(const CursorDescription &that) const
Definition: cursor_description.h:89
double delay
Definition: cursor_description.h:54
bool operator!=(const CursorDescription &that) const
Definition: cursor_description.h:85
Rect rect
Definition: cursor_description.h:53
bool operator<(const CursorDescription &that) const
Definition: cursor_description.h:86
Image Import Description Class.
Definition: image_import_description.h:45
void add_alphaclipped_frames_free(const PixelBufferPtr &pixelbuffer, int xpos=0, int ypos=0, float trans_limit=0.05f)
Adds images separated with pure alpha (within trans_limit).
void set_frame_delay(int frame, double delay)
Sets the duration this frame is displayed, in seconds.
bool operator<=(const CursorDescription &that) const
Definition: cursor_description.h:88
void set_hotspot(const Point &hotspot)
Sets the offset of where the cursor is drawn relative to the cursor image.
std::shared_ptr< IODevice > IODevicePtr
Definition: iodevice.h:85
2D (x,y) point structure - Integer
Definition: point.h:58
CursorDescription()
Constructs a cursor description.
const std::vector< CursorDescriptionFrame > & frames() const
Returns a list over all available frames.
CursorDescriptionFrame(PixelBufferPtr pixelbuffer, Rect rect)
Constructs a CursorDescriptionFrame.
Definition: cursor_description.h:50
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:491
bool operator>(const CursorDescription &that) const
Definition: cursor_description.h:87
void add_frame(const PixelBufferPtr &pixelbuffer)
Adds a single image.
void add_alphaclipped_frames(const PixelBufferPtr &pixelbuffer, int xpos=0, int ypos=0, float trans_limit=0.05f)
Adds images separated with pure alpha (within trans_limit).
CursorDescription & operator=(const CursorDescription &copy)
Copy assignment operator.
std::shared_ptr< PixelBuffer > PixelBufferPtr
Definition: d3d_target.h:39
This class describes a single frame in a cursor description.
Definition: cursor_description.h:41
Point hotspot() const
the offset of where the cursor is drawn relative to cursor image
Definition: Application/application.h:35
PixelBufferPtr pixelbuffer
Definition: cursor_description.h:52
This class contains everything to construct a cursor - its data, default settings etc...
Definition: cursor_description.h:65