% Name           : beamerthemeelegance.sty
% Copyright      : Ivan Cukic (ivan at cukic.co) 2016
%                  Benjamin Weiss (benjamin.weiss@student.hs-rm.de) 2013
% Version        : 0.1
% License        : This file may be distributed and/or modified under the
%                  GNU General Public License, version 3 or later
% Description    : Customizable beamer theme

\ProvidesPackage{beamerthemeelegance}[2017/07/01]

\usepackage{eso-pic}
\usepackage{etoolbox}
% \setbeamercovered{transparent=60}

\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 unnumbered]
\setbeamertemplate{subsection in toc}[subsections unnumbered]
\setbeamertemplate{subsection in toc}{\vspace{.2cm}\inserttocsubsection\\}

%---------------------------------------------------------------------
% Itemize
%---------------------------------------------------------------------
\setbeamertemplate{itemize item}[square]
\setbeamertemplate{itemize subitem}[square]
\setbeamertemplate{itemize subsubitem}[square]

\setlength{\parskip}{0.5em}

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

% Primary Colors
\definecolor{eleganceRed}{rgb}{0.882352941,0,0.098039216}
\definecolor{eleganceRedDark}{rgb}{0.588235294,0,0.058823529}
\definecolor{eleganceWarmGreyDark}{rgb}{0.274509804,0.254901961,0.235294118}
\definecolor{eleganceWarmGreyLight}{rgb}{0.666666667,0.647058824,0.62745098}
% \definecolor{eleganceWarmGreyLight}{rgb}{1,1,1}

% Secondary Colors
\definecolor{eleganceSec1}{rgb}{0,0.588235294,0.509803922}
\definecolor{eleganceSec1Dark}{rgb}{0,0.392156863,0.31372549}
\definecolor{eleganceSec1Comp}{rgb}{0.294117647,0.745098039,0.882352941}
\definecolor{eleganceSec1CompDark}{rgb}{0.196078431,0.490196078,0.568627451}

\definecolor{eleganceSec2}{rgb}{0.607843137,0.764705882,0.156862745}
\definecolor{eleganceSec2Dark}{rgb}{0.411764706,0.490196078,0.098039216}
\definecolor{eleganceSec2Comp}{rgb}{0.254901961,0.156862745,0.509803922}
\definecolor{eleganceSec2CompDark}{rgb}{0.176470588,0.098039216,0.333333333}

\definecolor{eleganceSec3}{rgb}{0.509803922,0.078431373,0.31372549}
\definecolor{eleganceSec3Dark}{rgb}{0.338345865,0.058823529,0.196078431}
\definecolor{eleganceSec3Comp}{rgb}{1,0.509803922,0}
\definecolor{eleganceSec3CompDark}{rgb}{0.666666667,0.333333333,0}

% General
\setbeamercolor{normal text}{fg=eleganceWarmGreyDark}
\setbeamercolor{structure}{fg=eleganceWarmGreyDark}
\setbeamercolor{alerted text}{fg=eleganceRed}
\setbeamercolor{example text}{fg=white}
\setbeamercolor{copyright text}{fg=eleganceWarmGreyLight}
\setbeamercolor{palette primary}{fg=eleganceWarmGreyDark}
\setbeamercolor{palette secondary}{fg=eleganceWarmGreyDark,bg=white}
\setbeamercolor{palette tertiary}{fg=eleganceWarmGreyDark,bg=white}
\setbeamercolor{palette quaternary}{fg=white,bg=eleganceWarmGreyDark}

% 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=eleganceSec1Dark}
\setbeamercolor{block body example}{fg=white, bg=eleganceSec1}
\setbeamercolor{block title alerted}{fg=white, bg=eleganceRedDark}
\setbeamercolor{block body alerted}{fg=white, bg=eleganceRed}

% Notes
\setbeamercolor{note page}{fg=eleganceWarmGreyDark,bg=eleganceWarmGreyLight}
\setbeamercolor{note title}{fg=white, bg=eleganceWarmGreyDark}
\setbeamercolor{note date}{parent=note title}

% Page Number
\setbeamercolor{page number in head/foot}{fg=eleganceWarmGreyDark}

\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\frame[plain]{
    \titlepage
}\fi}
\def\titlepage{\usebeamertemplate{title page}}
\setbeamertemplate{title page}
{
    % Add background to title page
    \begin{minipage}[b][\paperheight]{\textwidth}
        \vspace*{5mm}
        %\includegraphics[height=10mm]{./style/images/logo.png}\par
        \vspace*{5mm}
        \ifx\insertsubtitle\@empty%
        \else%
            % {\usebeamerfont{title}\usebeamercolor[fg]{title}\MakeUppercase{\inserttitle}\par}%
            {\usebeamerfont{title}\usebeamercolor[fg]{title}\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%

        \vspace*{2cm}

        \ifx\insertauthor\@empty%
        \else%
            {\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par}%
        \fi%
        \ifx\insertinstitut\@empty%
        \else%
            \vspace*{5mm}
            {\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par}%
        \fi%
        \vspace*{3mm}
    \end{minipage}
}

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

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

    \vspace{1cm}
    \footnotesize
    \tableofcontents[sections=\value{section},sectionstyle=hide/hide]
    \vspace{-4cm}
}

\if@doSectionPage\@empty
\else
% Insert frame with section title at every section start
\AtBeginSection[]
{
\begingroup
\setbeamercolor{background canvas}{bg=mainthemecolour}
\setbeamertemplate{background canvas} {\includegraphics[width=\paperwidth,height=\paperheight]{./style/images/background-section.pdf}}
\begin{frame}[plain]
\centering
\vfill\usebeamerfont{section title}\textcolor{white}{\insertsectionHEAD}\vfill
\end{frame}
\endgroup
}
\fi

%\setbeamertemplate{background canvas} {\includegraphics[width=\paperwidth,height=\paperheight]{./style/images/background-slide.pdf}}

\setbeamertemplate{background canvas}{%
   \ifnumequal{\c@framenumber}{1}{%
       % First frame
       \includegraphics[width=\paperwidth,height=\paperheight]{./style/images/background-title.pdf}
   }{%
       \includegraphics[width=\paperwidth,height=\paperheight]{./style/images/background-slide.pdf}
   }%
}

%---------------------------------------------------------------------
% Frametitle
%---------------------------------------------------------------------
\setbeamertemplate{frametitle}
{
    \begin{beamercolorbox}[wd=\paperwidth,leftskip=0.3cm,rightskip=0.3cm,ht=3ex,dp=1.5ex]{}
        % If you remove section titles, you can play with this

        % for the title to be vertically aligned
        % .\\
        % \vspace{-.3cm}
        % \hspace{-0.3cm}\includegraphics[width=\paperwidth,height=1cm]{./style/images/header.png}\\
        % \vspace{-.97cm}
        \usebeamerfont{frametitle}\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%
}}

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

\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Noto Sans}
\setsansfont{Noto Sans}
\setmonofont{Hack}

\mode
<all>
