Utility/Cursor: Add GetImage() method

This commit is contained in:
Lynix 2017-01-15 22:41:48 +01:00
parent c9458eeb17
commit 954298dc1e
3 changed files with 41 additions and 19 deletions

View File

@ -10,29 +10,33 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Vector2.hpp> #include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp> #include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Image.hpp>
namespace Nz namespace Nz
{ {
class CursorImpl; class CursorImpl;
class Image;
class NAZARA_UTILITY_API Cursor class NAZARA_UTILITY_API Cursor
{ {
friend class WindowImpl; friend class WindowImpl;
public: public:
Cursor(); inline Cursor();
~Cursor(); inline ~Cursor();
bool Create(const Image& cursor, int hotSpotX = 0, int hotSpotY = 0); bool Create(const Image& cursor, int hotSpotX = 0, int hotSpotY = 0);
bool Create(const Image& cursor, const Vector2i& hotSpot); bool Create(const Image& cursor, const Vector2i& hotSpot);
void Destroy(); void Destroy();
bool IsValid() const; inline const Image& GetImage() const;
inline bool IsValid() const;
private: private:
Image m_cursorImage;
CursorImpl* m_impl; CursorImpl* m_impl;
}; };
} }
#include <Nazara/Utility/Cursor.inl>
#endif // NAZARA_CURSOR_HPP #endif // NAZARA_CURSOR_HPP

View File

@ -0,0 +1,31 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/Cursor.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
inline Cursor::Cursor() :
m_impl(nullptr)
{
}
inline Cursor::~Cursor()
{
Destroy();
}
inline const Image& Cursor::GetImage() const
{
return m_cursorImage;
}
inline bool Cursor::IsValid() const
{
return m_impl != nullptr;
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@ -16,16 +16,6 @@
namespace Nz namespace Nz
{ {
Cursor::Cursor() :
m_impl(nullptr)
{
}
Cursor::~Cursor()
{
Destroy();
}
bool Cursor::Create(const Image& cursor, int hotSpotX, int hotSpotY) bool Cursor::Create(const Image& cursor, int hotSpotX, int hotSpotY)
{ {
Destroy(); Destroy();
@ -40,6 +30,8 @@ namespace Nz
return false; return false;
} }
m_cursorImage = cursor;
return true; return true;
} }
@ -58,9 +50,4 @@ namespace Nz
m_impl = nullptr; m_impl = nullptr;
} }
} }
bool Cursor::IsValid() const
{
return m_impl != nullptr;
}
} }