resonance 1.0.1
Loading...
Searching...
No Matches
scrollinglist.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
7#include "rnd/transformable.h"
8
9namespace Rnd {
10class Drawable;
11class Mesh;
12class Object;
13class Text;
14class View;
15} // namespace Rnd
16
46public:
68 int nRowPitch,
69 int nRowCount,
70 Rnd::View *pTemplate,
71 Rnd::Mesh *pHighlight,
72 Rnd::Mesh *pUpArrow,
73 Rnd::Mesh *pDownArrow,
74 int nContext);
75
86 virtual ~ScrollingList();
87
98 void refresh();
99
110 void scrollUp();
111
122
134 void setItemCount(int nItemCount);
135
144
155 void setSelected(int nSelected);
156
167 void setShowing(int nShowing);
168
179 void setEntriesShowing(int nShowing);
180
181private:
182 // One cell of a row. Exactly one of the two pointers is set.
183 struct Cell {
184 Rnd::Text *mText;
185 Rnd::Mesh *mMesh;
186 };
187
194 Rnd::View *makeRow(int nIndex);
195
203 void buildRowCells(Rnd::View *pRow);
204
211 void updateHighlight();
212
219 void updateArrows();
220
221 ListDataProvider *mProvider;
222 int mReserved; // +0x04, cleared by the constructor and read nowhere
223 int mRowCount;
224 int mItemCount;
225 int mCursorRow;
226 int mSelected;
227 int mRowPitch;
228 // The number of the template's children. Written by the constructor and read nowhere.
229 int mTemplateDrawCount;
230 Rnd::View *mTemplate;
231 Rnd::Mesh *mHighlight;
232 Rnd::Mesh *mUpArrow;
233 Rnd::Mesh *mDownArrow;
234 // The highlight mesh's local transform at construction, which places it on the first row.
235 float mHighlightXfm[Rnd::kXfmRowCount][Rnd::kXfmRowFloatCount];
236 std::list<std::vector<Cell>> mRowCells;
237 std::vector<Rnd::View *> mRows;
238 std::vector<Rnd::Drawable *> mTextCells;
239 int mShowing;
240 int mContext;
241};
Mix-in for an object that supplies the rows of a scrolling list to the screen that draws it.
Definition listdataprovider.h:30
Mix-in for an object that draws itself and then a list of other drawables.
Definition drawable.h:32
Indexed triangle mesh with one material.
Definition mesh.h:46
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Run of text drawn as a quad per glyph.
Definition text.h:57
Root of a loadable scene.
Definition view.h:47
virtual ~ScrollingList()
Delete every row clone together with every object it references.
void scrollDown()
Move the selection down by one item.
int getSelected()
Report the selected item.
void setEntriesShowing(int nShowing)
Pass a showing flag to every Text cell.
void scrollUp()
Move the selection up by one item.
void setShowing(int nShowing)
Record the showing flag and pass it to the highlight mesh.
void setItemCount(int nItemCount)
Record the number of items and clamp the selection to it.
void refresh()
Show the rows that have an item and fill their cells, and hide the rest.
ScrollingList(ListDataProvider *pProvider, int nRowPitch, int nRowCount, Rnd::View *pTemplate, Rnd::Mesh *pHighlight, Rnd::Mesh *pUpArrow, Rnd::Mesh *pDownArrow, int nContext)
Build the rows from the template view.
void setSelected(int nSelected)
Select one item and place the cursor row so the page ends at the last item where it can.
The rendering engine.
Definition animhelper.h:3
constexpr int kXfmRowFloatCount
Floats in one transform row.
Definition transformable.h:15
constexpr int kXfmRowCount
Rows in one transform.
Definition transformable.h:12