summaryrefslogtreecommitdiff
path: root/src/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/render.c')
-rw-r--r--src/render.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/render.c b/src/render.c
index 24490c0..b1fd3e8 100644
--- a/src/render.c
+++ b/src/render.c
@@ -186,6 +186,8 @@ static void RenderTable(const uiTable* table, RenderState* state) {
186 uiRect original_subsurface = {0}; 186 uiRect original_subsurface = {0};
187 uiPoint original_pen = {0}; 187 uiPoint original_pen = {0};
188 188
189 int col_widths_sum = 0;
190
189 // Render header. 191 // Render header.
190 if (table->header) { 192 if (table->header) {
191 for (int col = 0; col < table->cols; ++col) { 193 for (int col = 0; col < table->cols; ++col) {
@@ -201,6 +203,9 @@ static void RenderTable(const uiTable* table, RenderState* state) {
201 // Reset the original subsurface and pen for subsequent columns. 203 // Reset the original subsurface and pen for subsequent columns.
202 PopSubsurface(state, &original_subsurface, &original_pen); 204 PopSubsurface(state, &original_subsurface, &original_pen);
203 205
206 // Keep track of the sum of column widths to later render the scroll bar.
207 col_widths_sum += table->widths[col];
208
204 // Next column. 209 // Next column.
205 state->pen.x += table->widths[col]; 210 state->pen.x += table->widths[col];
206 } 211 }
@@ -235,6 +240,23 @@ static void RenderTable(const uiTable* table, RenderState* state) {
235 state->pen.y += g_ui.font->header.glyph_height; 240 state->pen.y += g_ui.font->header.glyph_height;
236 } 241 }
237 state->pen.y = y0; 242 state->pen.y = y0;
243
244 // Render scrollbar.
245 if (table->flags.vertical_overflow) {
246 state->pen.x = col_widths_sum;
247
248 const int y_start = (int)((double)table->offset / (double)table->rows *
249 (double)table->height);
250
251 const int height = (int)((double)table->num_visible_rows /
252 (double)table->rows * (double)table->height);
253
254 FillRect(
255 &(uiRect){.y = y_start, .width = ScrollBarWidth, .height = height},
256 uiPink, state);
257
258 state->pen.x = x0;
259 }
238} 260}
239 261
240/// Render a widget. 262/// Render a widget.