% 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 outer theme for beamer with a line below the frame title]

\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


\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 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:
\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 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:
\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]

\mode<all>
