Zoom value added
This commit is contained in:
parent
39f69ad7d7
commit
2852b6ed32
|
@ -93,4 +93,5 @@ tags
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/vim,c,linux
|
# End of https://www.toptal.com/developers/gitignore/api/vim,c,linux
|
||||||
|
|
||||||
main
|
main
|
||||||
build
|
build/
|
||||||
|
assets2/
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
int gridHelper(SDL_Rect* rect, int index, SDL_Rect screen, int zoom, int page){
|
int gridHelper(SDL_Rect* rect, int index, SDL_Rect screen, int zoom, int page){
|
||||||
rect->y = 0;
|
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);
|
//printf("index %i -- x = %i | y = %i | w = %i | h = %i\n", index, rect->x, rect->y, rect->w, rect->h);
|
||||||
}
|
}
|
||||||
|
|
19
src/main.c
19
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_container = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||||
SDL_Rect thumbs_rect = {40, 40, 40, 40};
|
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++){
|
for(int i = 0; i < nfiles; i++){
|
||||||
gridHelper(&thumbs_rect, i, thumbs_container, 1, 0);
|
gridHelper(&thumbs_rect, i, thumbs_container, 1, 0);
|
||||||
|
@ -89,6 +92,20 @@ int main(int argc, char* args[]) {
|
||||||
if(e.type == SDL_QUIT){
|
if(e.type == SDL_QUIT){
|
||||||
quit = true;
|
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]){
|
if(currentKeyStates[SDL_SCANCODE_ESCAPE]){
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -101,7 +118,7 @@ int main(int argc, char* args[]) {
|
||||||
//thumbs_rect.x = 0;
|
//thumbs_rect.x = 0;
|
||||||
//thumbs_rect.y = 0;
|
//thumbs_rect.y = 0;
|
||||||
for(int i = 0; i < nfiles; i++){
|
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);
|
SDL_RenderCopy(renderer, thumbs[i], NULL, &thumbs_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue