75 lines
2.5 KiB
C++
75 lines
2.5 KiB
C++
// 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
|
|
|
|
#pragma once
|
|
|
|
#ifndef NAZARA_SIMPLETEXTDRAWER_HPP
|
|
#define NAZARA_SIMPLETEXTDRAWER_HPP
|
|
|
|
#include <Nazara/Prerequesites.hpp>
|
|
#include <Nazara/Core/String.hpp>
|
|
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
|
#include <Nazara/Utility/Enums.hpp>
|
|
#include <Nazara/Utility/Font.hpp>
|
|
#include <vector>
|
|
|
|
namespace Nz
|
|
{
|
|
class NAZARA_UTILITY_API SimpleTextDrawer : public AbstractTextDrawer
|
|
{
|
|
public:
|
|
SimpleTextDrawer();
|
|
SimpleTextDrawer(const SimpleTextDrawer& drawer);
|
|
SimpleTextDrawer(SimpleTextDrawer&& drawer);
|
|
virtual ~SimpleTextDrawer();
|
|
|
|
const Rectui& GetBounds() const override;
|
|
unsigned int GetCharacterSize() const;
|
|
const Color& GetColor() const;
|
|
Font* GetFont() const;
|
|
Font* GetFont(unsigned int index) const override;
|
|
unsigned int GetFontCount() const override;
|
|
const Glyph& GetGlyph(unsigned int index) const override;
|
|
unsigned int GetGlyphCount() const override;
|
|
UInt32 GetStyle() const;
|
|
const String& GetText() const;
|
|
|
|
void SetCharacterSize(unsigned int characterSize);
|
|
void SetColor(const Color& color);
|
|
void SetFont(Font* font);
|
|
void SetStyle(UInt32 style);
|
|
void SetText(const String& str);
|
|
|
|
SimpleTextDrawer& operator=(const SimpleTextDrawer& drawer);
|
|
SimpleTextDrawer& operator=(SimpleTextDrawer&& drawer);
|
|
|
|
static SimpleTextDrawer Draw(const String& str, unsigned int characterSize, UInt32 style = TextStyle_Regular, const Color& color = Color::White);
|
|
static SimpleTextDrawer Draw(Font* font, const String& str, unsigned int characterSize, UInt32 style = TextStyle_Regular, const Color& color = Color::White);
|
|
|
|
private:
|
|
void ConnectFontSlots();
|
|
void DisconnectFontSlots();
|
|
void OnFontAtlasLayerChanged(const Font* font, AbstractImage* oldLayer, AbstractImage* newLayer);
|
|
void OnFontInvalidated(const Font* font);
|
|
void OnFontRelease(const Font* object);
|
|
void UpdateGlyphs() const;
|
|
|
|
NazaraSlot(Font, OnFontAtlasChanged, m_atlasChangedSlot);
|
|
NazaraSlot(Font, OnFontAtlasLayerChanged, m_atlasLayerChangedSlot);
|
|
NazaraSlot(Font, OnFontGlyphCacheCleared, m_glyphCacheClearedSlot);
|
|
NazaraSlot(Font, OnFontRelease, m_fontReleaseSlot);
|
|
|
|
mutable std::vector<Glyph> m_glyphs;
|
|
Color m_color;
|
|
FontRef m_font;
|
|
mutable Rectui m_bounds;
|
|
String m_text;
|
|
UInt32 m_style;
|
|
mutable bool m_glyphUpdated;
|
|
unsigned int m_characterSize;
|
|
};
|
|
}
|
|
|
|
#endif // NAZARA_SIMPLETEXTDRAWER_HPP
|