Utility/Icon: Make Icon a RefCounted object
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_ICON_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
@@ -16,22 +17,29 @@ namespace Nz
|
||||
class Image;
|
||||
class IconImpl;
|
||||
|
||||
class NAZARA_UTILITY_API Icon
|
||||
class Icon;
|
||||
|
||||
using IconRef = ObjectRef<Icon>;
|
||||
|
||||
class NAZARA_UTILITY_API Icon : public RefCounted
|
||||
{
|
||||
friend class WindowImpl;
|
||||
|
||||
public:
|
||||
Icon();
|
||||
~Icon();
|
||||
inline Icon();
|
||||
inline explicit Icon(const Image& icon);
|
||||
inline ~Icon();
|
||||
|
||||
bool Create(const Image& icon);
|
||||
void Destroy();
|
||||
|
||||
bool IsValid() const;
|
||||
inline bool IsValid() const;
|
||||
|
||||
private:
|
||||
IconImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Icon.inl>
|
||||
|
||||
#endif // NAZARA_ICON_HPP
|
||||
|
||||
42
include/Nazara/Utility/Icon.inl
Normal file
42
include/Nazara/Utility/Icon.inl
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
Icon::Icon() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
inline Icon::Icon(const Image& icon)
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(icon);
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool Icon::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
IconRef Icon::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<Icon> object(new Icon(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -15,18 +15,18 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Utility/CursorController.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <Nazara/Utility/Icon.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
#include <queue>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Cursor;
|
||||
class Image;
|
||||
class Icon;
|
||||
class WindowImpl;
|
||||
|
||||
class NAZARA_UTILITY_API Window
|
||||
@@ -86,7 +86,7 @@ namespace Nz
|
||||
inline void SetCursor(SystemCursor systemCursor);
|
||||
void SetEventListener(bool listener);
|
||||
void SetFocus();
|
||||
void SetIcon(const Icon& icon);
|
||||
void SetIcon(IconRef icon);
|
||||
void SetMaximumSize(const Vector2i& maxSize);
|
||||
void SetMaximumSize(int width, int height);
|
||||
void SetMinimumSize(const Vector2i& minSize);
|
||||
@@ -126,6 +126,7 @@ namespace Nz
|
||||
CursorController m_cursorController;
|
||||
CursorRef m_cursor;
|
||||
EventHandler m_eventHandler;
|
||||
IconRef m_icon;
|
||||
Mutex m_eventMutex;
|
||||
Mutex m_eventConditionMutex;
|
||||
bool m_asyncWindow;
|
||||
|
||||
Reference in New Issue
Block a user