diff --git a/.gitignore b/.gitignore index 7de9058..c9a7e47 100644 --- a/.gitignore +++ b/.gitignore @@ -93,4 +93,5 @@ tags # End of https://www.toptal.com/developers/gitignore/api/vim,c,linux main -build +build/ +assets2/ diff --git a/src/grid.c b/src/grid.c index cbf027d..301626b 100644 --- a/src/grid.c +++ b/src/grid.c @@ -2,7 +2,7 @@ int gridHelper(SDL_Rect* rect, int index, SDL_Rect screen, int zoom, int page){ rect->y = 0; - rect->x = screen.w/20 * index; + rect->x = screen.w/10 * index * zoom / 10; //printf("index %i -- x = %i | y = %i | w = %i | h = %i\n", index, rect->x, rect->y, rect->w, rect->h); } diff --git a/src/main.c b/src/main.c index fea8ed9..311b37e 100644 --- a/src/main.c +++ b/src/main.c @@ -75,6 +75,9 @@ int main(int argc, char* args[]) { SDL_Rect thumbs_container = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT}; SDL_Rect thumbs_rect = {40, 40, 40, 40}; + int min_zoom = 1, max_zoom = 100; + int zoom = 25; + for(int i = 0; i < nfiles; i++){ gridHelper(&thumbs_rect, i, thumbs_container, 1, 0); @@ -89,6 +92,20 @@ int main(int argc, char* args[]) { if(e.type == SDL_QUIT){ quit = true; } + if(e.type == SDL_MOUSEWHEEL){ + if(e.wheel.y > 0){ // scroll up + if(zoom < max_zoom){ + zoom++; + printf("zoom = %i\n", zoom); + } + } + else if(e.wheel.y < 0){ // scroll down + if(zoom > min_zoom){ + zoom--; + printf("zoom = %i\n", zoom); + } + } + } } if(currentKeyStates[SDL_SCANCODE_ESCAPE]){ return 0; @@ -101,7 +118,7 @@ int main(int argc, char* args[]) { //thumbs_rect.x = 0; //thumbs_rect.y = 0; for(int i = 0; i < nfiles; i++){ - gridHelper(&thumbs_rect, i, thumbs_container, 1, 0); + gridHelper(&thumbs_rect, i, thumbs_container, zoom, 0); SDL_RenderCopy(renderer, thumbs[i], NULL, &thumbs_rect); }