Statistics
| Branch: | Revision:

chunker-player / chunker_player / player_gui.c @ 5913a60a

History | View | Annotate | Download (28.6 KB)

1
/*
2
 *  Copyright (c) 2009-2011 Carmelo Daniele, Dario Marchese, Diego Reforgiato, Giuseppe Tropea
3
 *  developed for the Napa-Wine EU project. See www.napa-wine.eu
4
 *
5
 *  This is free software; see lgpl-2.1.txt
6
 */
7

    
8
#include "player_gui.h"
9
// #include "player_commons.h"
10

    
11
#define SCREEN_BOTTOM_PADDING (BUTTONS_LAYER_OFFSET + BUTTONS_CONTAINER_HEIGHT + STATS_BOX_HEIGHT)
12

    
13
SDL_Cursor *InitSystemCursor(const char *image[]);
14
void AspectRatioResize(float aspect_ratio, int width, int height, int* out_width, int* out_height);
15
void UpdateOverlaySize(float aspect_ratio, int width, int height);
16
void RedrawButtons();
17
void RedrawChannelName();
18
void RedrawStats();
19
void SetupGUI();
20
void ToggleAudio();
21
void PSNRLedCallback();
22

    
23
static char AudioStatsText[255];
24
static char VideoStatsText[255];
25

    
26
static Uint32 last_mousemotion;
27
#define MOUSE_HIDE_DELAY 2000
28

    
29
static float ratio;
30
static float ratios[] = {DEFAULT_RATIO, 4.0/3.0, 16.0/9.0};
31
static int ratios_index;
32

    
33
SDL_Surface *ChannelTitleSurface = NULL;
34
//SDL_Surface *AudioStatisticsSurface = NULL, *VideoStatisticsSurface = NULL;
35
SDL_Rect ChannelTitleRect, AudioStatisticsRect, VideoStatisticsRect, tmpRect;
36
SDL_Color ChannelTitleColor = { 255, 0, 0 }, StatisticsColor = { 255, 255, 255 };
37
SDL_Color ChannelTitleBgColor = { 0, 0, 0 }, StatisticsBgColor = { 0, 0, 0 };
38
TTF_Font *MainFont = NULL;
39
TTF_Font *StatisticsFont = NULL;
40

    
41
/* XPM */
42
static const char *handXPM[] = {
43
/* columns rows colors chars-per-pixel */
44
"32 32 3 1",
45
"  c black",
46
". c gray100",
47
"X c None",
48
/* pixels */
49
"XXXXX  XXXXXXXXXXXXXXXXXXXXXXXXX",
50
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
51
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
52
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
53
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
54
"XXXX ..   XXXXXXXXXXXXXXXXXXXXXX",
55
"XXXX .. ..   XXXXXXXXXXXXXXXXXXX",
56
"XXXX .. .. ..  XXXXXXXXXXXXXXXXX",
57
"XXXX .. .. .. . XXXXXXXXXXXXXXXX",
58
"   X .. .. .. .. XXXXXXXXXXXXXXX",
59
" ..  ........ .. XXXXXXXXXXXXXXX",
60
" ... ........... XXXXXXXXXXXXXXX",
61
"X .. ........... XXXXXXXXXXXXXXX",
62
"XX . ........... XXXXXXXXXXXXXXX",
63
"XX ............. XXXXXXXXXXXXXXX",
64
"XXX ............ XXXXXXXXXXXXXXX",
65
"XXX ........... XXXXXXXXXXXXXXXX",
66
"XXXX .......... XXXXXXXXXXXXXXXX",
67
"XXXX .......... XXXXXXXXXXXXXXXX",
68
"XXXXX ........ XXXXXXXXXXXXXXXXX",
69
"XXXXX ........ XXXXXXXXXXXXXXXXX",
70
"XXXXX          XXXXXXXXXXXXXXXXX",
71
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
72
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
73
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
74
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
75
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
76
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
77
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
78
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
79
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
80
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
81
"0,0"
82
};
83

    
84
int ChunkerPlayerGUI_Init()
85
{
86
        // some initializations
87
        ratio = DEFAULT_RATIO;
88
        FullscreenWidth = 0;
89
        FullscreenHeight = 0;
90
        Audio_ON = 1;
91
        
92
        UpdateOverlaySize(ratio, DEFAULT_WIDTH, DEFAULT_HEIGHT);
93
        
94
        if(!SilentMode)
95
                SetupGUI();
96
        
97
        return 0;
98
}
99

    
100
int SetVideoMode(int width, int height, int fullscreen)
101
{
102
        if(SilentMode)
103
                return 1;
104
                
105
        // printf("SetVideoMode(%d, %d, %d)\n", width, height, fullscreen);
106
        SDL_LockMutex(OverlayMutex);
107

    
108
        if(fullscreen)
109
        {
110
#ifndef __DARWIN__
111
                MainScreen = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_NOFRAME | SDL_FULLSCREEN);
112
#else
113
                MainScreen = SDL_SetVideoMode(width, height, 24, SDL_SWSURFACE | SDL_NOFRAME | SDL_FULLSCREEN);
114
#endif
115
        }
116
        else
117
        {
118
#ifndef __DARWIN__
119
                MainScreen = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_RESIZABLE);
120
#else
121
                MainScreen = SDL_SetVideoMode(width, height, 24, SDL_SWSURFACE | SDL_RESIZABLE);
122
#endif
123
        }
124

    
125
        if(!MainScreen) {
126
                fprintf(stderr, "ERROR: could not change video mode\n");
127
                return 1;
128
        }
129
        SDL_UnlockMutex(OverlayMutex);
130
        
131
        return 0;
132
}
133

    
134
void ChunkerPlayerGUI_HandleResize(int resize_w, int resize_h)
135
{
136
        if(SilentMode)
137
                return;
138
                
139
        SDL_LockMutex(OverlayMutex);
140
        
141
        int res = SetVideoMode(resize_w, resize_h, FullscreenMode?1:0);
142

    
143
        if(res && FullscreenMode)
144
        {
145
                // an error has occurred while switching to fullscreen mode
146
                
147
                // trying resize without fullscreen mode
148
                FullscreenMode = 0;
149
                res = SetVideoMode(resize_w, resize_h, 0);
150
        }
151
        if(res)
152
        {
153
                // nothing to do
154
                fprintf(stderr, "CRITICAL ERROR: could not change video mode\n");
155
                exit(1);
156
        }
157
        
158
        window_width = resize_w;
159
        window_height = resize_h;
160
        
161
        // update the overlay surface size, mantaining the aspect ratio
162
        UpdateOverlaySize(ratio, resize_w, resize_h);
163
        
164
        // update each button coordinates
165
        int i;
166
        for(i=0; i<NBUTTONS; i++)
167
        {
168
                if(Buttons[i].XOffset > 0)
169
                        Buttons[i].ButtonIconBox.x = Buttons[i].XOffset;
170
                else
171
                        Buttons[i].ButtonIconBox.x = (resize_w + Buttons[i].XOffset);
172
                        
173
                Buttons[i].ButtonIconBox.y = resize_h - Buttons[i].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
174
        }
175
        
176
        RedrawButtons();
177
        RedrawChannelName();
178
        RedrawStats();
179
        
180
        SDL_UnlockMutex(OverlayMutex);
181
}
182

    
183
void ChunkerPlayerGUI_HandleGetFocus()
184
{
185
        if(SilentMode)
186
                return;
187

    
188
        RedrawButtons();
189
        RedrawChannelName();
190
        RedrawStats();
191
}
192

    
193
Uint32 DisableCursor(Uint32 interval, void *param)
194
{
195
        Uint32 time = SDL_GetTicks();
196
        if (time >= last_mousemotion + MOUSE_HIDE_DELAY) {
197
                if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
198
                        SDL_LockMutex(OverlayMutex);
199
                        SDL_ShowCursor(SDL_DISABLE);
200
                        SDL_UnlockMutex(OverlayMutex);
201
                }
202
        }
203

    
204
        return interval;
205
}
206

    
207
void ChunkerPlayerGUI_HandleMouseMotion(int x, int y)
208
{
209
        static SDL_TimerID cursor_cb;
210

    
211
        if(SilentMode)
212
                return;
213
                
214
        int i;
215

    
216
#ifdef __linux__
217
        if (!cursor_cb) {
218
                cursor_cb = SDL_AddTimer(MOUSE_HIDE_DELAY/2, DisableCursor, NULL);
219
        }
220
        if (SDL_ShowCursor(SDL_QUERY) == SDL_DISABLE) {
221
                SDL_LockMutex(OverlayMutex);
222
                SDL_ShowCursor(SDL_ENABLE);
223
                SDL_UnlockMutex(OverlayMutex);
224
        }
225
        last_mousemotion = SDL_GetTicks();
226
#endif
227

    
228
        for(i=0; i<NBUTTONS; i++)
229
        {
230
                //If the mouse is over the button
231
                if(
232
                        ( x > Buttons[i].ButtonIconBox.x ) && ( x < Buttons[i].ButtonIconBox.x + Buttons[i].ButtonIcon->w )
233
                        && ( y > Buttons[i].ButtonIconBox.y ) && ( y < Buttons[i].ButtonIconBox.y + Buttons[i].ButtonIcon->h )
234
                )
235
                {
236
                    // LED Button 
237
                    if(i>=PSNR_LED_RED_BUTTON_INDEX && i<=PSNR_LED_GREEN_BUTTON_INDEX)
238
                    {
239
                        SDL_SetCursor(defaultCursor);
240
                        break;
241
                    }
242
                        
243
                        Buttons[i].Hover = 1;
244
                        SDL_SetCursor(handCursor);
245
                        break;
246
                }
247
                
248
                else
249
                {
250
                        Buttons[i].Hover = 0;
251
                        SDL_SetCursor(defaultCursor);
252
                }
253
        }
254
}
255

    
256
void ChunkerPlayerGUI_HandleLButton(int x, int y)
257
{
258
        if(SilentMode)
259
                return;
260
                
261
        int i;
262
        for(i=0; i<NBUTTONS; i++)
263
        {
264
                //If the mouse is over the button
265
                if(
266
                        ( x > Buttons[i].ButtonIconBox.x ) && ( x < Buttons[i].ButtonIconBox.x + Buttons[i].ButtonIcon->w )
267
                        && ( y > Buttons[i].ButtonIconBox.y ) && ( y < Buttons[i].ButtonIconBox.y + Buttons[i].ButtonIcon->h )
268
                )
269
                {
270
                        Buttons[i].LButtonUpCallback();
271
                        break;
272
                }
273
        }
274
}
275

    
276
void ChunkerPlayerGUI_HandleKey()
277
{
278
        /*static Uint32 LastTime=0;
279
        static int LastKey=-1;
280

281
        Uint32 Now=SDL_GetTicks();
282
        Uint8* keystate=SDL_GetKeyState(NULL);
283
        if(keystate[SDLK_ESCAPE] &&
284
          (LastKey!=SDLK_ESCAPE || (LastKey==SDLK_ESCAPE && (Now-LastTime>1000))))
285
        {
286
                LastKey=SDLK_ESCAPE;
287
                LastTime=Now;
288
                quit=1;
289
        }*/
290
}
291

    
292
void ChunkerPlayerGUI_Close()
293
{
294
        if(ChannelTitleSurface != NULL)
295
                SDL_FreeSurface( ChannelTitleSurface );
296
        
297
        TTF_CloseFont( MainFont );
298
        TTF_CloseFont( StatisticsFont );
299
        TTF_Quit();
300
        IMG_Quit();
301
}
302

    
303
void RedrawButtons()
304
{
305
        if(SilentMode)
306
                return;
307
                
308
        int i;
309
        for(i=0; i<NBUTTONS; i++)
310
        {
311
                if(!Buttons[i].Visible)
312
                {
313
                        SDL_LockMutex(OverlayMutex);
314
                        SDL_FillRect( MainScreen, &Buttons[i].ButtonIconBox, SDL_MapRGB(MainScreen->format, 0, 0, 0) );
315
                        SDL_UpdateRects(MainScreen, 1, &Buttons[i].ButtonIconBox);
316
                        SDL_UnlockMutex(OverlayMutex);
317
                }
318
        }
319
        for(i=0; i<NBUTTONS; i++)
320
        {
321
                if(Buttons[i].Visible)
322
                {
323
                        if(!Buttons[i].Hover)
324
                        {
325
                                SDL_LockMutex(OverlayMutex);
326
                                SDL_BlitSurface(Buttons[i].ButtonIcon, NULL, MainScreen, &Buttons[i].ButtonIconBox);
327
                                SDL_UpdateRects(MainScreen, 1, &Buttons[i].ButtonIconBox);
328
                                SDL_UnlockMutex(OverlayMutex);
329
                        }
330
                        else
331
                        {
332
                                SDL_LockMutex(OverlayMutex);
333
                                SDL_BlitSurface(Buttons[i].ButtonHoverIcon, NULL, MainScreen, &(Buttons[i].ButtonIconBox));
334
                                SDL_UpdateRects(MainScreen, 1, &(Buttons[i].ButtonIconBox));
335
                                SDL_UnlockMutex(OverlayMutex);
336
                        }
337
                }
338
        }
339
}
340

    
341
void RedrawChannelName()
342
{
343
        if(SilentMode)
344
                return;
345
                
346
        if(ChannelTitleSurface != NULL)
347
        {
348
                SDL_LockMutex(OverlayMutex);
349
                SDL_FillRect( MainScreen, &ChannelTitleRect, SDL_MapRGB(MainScreen->format, 0, 0, 0) );
350
                SDL_UpdateRect(MainScreen, ChannelTitleRect.x, ChannelTitleRect.y, ChannelTitleRect.w, ChannelTitleRect.h);
351
                
352
                ChannelTitleRect.w = ChannelTitleSurface->w;
353
                ChannelTitleRect.h = ChannelTitleSurface->h;
354
                ChannelTitleRect.x = ((FullscreenMode?FullscreenWidth:window_width) - ChannelTitleRect.w)/2;
355
                ChannelTitleRect.y = Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.y+5;
356
                SDL_BlitSurface(ChannelTitleSurface, NULL, MainScreen, &ChannelTitleRect);
357
                SDL_UpdateRects(MainScreen, 1, &ChannelTitleRect);
358
                SDL_UnlockMutex(OverlayMutex);
359
        }
360
}
361

    
362
void ChunkerPlayerGUI_ToggleFullscreen()
363
{
364
        if(SilentMode)
365
                return;
366

    
367
        SDL_LockMutex(OverlayMutex);
368
                
369
        int i, done = 0;
370
        //If the screen is windowed
371
        if( !FullscreenMode )
372
        {
373
                int res = SetVideoMode(FullscreenWidth, FullscreenHeight, 1);
374
                //Set the window state flag
375
                FullscreenMode = 1;
376

    
377
                if(res)
378
                {
379
                        fprintf(stderr, "ERROR: an error has occurred while switching to fullscreen mode\n");
380
                }
381
                else
382
                {
383
                        // update the overlay surface size, mantaining the aspect ratio
384
                        UpdateOverlaySize(ratio, FullscreenWidth, FullscreenHeight);
385
                        
386
                        // update each button coordinates
387
                        for(i=0; i<NBUTTONS; i++)
388
                        {
389
                                if(Buttons[i].XOffset > 0)
390
                                        Buttons[i].ButtonIconBox.x = Buttons[i].XOffset;
391
                                else
392
                                        Buttons[i].ButtonIconBox.x = (FullscreenWidth + Buttons[i].XOffset);
393
                                        
394
                                Buttons[i].ButtonIconBox.y = FullscreenHeight - Buttons[i].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
395
                        }
396
                        
397
                        Buttons[FULLSCREEN_BUTTON_INDEX].Visible = 0;
398
                        Buttons[NO_FULLSCREEN_BUTTON_INDEX].Visible = 1;
399
                        
400
                        done = 1;
401
                }
402
        }
403
        
404
        //If the screen is fullscreen
405
        if(FullscreenMode && !done)
406
        {
407
                int res = SetVideoMode(window_width, window_height, 0);
408
                if(res)
409
                {
410
                        // nothing to do
411
                        fprintf(stderr, "CRITICAL ERROR: could not change video mode\n");
412
                        exit(1);
413
                }
414
                
415
                // update the overlay surface size, mantaining the aspect ratio
416
                UpdateOverlaySize(ratio, window_width, window_height);
417
                
418
                // update each button coordinates
419
                for(i=0; i<NBUTTONS; i++)
420
                {
421
                        if(Buttons[i].XOffset > 0)
422
                                Buttons[i].ButtonIconBox.x = Buttons[i].XOffset;
423
                        else
424
                                Buttons[i].ButtonIconBox.x = (window_width + Buttons[i].XOffset);
425
                                
426
                        Buttons[i].ButtonIconBox.y = window_height - Buttons[i].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
427
                }
428
                
429
                //Set the window state flag
430
                FullscreenMode = 0;
431
                
432
                Buttons[FULLSCREEN_BUTTON_INDEX].Visible = 1;
433
                Buttons[NO_FULLSCREEN_BUTTON_INDEX].Visible = 0;
434
        }
435

    
436
        RedrawButtons();
437
        RedrawChannelName();
438
        RedrawStats();
439
        
440
        SDL_UnlockMutex(OverlayMutex);
441
}
442

    
443
void ChunkerPlayerGUI_AspectRatioResize(float aspect_ratio, int width, int height, int* out_width, int* out_height)
444
{
445
        AspectRatioResize(aspect_ratio, width, height, out_width, out_height);
446
}
447

    
448
void AspectRatioResize(float aspect_ratio, int width, int height, int* out_width, int* out_height)
449
{
450
        int h,w;
451
        h = (int)((float)width/aspect_ratio);
452
        if(h<=height)
453
        {
454
                w = width;
455
        }
456
        else
457
        {
458
                w = (int)((float)height*aspect_ratio);
459
                h = height;
460
        }
461
        *out_width = w;
462
        *out_height = h;
463
}
464

    
465
/**
466
 * Updates the overlay surface size, mantaining the aspect ratio
467
 */
468
void UpdateOverlaySize(float aspect_ratio, int width, int height)
469
{
470
        // height -= (BUTTONS_LAYER_OFFSET + BUTTONS_CONTAINER_HEIGHT);
471
        height -= SCREEN_BOTTOM_PADDING;
472
        int h = 0, w = 0, x, y;
473
        AspectRatioResize(aspect_ratio, width, height, &w, &h);
474
        x = (width - w) / 2;
475
        y = (height - h) / 2;
476
        SDL_LockMutex(OverlayMutex);
477
        OverlayRect.x = x;
478
        OverlayRect.y = y;
479
        OverlayRect.w = w;
480
        OverlayRect.h = h;
481
        // SDL_FillRect( SDL_GetVideoSurface(), NULL, SDL_MapRGB(SDL_GetVideoSurface()->format, 0,0,0) );
482
        SDL_UpdateRect(MainScreen, 0, 0, 0, 0);
483
        SDL_UnlockMutex(OverlayMutex);
484
}
485

    
486
void GetScreenSizeFromOverlay(int overlayWidth, int overlayHeight, int* screenWidth, int* screenHeight)
487
{
488
        *screenHeight = overlayHeight + SCREEN_BOTTOM_PADDING;
489
        *screenWidth = overlayWidth;
490
}
491

    
492
/* From the SDL documentation. */
493
SDL_Cursor *InitSystemCursor(const char *image[])
494
{
495
        int i, row, col;
496
        Uint8 data[4*32];
497
        Uint8 mask[4*32];
498
        int hot_x, hot_y;
499

    
500
        i = -1;
501
        for ( row=0; row<32; ++row ) {
502
                for ( col=0; col<32; ++col ) {
503
                        if ( col % 8 ) {
504
                                data[i] <<= 1;
505
                                mask[i] <<= 1;
506
                        } else {
507
                                ++i;
508
                                data[i] = mask[i] = 0;
509
                        }
510
                        
511
                        switch (image[4+row][col]) {
512
                                case ' ':
513
                                        data[i] |= 0x01;
514
                                        mask[i] |= 0x01;
515
                                        break;
516
                                case '.':
517
                                        mask[i] |= 0x01;
518
                                        break;
519
                                case 'X':
520
                                        break;
521
                        }
522
                }
523
        }
524
        
525
        sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
526
        return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
527
}
528

    
529
void SetupGUI()
530
{
531
        //Initialize SDL_ttf 
532
        if( TTF_Init() == -1 )
533
        {
534
                printf("TTF_Init: Failed to init SDL_ttf library!\n");
535
                printf("TTF_Init: %s\n", TTF_GetError());
536
                exit(1);
537
        }
538
        
539
        //Open the font
540
        MainFont = TTF_OpenFont(MAIN_FONT_FILE , MAIN_FONT_SIZE );
541
        StatisticsFont = TTF_OpenFont(STATS_FONT_FILE, STATS_FONT_SIZE );
542
        
543
        //If there was an error in loading the font
544
        if( MainFont == NULL)
545
        {
546
                printf("Cannot initialize GUI, %s file not found\n", MAIN_FONT_FILE);
547
                exit(1);
548
        }
549
        if( StatisticsFont == NULL )
550
        {
551
                printf("Cannot initialize GUI, %s file not found\n", STATS_FONT_FILE);
552
                exit(1);
553
        }
554
        
555
        // init SDL_image
556
        int flags=IMG_INIT_JPG|IMG_INIT_PNG;
557
        int initted=IMG_Init(flags);
558
        if(initted&flags != flags)
559
        {
560
                printf("IMG_Init: Failed to init required jpg and png support!\n");
561
                printf("IMG_Init: %s\n", IMG_GetError());
562
                exit(1);
563
        }
564
        
565
        SDL_VideoInfo* InitialVideoInfo = SDL_GetVideoInfo();
566
        FullscreenWidth = InitialVideoInfo->current_w;
567
        FullscreenHeight = InitialVideoInfo->current_h;
568

    
569
        SDL_Surface *temp;
570
        int screen_w = 0, screen_h = 0;
571

    
572
        if(OverlayRect.w > BUTTONS_CONTAINER_WIDTH)
573
                screen_w = OverlayRect.w;
574
        else
575
                screen_w = BUTTONS_CONTAINER_WIDTH;
576
        screen_h = OverlayRect.h + SCREEN_BOTTOM_PADDING;
577

    
578
        SDL_WM_SetCaption("Filling buffer...", NULL);
579
        
580
        // Make a screen to put our video
581
        SetVideoMode(screen_w, screen_h, 0);
582
        
583
        window_width = screen_w;
584
        window_height = screen_h;
585
        
586
        /** Setting up cursors */
587
        defaultCursor = SDL_GetCursor();
588
        handCursor = InitSystemCursor(handXPM);
589
        
590
        /** Init Buttons */
591
        int i;
592
        for(i=0; i<NBUTTONS; i++)
593
        {
594
                SButton* tmp = &(Buttons[i]);
595
                tmp->Hover = 0;
596
                tmp->ToggledButton = NULL;
597
                tmp->Visible = 1;
598
                tmp->HoverCallback = NULL;
599
                tmp->LButtonUpCallback = NULL;
600
        }
601
        
602
        /** Loading icons */
603
        
604
        // fullscreen
605
        temp = IMG_Load(FULLSCREEN_ICON_FILE);
606
        if (temp == NULL) {
607
                fprintf(stderr, "Error loading %s: %s\n", FULLSCREEN_ICON_FILE, SDL_GetError());
608
                exit(1);
609
        }
610
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
611
        if(Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIcon == NULL)
612
        {
613
                printf("ERROR in SDL_DisplayFormatAlpha, cannot load fullscreen button, error message: '%s'\n", SDL_GetError());
614
                exit(1);
615
        }
616
        SDL_FreeSurface(temp);
617
        
618
        // fullscreen hover
619
        temp = IMG_Load(FULLSCREEN_HOVER_ICON_FILE);
620
        if (temp == NULL) {
621
                fprintf(stderr, "Error loading %s: %s\n", FULLSCREEN_HOVER_ICON_FILE, SDL_GetError());
622
                exit(1);
623
        }
624
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
625
        SDL_FreeSurface(temp);
626

    
627
        // no fullscreen
628
        temp = IMG_Load(NOFULLSCREEN_ICON_FILE);
629
        if (temp == NULL) {
630
                fprintf(stderr, "Error loading %s: %s\n", NOFULLSCREEN_ICON_FILE, SDL_GetError());
631
                exit(1);
632
        }
633
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
634
        SDL_FreeSurface(temp);
635

    
636
        // no fullscreen hover
637
        temp = IMG_Load(NOFULLSCREEN_HOVER_ICON_FILE);
638
        if (temp == NULL) {
639
                fprintf(stderr, "Error loading %s: %s\n", NOFULLSCREEN_HOVER_ICON_FILE, SDL_GetError());
640
                exit(1);
641
        }
642
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
643
        SDL_FreeSurface(temp);
644
        
645
        // channel up
646
        temp = IMG_Load(CHANNEL_UP_ICON_FILE);
647
        if (temp == NULL) {
648
                fprintf(stderr, "Error loading %s: %s\n", CHANNEL_UP_ICON_FILE, SDL_GetError());
649
                exit(1);
650
        }
651
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
652
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
653
        SDL_FreeSurface(temp);
654
        
655
        // channel down
656
        temp = IMG_Load(CHANNEL_DOWN_ICON_FILE);
657
        if (temp == NULL) {
658
                fprintf(stderr, "Error loading %s: %s\n", CHANNEL_DOWN_ICON_FILE, SDL_GetError());
659
                exit(1);
660
        }
661
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
662
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
663
        SDL_FreeSurface(temp);
664
        
665
        // audio OFF
666
        temp = IMG_Load(AUDIO_OFF_ICON_FILE);
667
        if (temp == NULL) {
668
                fprintf(stderr, "Error loading %s: %s\n", AUDIO_OFF_ICON_FILE, SDL_GetError());
669
                exit(1);
670
        }
671
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
672
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
673
        SDL_FreeSurface(temp);
674
        
675
        // audio ON
676
        temp = IMG_Load(AUDIO_ON_ICON_FILE);
677
        if (temp == NULL) {
678
                fprintf(stderr, "Error loading %s: %s\n", AUDIO_ON_ICON_FILE, SDL_GetError());
679
                exit(1);
680
        }
681
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
682
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
683
        SDL_FreeSurface(temp);
684
        
685
        // PSNR RED LED
686
        temp = IMG_Load(PSNR_LED_RED_ICON_FILE);
687
        if (temp == NULL) {
688
                fprintf(stderr, "Error loading %s: %s\n", PSNR_LED_RED_ICON_FILE, SDL_GetError());
689
                exit(1);
690
        }
691
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
692
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
693
        SDL_FreeSurface(temp);
694
        
695
        // PSNR YELLOW LED
696
        temp = IMG_Load(PSNR_LED_YELLOW_ICON_FILE);
697
        if (temp == NULL) {
698
                fprintf(stderr, "Error loading %s: %s\n", PSNR_LED_YELLOW_ICON_FILE, SDL_GetError());
699
                exit(1);
700
        }
701
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
702
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
703
        SDL_FreeSurface(temp);
704
        
705
        // PSNR GREEN LED
706
        temp = IMG_Load(PSNR_LED_GREEN_ICON_FILE);
707
        if (temp == NULL) {
708
                fprintf(stderr, "Error loading %s: %s\n", PSNR_LED_GREEN_ICON_FILE, SDL_GetError());
709
                exit(1);
710
        }
711
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIcon = SDL_DisplayFormatAlpha(temp);
712
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonHoverIcon = SDL_DisplayFormatAlpha(temp);
713
        SDL_FreeSurface(temp);
714

    
715
        /** Setting up icon boxes */
716
        Buttons[FULLSCREEN_BUTTON_INDEX].XOffset = Buttons[NO_FULLSCREEN_BUTTON_INDEX].XOffset = 20;
717
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.x = 20;
718
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.w = Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIcon->w;
719
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.h = Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIcon->h;
720
        Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
721
        
722
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIconBox.x = 20;
723
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIconBox.w = Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIcon->w;
724
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIconBox.h = Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIcon->h;
725
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[NO_FULLSCREEN_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
726
        
727
        Buttons[CHANNEL_UP_BUTTON_INDEX].XOffset = -61;
728
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIconBox.w = Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIcon->w;
729
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIconBox.h = Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIcon->h;
730
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIconBox.x = (screen_w + Buttons[CHANNEL_UP_BUTTON_INDEX].XOffset);
731
        Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[CHANNEL_UP_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
732
        
733
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].XOffset = -36;
734
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIconBox.w = Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIcon->w;
735
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIconBox.h = Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIcon->h;
736
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIconBox.x = (screen_w + Buttons[CHANNEL_DOWN_BUTTON_INDEX].XOffset);
737
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[CHANNEL_DOWN_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
738
        
739
        Buttons[AUDIO_OFF_BUTTON_INDEX].XOffset = Buttons[AUDIO_ON_BUTTON_INDEX].XOffset = 70;
740
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIconBox.x = 20;
741
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIconBox.w = Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIcon->w;
742
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIconBox.h = Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIcon->h;
743
        Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[AUDIO_OFF_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
744
        Buttons[AUDIO_OFF_BUTTON_INDEX].Visible = 1;
745

    
746
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIconBox.x = 20;
747
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIconBox.w = Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIcon->w;
748
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIconBox.h = Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIcon->h;
749
        Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[AUDIO_ON_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
750
        Buttons[AUDIO_ON_BUTTON_INDEX].Visible = 0;
751
        
752
        Buttons[PSNR_LED_RED_BUTTON_INDEX].XOffset = -106;
753
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIconBox.w = Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIcon->w;
754
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIconBox.h = Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIcon->h;
755
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIconBox.x = (screen_w + Buttons[PSNR_LED_RED_BUTTON_INDEX].XOffset);
756
        Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[PSNR_LED_RED_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
757
        Buttons[PSNR_LED_RED_BUTTON_INDEX].Visible = 0;
758
        
759
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].XOffset = -106;
760
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIconBox.w = Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIcon->w;
761
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIconBox.h = Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIcon->h;
762
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIconBox.x = (screen_w + Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].XOffset);
763
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
764
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].Visible = 0;
765
        
766
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].XOffset = -106;
767
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIconBox.w = Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIcon->w;
768
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIconBox.h = Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIcon->h;
769
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIconBox.x = (screen_w + Buttons[PSNR_LED_GREEN_BUTTON_INDEX].XOffset);
770
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIconBox.y = screen_h - Buttons[PSNR_LED_GREEN_BUTTON_INDEX].ButtonIconBox.h - (SCREEN_BOTTOM_PADDING/2);
771
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].Visible = 1;
772
        
773
        // Setting up buttons events
774
        Buttons[FULLSCREEN_BUTTON_INDEX].ToggledButton = &(Buttons[NO_FULLSCREEN_BUTTON_INDEX]);
775
        Buttons[FULLSCREEN_BUTTON_INDEX].LButtonUpCallback = &ChunkerPlayerGUI_ToggleFullscreen;
776
        Buttons[NO_FULLSCREEN_BUTTON_INDEX].LButtonUpCallback = &ChunkerPlayerGUI_ToggleFullscreen;
777
        Buttons[CHANNEL_UP_BUTTON_INDEX].LButtonUpCallback = &ZapUp;
778
        Buttons[CHANNEL_DOWN_BUTTON_INDEX].LButtonUpCallback = &ZapDown;
779
        Buttons[AUDIO_OFF_BUTTON_INDEX].LButtonUpCallback = &ToggleAudio;
780
        Buttons[AUDIO_ON_BUTTON_INDEX].LButtonUpCallback = &ToggleAudio;
781
        Buttons[PSNR_LED_RED_BUTTON_INDEX].LButtonUpCallback = &PSNRLedCallback;
782
        Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].LButtonUpCallback = &PSNRLedCallback;
783
        Buttons[PSNR_LED_GREEN_BUTTON_INDEX].LButtonUpCallback = &PSNRLedCallback;
784
}
785

    
786
void ChunkerPlayerGUI_SetChannelTitle(char* title)
787
{
788
        if(SilentMode)
789
                return;
790
                
791
        SDL_LockMutex(OverlayMutex);
792
        
793
        SDL_FreeSurface( ChannelTitleSurface );
794
        // ChannelTitleSurface = TTF_RenderText_Solid( MainFont, channel->Title, ChannelTitleColor );
795
        ChannelTitleSurface = TTF_RenderText_Shaded( MainFont, title, ChannelTitleColor, ChannelTitleBgColor );
796
        if(ChannelTitleSurface == NULL)
797
        {
798
                printf("WARNING: CANNOT RENDER CHANNEL TITLE\n");
799
        }
800
        
801
        SDL_UnlockMutex(OverlayMutex);
802
        
803
        RedrawChannelName();
804
}
805

    
806
void ChunkerPlayerGUI_SetStatsText(char* audio_text, char* video_text, int ledstatus)
807
{
808
        if(SilentMode)
809
                return;
810
                
811
        if(audio_text == NULL)
812
                audio_text = AudioStatsText;
813
        
814
        if(video_text == NULL)
815
                video_text = VideoStatsText;
816

    
817
        if((strlen(audio_text) > 255) || (strlen(video_text) > 255))
818
        {
819
                printf("WARNING IN player_gui.c: stats text too long, could not refresh text\n");
820
                return;
821
        }
822
        
823
        strcpy(AudioStatsText, audio_text);
824
        strcpy(VideoStatsText, video_text);
825
        
826
        switch(ledstatus)
827
    {
828
    case LED_RED:
829
        // PSNR LED RED
830
        Buttons[PSNR_LED_RED_BUTTON_INDEX].Visible = 1;
831
                Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].Visible = 0;
832
                Buttons[PSNR_LED_GREEN_BUTTON_INDEX].Visible = 0;
833
            break;
834
        case LED_YELLOW:
835
            // PSNR LED YELLOW
836
            Buttons[PSNR_LED_RED_BUTTON_INDEX].Visible = 0;
837
                Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].Visible = 1;
838
                Buttons[PSNR_LED_GREEN_BUTTON_INDEX].Visible = 0;
839
            break;
840
        case LED_GREEN:
841
            // PSNR LED GREEN
842
            Buttons[PSNR_LED_RED_BUTTON_INDEX].Visible = 0;
843
                Buttons[PSNR_LED_YELLOW_BUTTON_INDEX].Visible = 0;
844
                Buttons[PSNR_LED_GREEN_BUTTON_INDEX].Visible = 1;
845
            break;
846
        }
847
        
848
        RedrawStats();
849
        RedrawButtons();
850
}
851

    
852
void RedrawStats()
853
{
854
        if(SilentMode)
855
                return;
856
                
857
        SDL_Surface *text_surface;
858

    
859
        SDL_LockMutex(OverlayMutex);
860
        
861
        // clear stats text
862
        SDL_FillRect( MainScreen, &VideoStatisticsRect, SDL_MapRGB(MainScreen->format, 0, 0, 0) );
863
        SDL_FillRect( MainScreen, &AudioStatisticsRect, SDL_MapRGB(MainScreen->format, 0, 0, 0) );
864
        SDL_UpdateRect(MainScreen, VideoStatisticsRect.x, VideoStatisticsRect.y, VideoStatisticsRect.w, VideoStatisticsRect.h);
865
        SDL_UpdateRect(MainScreen, AudioStatisticsRect.x, AudioStatisticsRect.y, AudioStatisticsRect.w, AudioStatisticsRect.h);
866
        
867
        
868
        text_surface = TTF_RenderText_Shaded( StatisticsFont, AudioStatsText, StatisticsColor, StatisticsBgColor );
869
    if (text_surface != NULL)
870
    {
871
                AudioStatisticsRect.w = text_surface->w;
872
                AudioStatisticsRect.h = text_surface->h;
873
                AudioStatisticsRect.x = ((FullscreenMode?FullscreenWidth:window_width) - AudioStatisticsRect.w)>>1;
874
                AudioStatisticsRect.y = Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.y+(STATS_FONT_SIZE<<1)+STATS_BOX_HEIGHT;
875

    
876
        SDL_BlitSurface(text_surface, NULL, MainScreen, &AudioStatisticsRect);
877
        SDL_FreeSurface(text_surface);
878
    }
879
    else
880
    {
881
        // report error
882
    }
883
    
884
        text_surface = TTF_RenderText_Shaded( StatisticsFont, VideoStatsText, StatisticsColor, StatisticsBgColor );
885
    if (text_surface != NULL)
886
    {
887
                VideoStatisticsRect.w = text_surface->w;
888
                VideoStatisticsRect.h = text_surface->h;
889
                VideoStatisticsRect.x = ((FullscreenMode?FullscreenWidth:window_width) - VideoStatisticsRect.w)>>1;
890
                VideoStatisticsRect.y = Buttons[FULLSCREEN_BUTTON_INDEX].ButtonIconBox.y+(STATS_FONT_SIZE)+STATS_BOX_HEIGHT;
891

    
892
        SDL_BlitSurface(text_surface, NULL, MainScreen, &VideoStatisticsRect);
893
        SDL_FreeSurface(text_surface);
894
    }
895
    else
896
    {
897
        // report error
898
    }
899
    
900
    SDL_UpdateRect(MainScreen, VideoStatisticsRect.x, VideoStatisticsRect.y, VideoStatisticsRect.w, VideoStatisticsRect.h);
901
        SDL_UpdateRect(MainScreen, AudioStatisticsRect.x, AudioStatisticsRect.y, AudioStatisticsRect.w, AudioStatisticsRect.h);
902
        
903
        SDL_UnlockMutex(OverlayMutex);
904
}
905

    
906
void ChunkerPlayerGUI_SetupOverlayRect(SChannel* channel)
907
{
908
        ratio = channel->Ratio;
909
        int w, h;
910
        GetScreenSizeFromOverlay(channel->Width, channel->Height, &w, &h);
911
        UpdateOverlaySize(ratio, w, h);
912
        // UpdateOverlaySize(ratio, channel->Width, channel->Height);
913
}
914

    
915
void ChunkerPlayerGUI_ForceResize(int width, int height)
916
{
917
        FullscreenMode = 0;
918
        int w, h;
919
        GetScreenSizeFromOverlay(width, height, &w, &h);
920
        ChunkerPlayerGUI_HandleResize(w, h);
921
}
922

    
923
void ToggleAudio()
924
{
925
        if(Audio_ON)
926
        {
927
                SDL_PauseAudio(1);
928
                Buttons[AUDIO_OFF_BUTTON_INDEX].Visible = 0;
929
                Buttons[AUDIO_ON_BUTTON_INDEX].Visible = 1;
930
                Audio_ON = 0;
931
        }
932
        else
933
        {
934
                SDL_PauseAudio(0);
935
                Buttons[AUDIO_OFF_BUTTON_INDEX].Visible = 1;
936
                Buttons[AUDIO_ON_BUTTON_INDEX].Visible = 0;
937
                Audio_ON = 1;
938
        }
939
        
940
        RedrawButtons();
941
}
942

    
943
void PSNRLedCallback()
944
{
945
}
946

    
947
void ChunkerPlayerGUI_ChannelSwitched()
948
{
949
        if(!Audio_ON)
950
        {
951
                SDL_PauseAudio(1);
952
                Buttons[AUDIO_OFF_BUTTON_INDEX].Visible = 0;
953
                Buttons[AUDIO_ON_BUTTON_INDEX].Visible = 1;
954
        }
955
        
956
        RedrawButtons();
957
}
958

    
959
void ChunkerPlayerGUI_SetChannelRatio(float r)
960
{
961
  ratios[0] = r;
962
  ratios_index = 0;
963
  ratio = ratios[ratios_index];
964
}
965

    
966
void ChunkerPlayerGUI_ChangeRatio()
967
{
968
        ratios_index = (ratios_index + 1) % (sizeof(ratios) / sizeof(ratios[0]));
969
        ratio = ratios[ratios_index];
970

    
971
fprintf(stderr, "resizing to %f\n", ratio);
972
        if (!FullscreenMode) {
973
                UpdateOverlaySize(ratio, window_width, window_height);
974
        } else {
975
                UpdateOverlaySize(ratio, FullscreenWidth, FullscreenHeight);
976
        }
977
}