% screenSize.m This function checks monitor dimension and set properly the
% window for video generation

function [ outputWindowWidth ] = screenSize( outputWindowWidth, timeSignalEnable )

scrsz                   = get( groot, 'ScreenSize' );                       % get screen size

if outputWindowWidth == 0
    outputWindowWidth   = 10 * floor( scrsz( 3 ) / 10 );                    % set resolution to maximum possible
% else
%     outputWindowWidth   = 10 * floor( outputWindowWidth / 10 );             % adjust value to a multiple of ten ( 1286 -> 1280 )
end

if timeSignalEnable 
    height              = outputWindowWidth / ( 2*0.8 );                    % calculate needed height
    if height > scrsz( 4 )                                                  % verify width is not too large
        outputWindowWidth = ( 10 * floor( scrsz( 4 ) / 10 ) ) * 1.6;        % reduce width
        height          = outputWindowWidth / ( 2*0.8 );                    % calculate new height
    end
    fprintf( [ 'Resolution is: ' num2str( outputWindowWidth ) 'x' num2str( height ) '\n' ] )
else
    if outputWindowWidth > scrsz( 3 )                                       % verify width is not too large
        outputWindowWidth = 10 * floor( scrsz( 3 ) / 10 );                  % reduce width to max possible
    end
    height              = outputWindowWidth / 2;                            % calculate new height
    fprintf( [ 'Resolution is: ' num2str( outputWindowWidth ) 'x' num2str( height ) '\n' ] )
end
