% 
% beamerthemeKenotom.sty
% 
% A beamer style file to use in a beamer presentation
%
% author: Christos Choutouridis <c.choutouridis@kenotom.com>
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemeKenotom}


% Requirements
% =====================================================
\RequirePackage{xcolor}
%\RequirePackage{silence}
%\RequirePackage{etoolbox}
\RequirePackage{fontspec}
\RequirePackage{tikz}
\RequirePackage{graphicx}
%\RequirePackage{enumitem}
\RequirePackage{ifthen}


% Options
% =====================================================

% aspectratio: {43(default), 169}
\DeclareOptionBeamer{aspectratio}{\def\beamer@kenotom@aspectratio{#1}}

% theme: {classic(default), light, dark}
\DeclareOptionBeamer{theme}{\def\beamer@kenotom@theme{#1}}

% backround: {none(default), ribon}
\DeclareOptionBeamer{backround}{\def\beamer@kenotom@backround{#1}}

% title: {normal(default), small, large}
\DeclareOptionBeamer{title}{\def\beamer@kenotom@title{#1}}

% nonavigation
%\DeclareOptionBeamer{nonavigation}{\setbeamertemplate{navigation symbols}{}}

% Set default options
\ExecuteOptionsBeamer{aspectratio=43}
\ExecuteOptionsBeamer{theme=classic}
\ExecuteOptionsBeamer{backround=none}
\ExecuteOptionsBeamer{title=normal}

\ProcessOptionsBeamer

%\ProcessOptions\relax
%\WarningsOff[mathdesign/mdbch]


% Colors
% =====================================================

% Define some colors
%\definecolor{KenotomGreen}{RGB}{67,174,158}
\definecolor{KenotomGreen}{RGB}{57,174,157}
\definecolor{KenotomGreenDark}{RGB}{39,103,96}
\definecolor{KenotomGreenGrey}{RGB}{67,91,92}


\definecolor{KenotomGreyLight}{RGB}{215,216,216}
\definecolor{KenotomGrey}{RGB}{154,155,157}
\definecolor{KenotomGreyDark1}{RGB}{108,108,108}
\definecolor{KenotomGreyDark2}{RGB}{92,96,98}

\definecolor{KenotomLightBlue1}{RGB}{207,226,234}
\definecolor{KenotomLightBlue2}{RGB}{232,241,245}
\definecolor{KenotomBlack}{RGB}{0,0,0}
\definecolor{KenotomWhite}{RGB}{255,255,255}


% Define kenotom logos
\pgfdeclareimage[height=0.075\paperheight]{Logo1}{media/kenotomLogo1.png}
\pgfdeclareimage[height=0.075\paperheight]{Logo2}{media/kenotomLogo2.png}
\pgfdeclareimage[height=0.04\paperheight]{Logo3}{media/kenotomLogo3.png}
\pgfdeclareimage[height=0.04\paperheight]{Logo4}{media/kenotomLogo4.png}
\pgfdeclareimage[height=0.06\paperheight]{Logo5}{media/kenotomLogo5.png}

%\pgfdeclareimage[height=0.04\paperheight]{Banner}{media/kenotomBanner.png}


% Local commands
% =====================================================

\newcommand{\Vfill}{\vskip0pt plus 1filll}

% Define a string equality test
\newcommand{\isequal}[2]{ \pdf@strcmp{#1}{#2} }

\newcommand{\SetItemize}[1]{%
	\setbeamertemplate{itemize item}{\small{#1}}
	\setbeamertemplate{itemize subitem}{\scriptsize{#1}}
	\setbeamertemplate{itemize subsubitem}{\tiny{#1}}
}

\newcommand{\SetGraphItemize}[2]{
	\setbeamertemplate{itemize item}{\small\includegraphics[height=#1]{#2}}
	\setbeamertemplate{itemize subitem}{\scriptsize\includegraphics[height=#1]{#2}}
	\setbeamertemplate{itemize subsubitem}{\tiny\includegraphics[height=#1]{#2}}
}

\newcommand{\SetBackroundImage}[1]{
	\setbeamertemplate{background}{%
		\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}
	}
}

%
% [1]: Color
% [2]: Text
%\newcommand{\InsertBackroundToText}[2]{%
%%	\colorbox{#1}{%
%%		\parbox{\dimexpr\textwidth-2\fboxsep\relax}{#2}
%	\colorbox{#1}{#2}
%
%	}
%}

%\newcommand{\InsertNavigation}{%
%	\insertslidenavigationsymbol%
%	\insertframenavigationsymbol%
%	\insertsubsectionnavigationsymbol%
%	\insertsectionnavigationsymbol%
%	\insertdocnavigationsymbol%
%	\insertbackfindforwardnavigationsymbol%
%}


%
% Theme
% =====================================================

\ifnum \isequal{\beamer@kenotom@theme}{dark}=0
	\colorlet{BackroundCanvasColor}{KenotomBlack}
	\colorlet{TitleColor}{KenotomGrey}
	\colorlet{TitleColorAux}{KenotomGreen}
	\colorlet{FrameTitleColor}{KenotomGreyDark1}
	\colorlet{BlockTitleColor}{KenotomGreyDark1}
	
	\colorlet{TextColor}{KenotomGreenGrey}
	\colorlet{StructureColor}{KenotomGreen}
	
	\colorlet{NavigationColor}{KenotomGreen}
	\colorlet{NavigationArrowsColor}{KenotomWhite}
	
	\colorlet{TableCaptionColor}{KenotomGreyDark1}
	\colorlet{TableCaptionTextColor}{KenotomWhite}
	\colorlet{TableRowColor1}{KenotomLightBlue1}
	\colorlet{TableRowColor2}{KenotomLightBlue2}
\else \ifnum \isequal{\beamer@kenotom@theme}{light}=0
	\colorlet{BackroundCanvasColor}{KenotomWhite}
	\colorlet{TitleColor}{KenotomGrey}
	\colorlet{TitleColorAux}{KenotomGreen}
	\colorlet{FrameTitleColor}{KenotomGrey}
	\colorlet{BlockTitleColor}{KenotomGrey}
	
	\colorlet{TextColor}{KenotomGrey}
	\colorlet{StructureColor}{KenotomGreen}
	
	\colorlet{NavigationColor}{KenotomGreen}
	\colorlet{NavigationArrowsColor}{KenotomGrey}
	
	\colorlet{TableCaptionColor}{KenotomGrey}
	\colorlet{TableCaptionTextColor}{KenotomWhite}
	\colorlet{TableRowColor1}{KenotomLightBlue1}
	\colorlet{TableRowColor2}{KenotomLightBlue2}
\else % clasic
	\colorlet{BackroundCanvasColor}{KenotomWhite}
	\colorlet{TitleColor}{KenotomGreyDark1}
	\colorlet{TitleColorAux}{KenotomGreen}
	\colorlet{FrameTitleColor}{KenotomGreyDark2}
	\colorlet{BlockTitleColor}{KenotomGreyDark2}
	
	\colorlet{TextColor}{KenotomGreenGrey}
	\colorlet{StructureColor}{KenotomGreen}
	
	\colorlet{NavigationColor}{KenotomGreen}
	\colorlet{NavigationArrowsColor}{KenotomGreyDark1}
	
	\colorlet{TableCaptionColor}{KenotomGreyDark1}
	\colorlet{TableCaptionTextColor}{KenotomWhite}
	\colorlet{TableRowColor1}{KenotomLightBlue1}
	\colorlet{TableRowColor2}{KenotomLightBlue2}
\fi\fi

% Apply theme colors
\setbeamercolor{background canvas}{bg=BackroundCanvasColor}
\setbeamercolor{titlelike}{fg=FrameTitleColor}
\setbeamercolor{block title}{fg=BlockTitleColor}

\setbeamercolor{normal text}{fg=TextColor}
\setbeamercolor{structure}{fg=StructureColor}
\setbeamercolor{navigation symbols}{fg=NavigationColor, bg=NavigationArrowsColor}



%
% Layout and global settings
% =====================================================

% Frame layout
\setbeamersize{
	text margin left=2em,
	text margin right=2em
}
\setlength{\leftmargini}{1.25em}
\setlength{\leftmarginii}{1em}
\setlength{\leftmarginiii}{1em}

%#+LaTeX_HEADER:\addtobeamertemplate{footnote}{}{\vspace{2ex}}
\addtobeamertemplate{footnote}{}{\vspace{2ex}}

% Default backround (We overwrite it with kenotom environments)
%\ifnum \isequal{\beamer@kenotom@backround}{ribon}=0
%	\ifnum \isequal{\beamer@kenotom@aspectratio}{169}=0
%		\SetBackround{media/backroundRibon169.png}
%	\else
%		\SetBackround{media/backroundRibon43.png}
%	\fi
%\else %None
%	\ifnum \isequal{\beamer@kenotom@aspectratio}{169}=0
%		\SetBackround{media/backroundNone169.png}
%	\else
%		\SetBackround{media/backroundNone43.png}
%	\fi
%\fi%

% Default backround (We overwrite it with kenotom environments)
% [1]: Baner image
% [2]: backround image
% [3]: Opacity
%\newcommand{\SetBackround}[3]{%

	\setbeamertemplate{background}{%
		\begin{tikzpicture}[overlay,remember picture]
		% Banner
		\node[anchor=north east, inner sep=0pt, yshift=-0.06\paperheight] at (current page.north east) {%
			\includegraphics[width=0.2\paperwidth]{media/kenotomBannerRight.png}
		};%
	%	\ifnum \isnotempty{#2}
			\node[anchor=center, inner sep=0pt, yshift=0.04\paperheight, opacity=0.1] at (current page.center) {%
				\includegraphics[width=\paperwidth]{media/ribon.png}
			};%
		
		\node[anchor=center, inner sep=0pt, yshift=0.04\paperheight, opacity=1] at (current page.center) {%
			\includegraphics[width=\paperwidth]{media/kenotomLogoDetails.png}
		};%
	%	\fi
		\end{tikzpicture}%
	}
%}

%\SetBackround{media/kenotomBannerRight.png}{media/ribon.png}{0.15}

% Fonts
\setromanfont{Georgia}
\setsansfont[Scale=MatchLowercase]{Open Sans}

% General
%\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]

% Default itemize symbols (We overwrite them with kenotom environments)
\SetItemize{\textbullet}

% Content style
% =====================================================

% Title page style
\setbeamertemplate{title page}[default][left]
\setbeamerfont{title}{family=\rmfamily,size=\Huge}
\setbeamerfont{author}{size=\Large}
\setbeamerfont{institute}{size=\normalsize}


% Delay headline format
%\newcommand{\SetHeadline}{%
%	\setbeamertemplate{headline}{%
%		\leavevmode
%		\hfill \textrm{ \footnotesize{\insertframenumber/\inserttotalframenumber}}
%%		\hfill \textrm{ \footnotesize{\insertframenumber/\inserttotalframenumber}}
%	}
%	\setbeamertemplate{navigation symbols}{\vspace{-1em}}
%	\addtobeamertemplate{navigation symbols}{\vspace{-1em}}{}
%}

% footline
%\setbeamertemplate{navigation symbols}{}
%\setbeamertemplate{footlline}{\hfill \insertnavigation{0.3\textwidth}}

\newcommand{\BeginCountingFrames}{%
	\addtobeamertemplate{navigation symbols}{}{%
%		\hspace{1em} \usebeamerfont{footline} \textrm{ \footnotesize{\insertframenumber/\inserttotalframenumber}}
		\hspace{2em} \usebeamerfont{footline} \texttt{ \footnotesize{\insertframenumber}}
	}
	\setcounter{framenumber}{0}
}
% Frame title style
\ifnum \isequal{\beamer@kenotom@title}{small}=0
	\setbeamerfont{frametitle}{family=\rmfamily,size=\large,series=\bfseries}
\else\ifnum \isequal{\beamer@kenotom@title}{normal}=0
	\setbeamerfont{frametitle}{family=\rmfamily,size=\Large,series=\bfseries}
\else\ifnum \isequal{\beamer@kenotom@title}{large}=0
	\setbeamerfont{frametitle}{family=\rmfamily,size=\huge,series=\bfseries}
\else % default = normal
	\setbeamerfont{frametitle}{size=\Large,series=\bfseries}
\fi\fi\fi%
\setbeamertemplate{frametitle}{
	\vskip0.05\paperheight
	\insertframetitle
}

% Block style
\setbeamerfont{block title}{family=\rmfamily,size=\large}


% Table style
\renewcommand{\arraystretch}{1.2}
\newcommand{\tableheadrow}{\rowcolor{TableCaptionColor}}
\newcommand{\tableheadcol}[1]{{\bfseries\color{TableCaptionTextColor}#1}}
\rowcolors{2}{TableRowColor1}{TableRowColor2}

%\AtBeginEnvironment{tabular}{\color{black}}


% Kenotom environments
% =====================================================

% Kenotom CoverFrame
\newcommand{\CoverFrame}{{%
	\ifnum \isequal{\beamer@kenotom@aspectratio}{169}=0
		\SetBackroundImage{media/backroundCover169.png}
	\else
		\SetBackroundImage{media/backroundCover43.png}
	\fi
	\begin{frame}
		
	\end{frame}
	}
}

\newcommand{\TitleFrame}{{%
	\ifnum \isequal{\beamer@kenotom@aspectratio}{169}=0
		\SetBackroundImage{media/backroundTitlePage169.png}
	\else
		\SetBackroundImage{media/backroundTitlePage43.png}
	\fi
	\begin{frame}
		\vspace{0.15\textheight}
		\textcolor{TitleColor}{
			\rmfamily \Huge
			\Title               \\[0.5ex]
			\normalsize
			\SubTitle            \\[10ex]
		}
		\textcolor{TextColor}{
			\Large
			\AuthorName          \\[1.5ex]
			\normalsize
			\Date
		}
	\end{frame}
	}
}

\newcommand{\BackCoverFrame}{{%
	\ifnum \isequal{\beamer@kenotom@aspectratio}{169}=0
		\SetBackroundImage{media/backroundBackCover169.png}
	\else
		\SetBackroundImage{media/backroundBackCover43.png}
	\fi
	\begin{frame}
		\Vfill
		\AuthorName    \\
		\AuthorMail    \\
		\textcolor{StructureColor}{%
			\Address   \\
			\Telephone
		}
		\vspace{0.125\paperheight}
	\end{frame}
	}
}

\newenvironment{tickmarks}{%
	\SetGraphItemize{1.6ex}{media/tickmark1.png}
	\begin{itemize}
	}{%
	\end{itemize}
}

\newenvironment{bullets}{%
	\SetGraphItemize{1.3em}{media/bullet.png}
	\begin{itemize}
	}{%
	\end{itemize}
}


