% \iffalse meta-comment -------------------------------------------------------
% Copyright (C) 2021 Thomas Lambert <trigon@thl.ovh>
% Other contributors to this theme are listed here:
%     https://gitlab.com/thlamb/beamertheme-trigon/-/graphs/master
%
% The original template was heavily inspired by Metropolis from Matthias
% Vogelgesang.
%
% License CC-BY-SA 4.0
% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
% International License (https://creativecommons.org/licenses/by-sa/4.0/)
% ------------------------------------------------------------------------- \fi
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerouterthemetrigon}[2023/02/20 v0.7.0 Trigon outer theme]
%</package>
% \fi
% \CheckSum{0}
% \StopEventually{}
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
%
% \subsection{\themename outer theme}
%
% A |beamer| outer theme dictates the style of the frame elements traditionally
% set outside the ``body'' of each slide, such as the frame title, the logo, the
% footer, etc.
%
% \subsubsection{Package dependencies}
%
%    \begin{macrocode}
\RequirePackage{pgfopts}
%    \end{macrocode}
%
% \subsubsection{Definitions}
%
% We define the command |\smalllogo| to specify the logo that needs to be applied
% displayed on all normal frames. This command is just a replacement for
% |\includegraphics|, so it accepts the same options.
%    \begin{macrocode}
\def\logsmall{}
\newcommand*\smalllogo[2][width=20pt]{
\ifx#2\@empty\else
  \edef\logsmall{\includegraphics[#1]{#2}}
\fi
}
%    \end{macrocode}
%
% \subsubsection{Options}
%
% \begin{macro}{numbering}
% Adds slide number to the bottom of each regular frame
%    \begin{macrocode}
\pgfkeys{
  /trigon/outer/numbering/.cd,
  .is choice,
  none/.code=\setbeamertemplate{frame numbering}[none],
  counter/.code=\setbeamertemplate{frame numbering}[counter],
  fraction/.code=\setbeamertemplate{frame numbering}[fraction]
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\trigon@outer@setdefaults}
% Sets default values for the outer theme options.
%    \begin{macrocode}
\newcommand{\trigon@outer@setdefaults}{
  \pgfkeys{/trigon/outer/.cd,
    numbering=counter
  }
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Frame title}
%
% \begin{macro}{frametitle}
% Template for the frame title
%    \begin{macrocode}
\defbeamertemplate*{frametitle}{trigon}
{
  \vspace{-1pt}
  \begin{beamercolorbox}[wd=\paperwidth,leftskip=0.05\paperwidth]{frametitle}
    \vskip.4cm
    \ifx\insertframesubtitle\@empty%
      {\usebeamerfont{frametitle}\usebeamercolor[fg]{frametitle}\insertframetitle}%
    \else%
      {\usebeamerfont{frametitle}\usebeamercolor[fg]{frametitle}\insertframetitle}\\[-.25cm]
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}%
    \fi
    \vskip.3cm
  \end{beamercolorbox}
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Fame header}
%
% \begin{macro}{headline}
% Templates for the frame header
%    \begin{macrocode}
\defbeamertemplate{headline}{none}{}
\defbeamertemplate*{headline}{logo}{
  \ifx\logsmall\@empty\else
    \hfill\logsmall\hspace{20pt}\vspace{-40pt}
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Frame footer}
%
% Define various template for frame footer and manage frame numbering.
%    \begin{macrocode}
\setbeamertemplate{navigation symbols}{}

\defbeamertemplate{frame footer}{none}{}
\defbeamertemplate{frame footer}{custom}[1]{ #1 }
\defbeamertemplate{frame numbering}{none}{}
\defbeamertemplate{frame numbering}{counter}{\insertframenumber}
\defbeamertemplate{frame numbering}{fraction}{
  \insertframenumber/\inserttotalframenumber
}

\defbeamertemplate{footline}{plain}{%
  \begin{beamercolorbox}[wd=\textwidth, sep=10pt]{page number in head/foot}%
    \usebeamerfont{page number in head/foot}%
    \usebeamercolor[fg]{page number in head/foot}%
    \usebeamertemplate*{frame footer}
    \hfill%
    \usebeamertemplate*{frame numbering}
  \end{beamercolorbox}%
}

\setbeamertemplate{footline}[plain]
%    \end{macrocode}
%
% \begin{macro}{appendix}
% Removes page numbering and per-slide progress bars when |\appendix| is
% called. This makes it easier to include additional ``backup slides'' at
% the end of the presentation, especially in conjunction with the package
% |appendixnumberbeamer|.
%    \begin{macrocode}
\AtBeginDocument{%
  \apptocmd{\appendix}{%
    \pgfkeys{%
      /trigon/outer/.cd,
    numbering=none}
  }{}{}
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Process package options}
%
%    \begin{macrocode}
\trigon@outer@setdefaults
\ProcessPgfPackageOptions{/trigon/outer}
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
% \Finale
\endinput
