-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanel_info.c
More file actions
50 lines (44 loc) · 1.4 KB
/
Copy pathpanel_info.c
File metadata and controls
50 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "common.h"
static void draw_arraysize(t_app_state *state, int ay)
{
char buf[64];
int sz_w;
DrawLineEx((Vector2){0, ay}, (Vector2){PANEL_WIDTH, ay}, 1.5f, COL_BORDER);
ay += 14;
DrawTxt("ARRAY SIZE", 14, ay, 11, COL_MUTED);
snprintf(buf, sizeof(buf), "%d", state->global_size);
sz_w = MeasureTxt(buf, 13);
DrawTxt(buf, PANEL_WIDTH - sz_w - 14, ay, 13, COL_TEXT);
ay += 22;
UiSlider(
(Rectangle){12, ay, PANEL_WIDTH - 40, 22},
"", &state->global_size, MIN_SIZE, MAX_SIZE);
DrawRectangle(PANEL_WIDTH - 40, ay - 2, 41, 26, COL_SURFACE);
}
static void draw_stats(t_sort_state *s, int sy)
{
char buf[64];
DrawLineEx((Vector2){0, sy}, (Vector2){PANEL_WIDTH, sy}, 1.5f, COL_BORDER);
sy += 14;
DrawTxt("STATS", 14, sy, 11, COL_MUTED);
sy += 22;
snprintf(buf, sizeof(buf), "Comparisons %ld", s->comparisons);
DrawTxt(buf, 14, sy, 13, COL_TEXT_DIM);
sy += 19;
snprintf(buf, sizeof(buf), "Swaps %ld", s->swaps);
DrawTxt(buf, 14, sy, 13, COL_TEXT_DIM);
sy += 19;
if (s->sorted)
DrawTxt("SORTED \xe2\x9c\x93", 14, sy, 13, COL_SORTED);
else
DrawTxt("Sorting...", 14, sy, 13, COL_MUTED);
}
void draw_panel_info(t_app_state *state, int arraysize_y, int stats_y)
{
t_sort_state *s;
BeginScissorMode(0, arraysize_y, PANEL_WIDTH, SCREEN_HEIGHT - arraysize_y);
draw_arraysize(state, arraysize_y);
s = &state->views[state->focused_view].state;
draw_stats(s, stats_y);
EndScissorMode();
}