% Name           : beamerthemehri.sty
% Author         : Séverin Lemaignan (severin.lemaignan@epfl.ch)
% Author         : Benjamin Weiss (benjamin.weiss@kreatiefton.de)
% License        : This file may be distributed and/or modified under the
%                  GNU Public License.

\ProvidesPackage{beamerthemehri}[2013/05/05]

\usepackage{eso-pic}

\newif\if@doSans
\@doSansfalse
\DeclareOption{noserifmath}{\@doSanstrue}
\newif\if@doNoFlama
\@doNoFlamafalse
\DeclareOption{noflama}{\@doNoFlamatrue}
\newif\if@doSectionPage
\@doSectionPagefalse
\DeclareOption{nosectionpages}{\@doSectionPagetrue}
\ProcessOptions

\mode<presentation>

%---------------------------------------------------------------------
% TOC
%---------------------------------------------------------------------
\useoutertheme[subsection=false,shadow]{miniframes}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]

%---------------------------------------------------------------------
% custom commands
%---------------------------------------------------------------------
\newcommand{\rightTextArrow}{→}
\newcommand{\quoted}[1]{›#1‹}
\newcommand{\doublequoted}[1]{»#1«}

%---------------------------------------------------------------------
% Itemize
%---------------------------------------------------------------------
\setbeamertemplate{itemize item}{\rightTextArrow}
\setbeamertemplate{itemize subitem}{\rightTextArrow}
\setbeamertemplate{itemize subsubitem}{\rightTextArrow}

\setlength{\parskip}{0.5em}

%---------------------------------------------------------------------
% Background
%---------------------------------------------------------------------

\setbeamertemplate{background}{
    \includegraphics[width=\paperwidth,
    height=\paperheight]{slide-background.pdf}
}

%---------------------------------------------------------------------
% Colors
%---------------------------------------------------------------------

% Primary Colors
\definecolor{hriRed}{rgb}{0.882352941,0,0.098039216}
\definecolor{hriRedDark}{rgb}{0.588235294,0,0.058823529}
\definecolor{hriWarmGreyDark}{rgb}{0.274509804,0.254901961,0.235294118}
\definecolor{hriWarmGreyLight}{rgb}{0.666666667,0.647058824,0.62745098}

% Secondary Colors
\definecolor{hriSec1}{rgb}{0,0.588235294,0.509803922}
\definecolor{hriSec1Dark}{rgb}{0,0.392156863,0.31372549}
\definecolor{hriSec1Comp}{rgb}{0.294117647,0.745098039,0.882352941}
\definecolor{hriSec1CompDark}{rgb}{0.196078431,0.490196078,0.568627451}

\definecolor{hriSec2}{rgb}{0.607843137,0.764705882,0.156862745}
\definecolor{hriSec2Dark}{rgb}{0.411764706,0.490196078,0.098039216}
\definecolor{hriSec2Comp}{rgb}{0.254901961,0.156862745,0.509803922}
\definecolor{hriSec2CompDark}{rgb}{0.176470588,0.098039216,0.333333333}

\definecolor{hriSec3}{rgb}{0.509803922,0.078431373,0.31372549}
\definecolor{hriSec3Dark}{rgb}{0.338345865,0.058823529,0.196078431}
\definecolor{hriSec3Comp}{rgb}{1,0.509803922,0}
\definecolor{hriSec3CompDark}{rgb}{0.666666667,0.333333333,0}

% General
\setbeamercolor{normal text}{fg=hriWarmGreyDark}
\setbeamercolor{structure}{fg=hriWarmGreyDark}
\setbeamercolor{alerted text}{fg=hriRed}
\setbeamercolor{example text}{fg=white}
\setbeamercolor{copyright text}{fg=hriWarmGreyLight}
\setbeamercolor{palette primary}{fg=hriWarmGreyDark}
\setbeamercolor{palette secondary}{fg=hriWarmGreyDark,bg=hriWarmGreyLight}
\setbeamercolor{palette tertiary}{fg=black,bg=hriWarmGreyLight}
\setbeamercolor{palette quaternary}{fg=white, bg=hriWarmGreyDark}
% Titlepage
\setbeamercolor{title}{parent=normal text}
\setbeamercolor{subtitle}{parent=normal text}
\setbeamercolor{institute}{parent=normal text}
% Content
\setbeamercolor{frametitle}{parent=palette quaternary}
% Blocks
\setbeamercolor{block title}{parent=palette quaternary}
\setbeamercolor{block body}{parent=palette secondary}
\setbeamercolor{block title example}{fg=white, bg=hriSec1Dark}
\setbeamercolor{block body example}{fg=white, bg=hriSec1}
\setbeamercolor{block title alerted}{fg=white, bg=hriRedDark}
\setbeamercolor{block body alerted}{fg=white, bg=hriRed}
% Notes
\setbeamercolor{note page}{fg=hriWarmGreyDark,bg=hriWarmGreyLight}
\setbeamercolor{note title}{fg=white, bg=hriWarmGreyDark}
\setbeamercolor{note date}{parent=note title}
% Page Number
\setbeamercolor{page number in head/foot}{fg=hriWarmGreyDark}

%---------------------------------------------------------------------
% Fonts
%---------------------------------------------------------------------

% General

% Declare fontfamilys
\if@doNoFlama%
	% Sans serif math option
	\if@doSans%
		% sans serif math %
		\usepackage[no-math]{fontspec}%	
		\setmainfont{Arial}%
	\else%
		% serif math %
		\usepackage{fontspec}%	
		\usefonttheme[onlymath]{serif}%
	\fi%
	\newfontfamily\Light{Arial}%
	\newfontfamily\Book{Arial-Bold}%
	\newfontfamily\Medium{Arial-Bold}%
	\setsansfont{Arial}%
\else%
	% Sans serif math option
	\if@doSans%
		\usepackage[no-math]{fontspec}%	
		\setmainfont{FlamaLight}%
	\else%
		\usepackage{fontspec}%	
		\usefonttheme[onlymath]{serif}%
	\fi%
	\newfontfamily\Light{FlamaLight}%
	\newfontfamily\Book{FlamaBook}%
	\newfontfamily\Medium{FlamaMedium}%
	\setsansfont{FlamaLight}%
\fi%

\renewcommand\UrlFont{\Medium}
% Titlepage
\setbeamerfont{title}{family=\Light,size=\fontsize{20}{20}}
\setbeamerfont{subtitle}{family=\Light,size=\fontsize{12}{14}}
\setbeamerfont{date}{size=\fontsize{8}{10}}
\setbeamerfont{author}{size=\fontsize{12}{15}}
\setbeamerfont{institute}{size=\fontsize{8}{10}}
% Section
\setbeamerfont{section title}{size=\LARGE}
% Content
\setbeamerfont{frametitle}{family=\Light,size=\large}
\setbeamerfont{copyright text}{family=\Light,size=\tiny}
\setbeamerfont{block title}{family=\Book,size=\large}
\setbeamerfont{block title alerted}{family=\Book,size=\large}
\setbeamerfont{alerted text}{family=\Medium}
% Captions
\setbeamerfont{caption name}{family=\Book}

%---------------------------------------------------------------------
% Titlepage
%---------------------------------------------------------------------

% Titlepage structure
\def\maketitle{\ifbeamer@inframe\titlepage\else{\setbeamertemplate{background}{}\frame[plain]{\titlepage}}\fi}
    
\def\titlepage{
\usebeamertemplate{title page}
}
\setbeamertemplate{title page}
{
	% Add background to title page
	\AddToShipoutPictureFG*{\includegraphics[width=\paperwidth]{background.pdf}}
	\begin{minipage}[b][\paperheight]{\textwidth}
	\vspace*{5mm}
	\includegraphics[height=14mm]{./logo}\par
	\vspace*{5mm}
	\ifx\insertsubtitle\@empty%
	\else%
		{\usebeamerfont{title}\usebeamercolor[fg]{title}\MakeUppercase{\inserttitle}\par}%
	\fi%
	\ifx\insertsubtitle\@empty%
	\else%
		{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
		\vspace*{5mm}
	\fi%
	\ifx\insertdate\@empty%
	\else%
		{\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate\par}%
	\fi% 
	
	\vfill
	
	\ifx\insertauthor\@empty%
	\else%
		{\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par}%
	\fi%
	\ifx\insertinstitut\@empty%
	\else%
		\vspace*{3mm}
		{\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par}%
	\fi% 
	\vspace*{5mm}
	\end{minipage}
}

%---------------------------------------------------------------------
% Sectionpages
%---------------------------------------------------------------------

% Make Sectionhead uppercase
\newcommand{\insertsectionHEAD}{%
	\expandafter\insertsectionHEADaux\insertsectionhead}
	\newcommand{\insertsectionHEADaux}[3]{\MakeUppercase{#3}
}

\if@doSectionPage\@empty
\else
% Insert frame with section title at every section start
\AtBeginSection[]
{
\begingroup
\setbeamertemplate{background}{}
\setbeamercolor{background canvas}{bg=hriWarmGreyDark}
\begin{frame}[plain]
\centering
\vfill\usebeamerfont{section title}\textcolor{white}{\insertsectionHEAD}\vfill
\end{frame}
\endgroup
}
\fi

%---------------------------------------------------------------------
% Frametitle
%---------------------------------------------------------------------
\setbeamertemplate{frametitle}
{
\begin{beamercolorbox}[wd=\paperwidth,leftskip=0.3cm,rightskip=0.3cm,ht=3ex,dp=1.5ex]{frametitle}
	 \usebeamerfont{frametitle}\MakeUppercase{\insertframetitle}%
\end{beamercolorbox}
}

%---------------------------------------------------------------------
% Footline
%---------------------------------------------------------------------
\usenavigationsymbolstemplate{}
\setbeamertemplate{footline}
{%
\begin{beamercolorbox}[wd=\textwidth,ht=3ex,dp=1.5ex,leftskip=0.3cm,rightskip=0.3cm]{structure}%
\hfill\usebeamerfont{page number in head/foot}%
\insertframenumber%
\end{beamercolorbox}%
}

%---------------------------------------------------------------------
% Captions
%---------------------------------------------------------------------
\setbeamertemplate{caption label separator}{: }

%---------------------------------------------------------------------
% Blocks
%---------------------------------------------------------------------
\setbeamertemplate{block begin}
{
  \setbeamercolor{item}{parent=block body}
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex]{block title}
    \usebeamerfont*{block title}\insertblocktitle%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  {\nointerlineskip\vskip-0.5pt}%
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex,vmode]{block body}%
}
\setbeamertemplate{block end}  
{\end{beamercolorbox}\vskip\smallskipamount}

\setbeamertemplate{block alerted begin}
{
  \setbeamercolor{item}{parent=block body alerted}
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex]{block title alerted}
    \usebeamerfont*{block title alerted}\insertblocktitle%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  {\nointerlineskip\vskip-0.5pt}%
  \usebeamerfont{block body alerted}%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex,vmode]{block body alerted}%
}
\setbeamertemplate{block alerted end}
{\end{beamercolorbox}\vskip\smallskipamount}

\setbeamertemplate{block example begin}
{
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex]{block title example}
    \usebeamerfont*{block title example}\insertblocktitle%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  {\nointerlineskip\vskip-0.5pt}%
  \usebeamerfont{block body example}%
  \begin{beamercolorbox}[sep=.5ex,dp=0.6ex,leftskip=0.5ex,rightskip=0.5ex,vmode]{block body example}%
}
\setbeamertemplate{block example end}
{\end{beamercolorbox}\vskip\smallskipamount}

%---------------------------------------------------------------------
% Images
%---------------------------------------------------------------------

\newbox\mytempbox
\newdimen\mytempdimen

\newcommand\includegraphicscopyright[3][]{%
  \leavevmode\vbox{\vskip3pt\raggedright\setbox\mytempbox=\hbox{\includegraphics[#1]{#2}}%
    \mytempdimen=\wd\mytempbox\box\mytempbox\par\vskip1pt%
    \usebeamerfont{copyright text}{\usebeamercolor[fg]{copyright text}{\vbox{\hsize=\mytempdimen#3}}}\vskip3pt%
}}

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

\newcommand\imageframe[2][]{%
{
    \setbeamertemplate{background canvas}{
        \includegraphics[width=\paperwidth, height=\paperheight]{#2}
    }
    \setbeamertemplate{background}{}
    \begin{frame}[plain]
        \begin{tikzpicture}[remember picture,overlay]%
            \node at (-1, -4.5) [anchor=south west, shape=rectangle,
            fill=hriSec3Dark, opacity=0.7, align=right, text width=0.5\paperwidth]
            {\usebeamerfont{subtitle}\usebeamercolor[bg]{subtitle}#1\par};
        \end{tikzpicture}
    \end{frame}
}
}


\mode
<all>
