% Copyright 2021 by Jan Benda
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.

\ProvidesPackage{beamerouterthemelines}[2021/02/28 beamer theme with horizontal lines]

\RequirePackage{tikz}

\newif\if@beamer@footline@author
\newif\if@beamer@footline@institute
\newif\if@beamer@footline@date
\newif\if@beamer@footline@title
\newif\if@beamer@footline@page
\newif\if@beamer@footline@logo

\DeclareOptionBeamer{author}{\@beamer@footline@authortrue}
\DeclareOptionBeamer{hideauthor}{\@beamer@footline@authorfalse}
\DeclareOptionBeamer{institute}{\@beamer@footline@institutetrue}
\DeclareOptionBeamer{hideinstitute}{\@beamer@footline@institutefalse}
\DeclareOptionBeamer{date}{\@beamer@footline@datetrue}
\DeclareOptionBeamer{hidedate}{\@beamer@footline@datefalse}
\DeclareOptionBeamer{title}{\@beamer@footline@titletrue}
\DeclareOptionBeamer{hidetitle}{\@beamer@footline@titlefalse}
\DeclareOptionBeamer{page}{\@beamer@footline@pagetrue}
\DeclareOptionBeamer{hidepage}{\@beamer@footline@pagefalse}
\DeclareOptionBeamer{logo}{\@beamer@footline@logotrue}
\DeclareOptionBeamer{hidelogo}{\@beamer@footline@logofalse}

\ExecuteOptionsBeamer{author}
\ExecuteOptionsBeamer{hideinstitute}
\ExecuteOptionsBeamer{hidedate}
\ExecuteOptionsBeamer{hidetitle}
\ExecuteOptionsBeamer{page}
\ExecuteOptionsBeamer{hidelogo}

\ProcessOptionsBeamer

%%%%% \titlelogo command:

\mode<all>{
  \newcommand\titlelogo[1]{\def\inserttitlelogo{#1}}
  \titlelogo{}
}


\mode<presentation>

% margins:
\setbeamersize{text margin left=1em,text margin right=1em}

% no navigation symbols:
\defbeamertemplate{navigation symbols}{empty}{}
\setbeamertemplate{navigation symbols}[empty]

% no side bars:
\setbeamertemplate{sidebar left}[default]

\defbeamertemplate{sidebar right}{empty}{}
\setbeamertemplate{sidebar right}[empty]

% no headline:
\setbeamertemplate{headline}[default]


%%%%% footline %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% footline line:

\defbeamertemplate{footline line}{text}[1][1pt]%
{
  \ifbeamercolorempty[fg]{footline line}{}{%
    \begin{beamercolorbox}[wd=1\paperwidth,dp=0pt,ht=#1,sep=0pt,%
      leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{footline line}%
      \rule{1\linewidth}{#1}%
    \end{beamercolorbox}%
    \nointerlineskip%
  }%
}
\defbeamertemplate{footline line}{page}[1][1pt]%
{
  \ifbeamercolorempty[fg]{footline line}{}{%
    \begin{beamercolorbox}[wd=1\paperwidth,dp=0pt,ht=#1,sep=0pt,%
      leftskip=0pt,rightskip=0pt]{footline line}%
      \rule{1\paperwidth}{#1}%
    \end{beamercolorbox}%
    \nointerlineskip%
  }%
}

\setbeamertemplate{footline line}[text][0.5pt]


%%%%% footline separator:

\defbeamertemplate{footline separator}{text}[1][1pt]{%
  {\usebeamercolor[fg]{footline separator}$\;\;$\rule[-0.55ex]{#1}{2.3ex}$\;$}}
\defbeamertemplate{footline separator}{full}[1][1pt]{%
  {\usebeamercolor[fg]{footline separator}$\;\;$\rule[-1.2ex]{#1}{4ex}$\;$}}
\defbeamertemplate{footline separator}{space}{%
  {\usebeamercolor[fg]{footline separator}$\;\;\;$}}

\setbeamertemplate{footline separator}[text][0.5pt]


%%%%% footline: lines

\defbeamertemplate{footline}{lines}{%
  \usebeamerfont{footline}%
  \usebeamertemplate{footline line}%
  \begin{beamercolorbox}[wd=1\paperwidth,dp=1.2ex,ht=2.8ex,sep=0pt,colsep=0pt,colsep*=0pt,%
    leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{footline}
    \hypersetup{allcolors=.}%
    \newif\if@tempsep%
    \@tempsepfalse%
    % author:
    \if@beamer@footline@author
      \insertshortauthor
      \@tempseptrue
    \fi
    % institute:
    \if@beamer@footline@institute
      \if@tempsep\usebeamertemplate{footline separator}\hskip0.6ex\fi
      \insertshortinstitute
      \@tempseptrue
    \fi
    % date:
    \if@beamer@footline@date
      \if@tempsep\usebeamertemplate{footline separator}\hskip0.6ex\fi
      \insertshortdate
      \@tempseptrue
    \fi
    % title:
    \if@beamer@footline@title
      \if@tempsep\usebeamertemplate{footline separator}\hskip0.6ex\fi
      \insertshorttitle
      \@tempseptrue
    \fi
    \hfill
    % page:
    \if@beamer@footline@page
      \usebeamertemplate{footline separator}
      \insertframenumber
    \fi
    % logo:
    \if@beamer@footline@logo%
      \ifx\insertlogo\@empty\else\quad \raisebox{-1ex}{\insertlogo}\fi%
    \fi
  \end{beamercolorbox}
}

\setbeamertemplate{footline}[lines]


%%%%% frametitle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% frametitle line:

\defbeamertemplate{frametitle line}{text}[1][1pt]%
{
  \ifbeamercolorempty[fg]{frametitle line}{}{%
    \nointerlineskip%
    \begin{beamercolorbox}[wd=1\paperwidth,dp=0pt,ht=#1,sep=0pt,%
      leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{frametitle line}%
      \rule{1\linewidth}{#1}%
    \end{beamercolorbox}%
  }%
}
\defbeamertemplate{frametitle line}{page}[1][1pt]%
{
  \ifbeamercolorempty[fg]{frametitle line}{}{%
    \nointerlineskip%
    \begin{beamercolorbox}[wd=1\paperwidth,dp=0pt,ht=#1,sep=0pt,%
      leftskip=0pt,rightskip=0pt]{frametitle line}%
      \rule{1\paperwidth}{#1}%
    \end{beamercolorbox}%
  }%
}

\setbeamertemplate{frametitle line}[text][0.5pt]


%%%%% frametitle: boxline

\defbeamertemplate{frametitle}{boxline}%
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \usebeamerfont{frametitle}%
  \begin{beamercolorbox}[wd=1\paperwidth,dp=1.2ex,ht=3.2ex,sep=0pt,%
    leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{frametitle}
    \insertframetitle\strut
  \end{beamercolorbox}%
  \usebeamertemplate{frametitle line}%
  \ifx\insertframesubtitle\@empty\else%
    \vspace{-0.5ex}
    \begin{beamercolorbox}[wd=1\paperwidth,sep=0pt,%
      leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{framesubtitle}
      \usebeamerfont{framesubtitle}\insertframesubtitle\strut
    \end{beamercolorbox}%
  \fi%
  \vspace{-1ex}
}
\defbeamertemplate{frametitle}{boxlinelogo}%
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \usebeamerfont{frametitle}%
  \begin{beamercolorbox}[wd=1\paperwidth,dp=1.2ex,ht=3.2ex,sep=0pt,%
    leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{frametitle}
    \insertframetitle\strut%
    \ifx\insertlogo\@empty%
    \else%
    \hfill \raisebox{-0.7ex}{\insertlogo}%
    \fi%
  \end{beamercolorbox}%
  \usebeamertemplate{frametitle line}%
  \ifx\insertframesubtitle\@empty\else%
    \vspace{-0.5ex}
    \begin{beamercolorbox}[wd=1\paperwidth,sep=0pt,%
      leftskip=1\beamer@leftmargin,rightskip=1\beamer@rightmargin]{framesubtitle}
      \usebeamerfont{framesubtitle}\insertframesubtitle\strut
    \end{beamercolorbox}%
  \fi%
  \vspace{-1ex}
}

\setbeamertemplate{frametitle}[boxlinelogo]


%%%%% itemize and enumerate %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% itemize and enumerate symbols:

\defbeamertemplate{itemize item}{arrow}{%
  \begin{tikzpicture}
    \draw[line width=0.2ex] (0ex, 0ex) -- (0.7ex,0.7ex) -- (0ex, 1.4ex);
  \end{tikzpicture}}

\setbeamertemplate{itemize item}[arrow]      % default, triangle, circle, square, ball
\setbeamertemplate{enumerate item}[default]  % default, circle, square, ball


%%%%% block environments:

\setbeamertemplate{blocks}[default]


%%%%% title page %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% title page graphic line:

\defbeamertemplate{title page graphic line}{default}[1][1ex]%
{
  \ifbeamercolorempty[fg]{title page graphic line}{}{%
    \nointerlineskip%
    \begin{beamercolorbox}[wd=1\textwidth,dp=0pt,ht=#1,sep=0pt]{title page graphic line}%
      \rule{1\linewidth}{#1}%
    \end{beamercolorbox}%
  }%
}

\setbeamertemplate{title page graphic line}[default][1.5ex]


%%%%% title page title line:

\defbeamertemplate{title page title line}{default}[1][1ex]%
{
  \ifbeamercolorempty[fg]{title page title line}{}{%
    \nointerlineskip%
    \begin{beamercolorbox}[wd=1\textwidth,dp=0pt,ht=#1,sep=0pt]{title page title line}%
      \rule{1\linewidth}{#1}%
    \end{beamercolorbox}%
  }%
}

\setbeamertemplate{title page title line}[default][0.2ex]


%%%%% title page author \and command:

\defbeamertemplate{title page author and}{space}{\def\beamer@andtitle{\quad}}
\defbeamertemplate{title page author and}{comma}{\def\beamer@andtitle{,\quad}}
\defbeamertemplate{title page author and}{line}{\def\beamer@andtitle{$\;\;\vert\;\;\;$}}
\defbeamertemplate{title page author and}{and}{\def\beamer@andtitle{$\;$\&$\;\;$}}

\setbeamertemplate{title page author and}[line]


%%%%% title page institute \and command:

\defbeamertemplate{title page institute and}{default}{}
\defbeamertemplate{title page institute and}{space}{\def\beamer@andinst{\quad}}
\defbeamertemplate{title page institute and}{comma}{\def\beamer@andinst{,\quad}}
\defbeamertemplate{title page institute and}{line}{\def\beamer@andinst{$\;\;\vert\;\;\;$}}

\setbeamertemplate{title page institute and}[line]


%%%%% title page: leftlines

\defbeamertemplate*{title page}{leftlines}
{
  \vbox{}
  % title logo with line:
  \ifx\inserttitlelogo\@empty\else%
    \begin{beamercolorbox}[wd=\linewidth]{titlelogo}
      \inserttitlelogo%
    \end{beamercolorbox}%
    \vspace{1.2ex}
    \usebeamertemplate{frametitle line}%
    \vspace{1ex}
  \fi
  % title graphic:
  \ifx\inserttitlegraphic\@empty\else%
    \begin{beamercolorbox}[wd=\linewidth]{titlegraphic}
      \inserttitlegraphic%
    \end{beamercolorbox}%
    \usebeamertemplate{title page graphic line}%
  \fi%
  \vfill\vfill\vfill
  % title:
  \begin{beamercolorbox}{title}
    \usebeamerfont{title}\inserttitle\par%
  \end{beamercolorbox}%
  % subtitle:
  \ifx\insertsubtitle\@empty\else%
    \vspace{1ex}
    \begin{beamercolorbox}{subtitle}
      \usebeamerfont{subtitle}\insertsubtitle\par%
    \end{beamercolorbox}%
  \fi%
  \vfill
  \usebeamertemplate{title page title line}%
  \vfill
  % author:
  \begin{beamercolorbox}{author}
    \usebeamertemplate{title page author and}%
    \usebeamerfont{author}\insertauthor
  \end{beamercolorbox}
  \vfill
  % institute and date:
  \begin{beamercolorbox}{institute}
    \usebeamertemplate{title page institute and}%
    \usebeamerfont{institute}\insertinstitute
    \hfill
    \usebeamerfont{date}\insertdate
  \end{beamercolorbox}
}


%%%%% title page: centerlines

\defbeamertemplate*{title page}{centerlines}
{
  \vbox{}
  % title logo with line:
  \ifx\inserttitlelogo\@empty\else%
    \begin{beamercolorbox}[wd=\linewidth,center]{titlelogo}
      \inserttitlelogo%
    \end{beamercolorbox}%
    \vspace{1.2ex}
    \usebeamertemplate{frametitle line}%
    \vspace{1ex}
  \fi
  % title graphic:
  \ifx\inserttitlegraphic\@empty\else%
    \begin{beamercolorbox}[wd=\linewidth,center]{titlegraphic}
      \inserttitlegraphic%
    \end{beamercolorbox}%
    \usebeamertemplate{title page graphic line}%
  \fi%
  \vfill\vfill\vfill
  % title:
  \begin{beamercolorbox}[center]{title}
    \usebeamerfont{title}\inserttitle\par%
  \end{beamercolorbox}%
  % subtitle:
  \ifx\insertsubtitle\@empty\else%
    \vspace{1ex}
    \begin{beamercolorbox}[center]{subtitle}
      \usebeamerfont{subtitle}\insertsubtitle\par%
    \end{beamercolorbox}%
  \fi%
  \vfill
  \usebeamertemplate{title page title line}%
  \vfill
  % author:
  \begin{beamercolorbox}[center]{author}
    \usebeamertemplate{title page author and}%
    \usebeamerfont{author}\insertauthor
  \end{beamercolorbox}
  \vfill
  % institute and date:
  \begin{beamercolorbox}[center]{institute}
    \usebeamertemplate{title page institute and}%
    \usebeamerfont{institute}\insertinstitute
    \hfill
    \usebeamerfont{date}\insertdate
  \end{beamercolorbox}
}

\setbeamertemplate{title page}[leftlines]


%%%%% section page %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% section page separator: space

\defbeamertemplate{section name separator}{space}{}

% section page separator: text

\defbeamertemplate{section name separator}{text}[1][1pt]%
{
  {\usebeamercolor[fg]{section name separator}
    \rule[-0.5ex]{#1}{2.4ex}}
}

\setbeamertemplate{section name separator}[text][1pt]


%%%%% section page: left

\defbeamertemplate{section page}{left}%
{
  \begin{columns}[t,onlytextwidth]
    \begin{column}{0.1\textwidth}
      \usebeamerfont{section name}%
      \raggedleft{\usebeamercolor[fg]{section name}%
        \makebox[0.5\linewidth][r]{\insertsectionnumber}%
        \makebox[0.5\linewidth][c]{\usebeamertemplate{section name separator}}}%
    \end{column}
    \begin{column}{0.9\textwidth}
      \usebeamerfont{section title}%
      {\usebeamercolor[fg]{section title}\hypersetup{allcolors=.}\insertsection}%
    \end{column}
  \end{columns}
}

\setbeamertemplate{section page}[left]


%%%%% start each section with a special slide:

\AtBeginSection{
  \frame[plain,c]{\sectionpage}
}


%%%%% fonts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\familydefault}{\sfdefault}

\setbeamerfont{frametitle}{size=\LARGE}
\setbeamerfont{framesubtitle}{size=\large}

\setbeamerfont{title}{size=\LARGE, shape=\bfseries}
\setbeamerfont{subtitle}{size=\Large, shape=\bfseries}
\setbeamerfont{author}{size=\Large}
\setbeamerfont{institute}{size=\normalsize}

\setbeamerfont*{section title}{size=\Huge}
\setbeamerfont*{section name}{size=\Huge}

\setbeamerfont{footline}{size=\footnotesize}


%%%%% colors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usecolortheme{aptero}

\mode<all>
