mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[ui] Split flowed line separation
The separation now uses height above (right of) the base line, and depth below (left of) the base line. This puts the text exactly where I want it, but there's still the problem of uneven line spacing caused by descenders and ascenders. However, I suspect that's more up to the text/font handling code to get the boxes right (maybe set spaces to have the right dimensions?).
This commit is contained in:
parent
490217a136
commit
65214fb7f8
1 changed files with 16 additions and 7 deletions
|
@ -294,7 +294,8 @@ typedef struct flowline_s {
|
|||
int first_child;
|
||||
int child_count;
|
||||
int cursor;
|
||||
int height;
|
||||
int height; // from baseline
|
||||
int depth; // from baseline
|
||||
} flowline_t;
|
||||
|
||||
#define NEXT_LINE(line, child_index) \
|
||||
|
@ -326,7 +327,8 @@ flow_right (view_t view, void (*set_rows) (view_t, flowline_t *))
|
|||
if (pos[child].x || !cont[child].bol_suppress) {
|
||||
line->cursor += len[child].x;
|
||||
}
|
||||
line->height = max (len[child].y, line->height);
|
||||
line->height = max (len[child].y - pos[child].y, line->height);
|
||||
line->depth = max (pos[child].y, line->depth);
|
||||
line->child_count++;
|
||||
}
|
||||
set_rows (view, &flowline);
|
||||
|
@ -355,7 +357,8 @@ flow_left (view_t view, void (*set_rows) (view_t, flowline_t *))
|
|||
line->cursor -= len[child].x;
|
||||
}
|
||||
pos[child].x = line->cursor;
|
||||
line->height = max (len[child].y, line->height);
|
||||
line->height = max (len[child].y - pos[child].y, line->height);
|
||||
line->depth = max (pos[child].y, line->depth);
|
||||
line->child_count++;
|
||||
}
|
||||
set_rows (view, &flowline);
|
||||
|
@ -382,7 +385,8 @@ flow_down (view_t view, void (*set_rows) (view_t, flowline_t *))
|
|||
if (pos[child].y || !cont[child].bol_suppress) {
|
||||
line->cursor += len[child].y;
|
||||
}
|
||||
line->height = max (len[child].x, line->height);
|
||||
line->height = max (len[child].x - pos[child].x, line->height);
|
||||
line->depth = max (pos[child].x, line->depth);
|
||||
line->child_count++;
|
||||
}
|
||||
set_rows (view, &flowline);
|
||||
|
@ -411,7 +415,8 @@ flow_up (view_t view, void (*set_rows) (view_t, flowline_t *))
|
|||
line->cursor -= len[child].y;
|
||||
}
|
||||
pos[child].y = line->cursor;
|
||||
line->height = max (len[child].x, line->height);
|
||||
line->height = max (len[child].x - pos[child].x, line->height);
|
||||
line->depth = max (pos[child].x, line->depth);
|
||||
line->child_count++;
|
||||
}
|
||||
set_rows (view, &flowline);
|
||||
|
@ -422,7 +427,7 @@ flow_view_height (view_pos_t *len, flowline_t *flowlines)
|
|||
{
|
||||
len->y = 0;
|
||||
for (flowline_t *line = flowlines; line; line = line->next) {
|
||||
len->y += line->height;
|
||||
len->y += line->height + line->depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +436,7 @@ flow_view_width (view_pos_t *len, flowline_t *flowlines)
|
|||
{
|
||||
len->x = 0;
|
||||
for (flowline_t *line = flowlines; line; line = line->next) {
|
||||
len->x += line->height;
|
||||
len->x += line->height + line->depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,6 +464,7 @@ set_rows_down (view_t view, flowline_t *flowlines)
|
|||
rel[child].x = pos[child].x;
|
||||
rel[child].y = cursor + pos[child].y - len[child].y;
|
||||
}
|
||||
cursor += line->depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,6 +485,7 @@ set_rows_up (view_t view, flowline_t *flowlines)
|
|||
|
||||
int cursor = len[vind].y;
|
||||
for (flowline_t *line = flowlines; line; line = line->next) {
|
||||
cursor -= line->depth;
|
||||
for (int i = 0; i < line->child_count; i++) {
|
||||
uint32_t child = line->first_child + i;
|
||||
|
||||
|
@ -506,6 +513,7 @@ set_columns_right (view_t view, flowline_t *flowlines)
|
|||
|
||||
int cursor = 0;
|
||||
for (flowline_t *line = flowlines; line; line = line->next) {
|
||||
cursor += line->depth;
|
||||
for (int i = 0; i < line->child_count; i++) {
|
||||
uint32_t child = line->first_child + i;
|
||||
|
||||
|
@ -540,6 +548,7 @@ set_columns_left (view_t view, flowline_t *flowlines)
|
|||
rel[child].x = cursor + pos[child].x;
|
||||
rel[child].y = pos[child].y;
|
||||
}
|
||||
cursor -= line->depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue