| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "igui.h" |
| 4 |
#include "irenderable.h" |
| 5 |
#include "ifonts.h" |
| 6 |
#include <map> |
| 7 |
#include "RenderableCharacterBatch.h" |
| 8 |
|
| 9 |
namespace gui |
| 10 |
{ |
| 11 |
|
| 12 |
class IGuiWindowDef; |
| 13 |
|
| 14 |
class RenderableText : |
| 15 |
public IRenderableText |
| 16 |
{ |
| 17 |
// The owning windowDef |
| 18 |
const IGuiWindowDef& _owner; |
| 19 |
|
| 20 |
// The character soup, arranged into OpenGLRenderables, sorted by shader |
| 21 |
typedef std::map<ShaderPtr, RenderableCharacterBatchPtr> CharBatches; |
| 22 |
CharBatches _charBatches; |
| 23 |
|
| 24 |
// The font we're rendering |
| 25 |
fonts::IFontInfoPtr _font; |
| 26 |
|
| 27 |
// The resolution we're working with |
| 28 |
fonts::Resolution _resolution; |
| 29 |
|
| 30 |
private: |
| 31 |
void printMissingGlyphSetError() const; |
| 32 |
|
| 33 |
public: |
| 34 |
// Construct a renderable for the text in the given windowDef |
| 35 |
RenderableText(const IGuiWindowDef& owner); |
| 36 |
|
| 37 |
void render() override; |
| 38 |
|
| 39 |
// Re-construct this structure, called when the text in the owning windowDef has been changed |
| 40 |
void recompile() override; |
| 41 |
|
| 42 |
private: |
| 43 |
void realiseFontShaders(); |
| 44 |
void ensureFont(); |
| 45 |
|
| 46 |
// Calculates the horizontal alignment correction for the given line width |
| 47 |
// relative to the (default) left-aligned state |
| 48 |
double getAlignmentCorrection(double lineWidth); |
| 49 |
}; |
| 50 |
|
| 51 |
} // namespace |