aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index a22f6e7..9e3e551 100644
--- a/src/main.c
+++ b/src/main.c
@@ -396,6 +396,31 @@ static void show_pages() {
free_unused_pages(&pages);
}
+static void show_grid() {
+ double s = get_scale();
+ double offs_x = (SDL_floor(pos_x) - pos_x) * s;
+ double offs_y = (SDL_floor(pos_y) - pos_y) * s;
+ for (int i = 0; i < window_height / s; i++) {
+ if (((int)pos_y + i) % sizeof(long) == 0) {
+ SDL_SetRenderDrawColor(renderer, 80, 80, 80, 255);
+ } else {
+ SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255);
+ }
+ double y = offs_y + s*i;
+ SDL_RenderLine(renderer, 0, y, window_width, y);
+ }
+ for (int i = 0; i < window_width / s; i++) {
+ if (((int)pos_x + i) % sizeof(long) == 0) {
+ SDL_SetRenderDrawColor(renderer, 128, 128, 128, 255);
+ } else {
+ SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255);
+ }
+ double x = offs_x + s*i;
+ SDL_RenderLine(renderer, x, 0, x, window_height);
+ }
+ SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
+}
+
static SDL_Texture *missing_texture() {
static SDL_Texture *tex = NULL;
if (!tex) {
@@ -423,6 +448,7 @@ static void show() {
SDL_GetWindowSize(window, &window_width, &window_height);
SDL_RenderClear(renderer);
show_pages();
+ if (scale >= 4) show_grid();
SDL_RenderPresent(renderer);
if (current_menu) {
menu_render(current_menu);