wavelength 1.0.0
Loading...
Searching...
No Matches
rndcursor.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <list>
5#include <memory>
6
7#include "os/binstream.h"
8#include "os/mem.h"
9#include "os/prnstream.h"
10#include "rnd/rndanimatable.h"
11#include "rnd/rndblur.h"
12#include "rnd/rnddrawable.h"
13#include "rnd/rndmesh.h"
14#include "rnd/rndtext.h"
15
24class RndCursor : public RndAnimatable, public RndDrawable {
25public:
33 explicit RndCursor(const char *pszName);
34
41 ~RndCursor() override;
42
49 void *operator new(size_t nSize) {
50 return PoolMemAlloc(static_cast<int>(nSize), "Cursor", 0);
51 }
52
58 void operator delete(void *pBlock) {
59 PoolMemFree(pBlock);
60 }
61
69 float EndFrame() override;
70
78 void ListDrawObjects(std::list<RndObject *> &objects) override;
79
87 void ListDrawables(std::list<RndDrawable *> &drawables) override;
88
99 int DrawShowing() override;
100
110 void DumpText(PrnStream &stream) override;
111
119 void Save(BinStream &stream) override;
120
129 void Replace(RndObject *pFrom, RndObject *pTo) override;
130
138 const char *ClassName() const override {
139 return sClassName;
140 }
141
150 void Copy(const RndObject *pSource, int nFlags) override;
151
159 void Load(BinStream &stream) override;
160
168 void SetText(RndText *pText);
169
179
189
199
209 void BuildMask();
210
220 float CursorPos();
221
230 static RndObject *New(const char *pszName) {
231 return new RndCursor(pszName);
232 }
233
240 static const char *sClassName;
241
248 static int sRev;
249
255 static int sLoadRev;
256
257private:
258 RndText *mText;
259 RndBlur *mBlur;
260 std::unique_ptr<RndBlur> mCursor;
261 std::unique_ptr<RndMesh> mMask;
262 float mOffset;
263 float mStutter;
264 float mWidth;
265 float mStartX;
266 float mCenterZ;
267};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
RndAnimatable()
Construct an animatable at frame 0 without children or filters.
Definition rndanimatable.h:600
Motion trail that draws a mesh or a text again at the transforms it recently occupied.
Definition rndblur.h:21
void Save(BinStream &stream) override
Write the cursor and its bases.
void Load(BinStream &stream) override
Read what Save() wrote.
~RndCursor() override
Drop the references and delete the mask and the internal blur.
void ReleaseRefs()
Drop the references on the text and the blur, and delete the mask and the internal blur.
static RndObject * New(const char *pszName)
Create a cursor.
Definition rndcursor.h:230
void SetText(RndText *pText)
Set the text the cursor sweeps, then rebuild the mask.
void BuildMask()
Replace the mask with a quad over the line of the text, and measure the line.
void AcquireRefs()
Take the references on the text and the blur, then build the mask and the internal blur.
void BuildCursor()
Replace the internal blur with a copy of mBlur, whose mesh is not drawn by itself.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndcursor.h:248
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a referenced text or blur with another, and rebuild what depends on it.
void ListDrawables(std::list< RndDrawable * > &drawables) override
Add the drawables of the text, then the children, to a list.
void DumpText(PrnStream &stream) override
Write a description of the cursor and its bases.
RndCursor(const char *pszName)
Construct a cursor without a text or a blur, offset by -0.1 and resting 0.8 of a frame.
static const char * sClassName
The class name a .rnd file writes, Cursor.
Definition rndcursor.h:240
float EndFrame() override
Report the last frame, the length of the text plus the rest at the end.
int DrawShowing() override
Move the mask and the internal blur to the cursor position and draw them with the text.
float CursorPos()
Report the character the cursor has reached, resting on each for mStutter of a frame.
void Copy(const RndObject *pSource, int nFlags) override
Copy another cursor and its bases.
void ListDrawObjects(std::list< RndObject * > &objects) override
Add the objects of the blur and of the text to a list.
static int sLoadRev
The version Load() read last.
Definition rndcursor.h:255
const char * ClassName() const override
Report the class name.
Definition rndcursor.h:138
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
RndObject(const char *pszName)
Construct an object and register it under a name.
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.