Skip to content

Commit 44d1b8f

Browse files
committed
Cleanup
Reserve just enough space for the cursor
1 parent 8793be5 commit 44d1b8f

4 files changed

Lines changed: 103 additions & 89 deletions

File tree

source/engine/engine.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ namespace text
6464
// A rendered text label, ready to be drawn
6565
class Label
6666
{
67-
GLuint tex;
6867
int w, h;
6968
int ox, oy; // offsets
69+
GLuint tex;
7070
_PangoLayout *layout;
7171
int *map_markup_to_text;
7272
int *map_text_to_markup;
@@ -93,15 +93,14 @@ namespace text
9393
// do not call if the label was not prepared with `keep_layout=true`
9494
int xy_to_index(float x, float y) const;
9595

96-
friend Label prepare(const char *, int, bvec, int, double, bvec4, int, int, const char *, bool, bool);
96+
friend Label prepare(const char *, int, bvec, int, double, bvec4, int, int, const char *, bool, bool, bool);
9797
};
9898

9999
// measure text before creating the label
100-
// TODO: consider removing in favor of `Label::prepare()`
101100
void measure(const char *str, int maxw, int &w, int &h,
102101
int align = -1,
103102
int justify = 0,
104-
const char *lang = NULL,
103+
const char *lang = nullptr,
105104
bool no_fallback = false
106105
);
107106

@@ -112,26 +111,27 @@ namespace text
112111
bvec4 ol_color = bvec4(0, 0, 0, 0),
113112
int align = -1,
114113
int justify = 0,
115-
const char *lang = NULL, // language code, used for text shaping
114+
const char *lang = nullptr, // language code, used for text shaping
116115
bool no_fallback = false, // don't use fallback fonts for unavailable glyphs
117-
bool keep_layout = false // use only if you need to call `xy_to_index()`
116+
bool keep_layout = false, // use only if you need to call `xy_to_index()`
117+
bool reserve_cursor = false // reserve space for the cursor, even if the cursor is absent
118118
);
119119
Label prepare_for_console(const char *str, int maxw, int cursor);
120120
const Label& prepare_for_particle(const char *str,
121121
bvec color = bvec(255, 255, 255),
122122
double outline = 0,
123123
bvec4 ol_color = bvec4(0, 0, 0, 0),
124-
const char *lang = NULL,
124+
const char *lang = nullptr,
125125
bool no_fallback = false
126126
);
127127

128128
void draw(const char *str, double left, double top,
129129
bvec color = bvec(255, 255, 255),
130-
int a = 255,
130+
int alpha = 255,
131131
int maxw = 0,
132132
int align = -1,
133133
int justify = 0,
134-
const char *lang = NULL,
134+
const char *lang = nullptr,
135135
bool no_fallback = false
136136
);
137137
static inline void draw_fmt(const char *fstr, double left, double top, ...)
@@ -153,13 +153,13 @@ namespace text
153153
int visible(const char *str, float hitx, float hity, int maxw,
154154
int align = -1,
155155
int justify = 0,
156-
const char *lang = NULL,
156+
const char *lang = nullptr,
157157
bool no_fallback = false
158158
);
159159
void pos(const char *str, int cursor, int &cx, int &cy, int maxw,
160160
int align = -1,
161161
int justify = 0,
162-
const char *lang = NULL,
162+
const char *lang = nullptr,
163163
bool no_fallback = false
164164
);
165165
}

0 commit comments

Comments
 (0)