mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MouseCursor refactoring.
This commit is contained in:
parent
8d2f81cf57
commit
d5dc5b2ba9
6 changed files with 70 additions and 36 deletions
|
|
@ -23,6 +23,23 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
struct CustomMouseCursorInfo
|
||||
{
|
||||
CustomMouseCursorInfo (const Image& im, int hsX, int hsY) noexcept
|
||||
: image (im), hotspot (hsX, hsY), scaleFactor (1.0f)
|
||||
{}
|
||||
|
||||
CustomMouseCursorInfo (const Image& im, const Point<int>& hs, float scale) noexcept
|
||||
: image (im), hotspot (hs), scaleFactor (scale)
|
||||
{}
|
||||
|
||||
void* create() const;
|
||||
|
||||
Image image;
|
||||
const Point<int> hotspot;
|
||||
float scaleFactor;
|
||||
};
|
||||
|
||||
class MouseCursor::SharedCursorHandle
|
||||
{
|
||||
public:
|
||||
|
|
@ -34,8 +51,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
SharedCursorHandle (const Image& image, const int hotSpotX, const int hotSpotY)
|
||||
: handle (createMouseCursorFromImage (image, hotSpotX, hotSpotY)),
|
||||
SharedCursorHandle (const Image& image, const Point<int>& hotSpot, const float scaleFactor)
|
||||
: handle (CustomMouseCursorInfo (image, hotSpot, scaleFactor).create()),
|
||||
refCount (1),
|
||||
standardType (MouseCursor::NormalCursor),
|
||||
isStandard (false)
|
||||
|
|
@ -120,7 +137,12 @@ MouseCursor::MouseCursor (const StandardCursorType type)
|
|||
}
|
||||
|
||||
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY)
|
||||
: cursorHandle (new SharedCursorHandle (image, hotSpotX, hotSpotY))
|
||||
: cursorHandle (new SharedCursorHandle (image, Point<int> (hotSpotX, hotSpotY), 1.0f))
|
||||
{
|
||||
}
|
||||
|
||||
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY, float scaleFactor)
|
||||
: cursorHandle (new SharedCursorHandle (image, Point<int> (hotSpotX, hotSpotY), scaleFactor))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue