%% This is file `beamerouterthemeTUDa.sty' version 3.39 (2024-06-27),
%% it is part of
%% TUDa-CI -- Corporate Design for TU Darmstadt
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2018--2024 by Marei Peischl <marei@peitex.de>
%%
%% ============================================================================
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <tuda-ci@peitex.de>
%%
%% The development respository can be found at
%% https://github.com/tudace/tuda_latex_templates
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplPackage{beamerouterthemeTUDa}{2024-04-21}{3.37}{Outer~beamer~theme~of~tuda-ci~design~of~2023}

\PassOptionsToPackage{paper=slide}{tudarules}
\RequirePackage{tudarules}

\dim_new:N \l__ptxcd_beamer_extraindent_dim
\dim_new:N {\g__ptxcd_beamer_sep_dim}
\dim_gset:Nn \g__ptxcd_beamer_sep_dim {.3\c_ptxcd_logoheight_dim}
\dim_new:N \g__ptxcd_beamer_logosep_dim
\dim_gset:Nn \g__ptxcd_beamer_logosep_dim{2mm}


\cs_if_exist:NF \g__ptxcd_colorframetitle_bool {\bool_new:N \g__ptxcd_colorframetitle_bool}

\keys_define:nn {ptxcd/beamer/outer} {
	logo .bool_gset:N = \g_ptxcd_headlinelogo_bool,
	logo .default:n =true,
	logo .initial:n =true,
	logofile .tl_gset:N = \g_ptxcd_logofile_tl,
	logofile .initial:n = tuda_logo,
	colorframetitle .code:n =  \msg_warning:nnn {tudabeamer} {option-removed} {colorframetitle},
	centerframetitle .code:n = \msg_warning:nnn {tudabeamer} {option-removed} {centerframetitle},
	framebgcolor .code:n = \msg_warning:nnn {tudabeamer} {option-removed} {framebgcolor},
	singleframebgcolor .code:n = \msg_warning:nnn {tudabeamer} {option-removed} {singleframebgcolor},
	headsepline .code:n = \msg_warning:nnn {tudabeamer} {option-removed} {headsepline},
	extendedspace .bool_gset:N = \g__ptxcd_extended_space_bool,
	headrule .bool_gset:N = \g__ptxcd_headrule_bool,
	uppercase-frametitle .bool_gset:N = \g__ptxcd_uppercase_frametitle_bool,
	uppercase-frametitle .default:n = true,
	uppercase-frametitle .initial:n = true,
}

\define@key{beamerframe}{bgcolor}{
	\keys_set:nn {ptxcd/beamer/outer} {
		singleframebgcolor=#1
	}
}

\define@key{beamerframe}{uppercase}{
	\keys_set:nn {ptxcd/beamer/outer} {
		uppercase-frametitle=#1
	}
}

\ProcessKeyOptions[ptxcd/beamer/outer]


\mode<presentation>

\RequirePackage{graphicx}

\bool_if:NT \g__ptxcd_colorframetitle_bool
	{\dim_set:Nn \l__ptxcd_beamer_extraindent_dim {\g__ptxcd_beamer_logosep_dim}}

\setbeamersize{
	text~margin~left=\dim_eval:n {\paperwidth/34},
	text~margin~right=\dim_eval:n {\paperwidth/38}
}

\cs_new:Nn \__ptxcd_beamer_linewidth: {\dim_eval:n {\paperwidth-\beamer@leftmargin-\beamer@rightmargin}}

%Logo

\box_new:N \g__ptxcd_logo_box
\hbox_gset:Nn \g__ptxcd_logo_box {%
	\raisebox{\dim_eval:n {-\height+.33\c_ptxcd_logoheight_dim}}{\includegraphics[height=\c_ptxcd_logoheight_dim]{\g_ptxcd_logofile_tl}}%
}

\bool_if_exist:NF \l_ptxcd_tmpa_bool {\bool_new:N \l_ptxcd_tmpa_bool}

\defbeamertemplate*{footline}{TUDa2023}{
	\begin{beamercolorbox}[leftskip=\beamer@leftmargin,rightskip=\beamer@rightmargin]{footline}
	\usebeamerfont{footline}
	\rlap{\insertshortdate}
	\hfill
	\makebox[0pt][c]{
		\bool_set_false:N \l_ptxcd_separate_bool
		\clist_map_variable:nNn {department, institute, author} \l_tmpa_tl {
			\tl_if_empty:cF {beamer@short\l_tmpa_tl} {
				\bool_if:NTF \l_ptxcd_separate_bool
					 {\usebeamertemplate{footline~sep}}
					{\bool_set_true:N  \l_ptxcd_separate_bool}
				\use:c {insertshort\l_tmpa_tl}
			}
		}
	}
	\hfill
	\llap{\insertframenumber}
	\par\vspace{-\dp\strutbox}
	\end{beamercolorbox}
	\skip_vertical:n {\dimexpr\paperheight/32-\dp\strutbox}
}

\setbeamertemplate{footline~sep}{\space\smash{\rule[-.5\dp\strutbox]{.25pt}{\ht\strutbox}}\space}

\RenewDocumentCommand{\logo}{sm}{
	\IfBooleanTF{#1}{
	\setbeamertemplate{logo}{\resizebox{!}{.06\beamer@paperheight}{\mbox{#2}}}
	}{
	\setbeamertemplate{logo}{#2}
	}
}

\defbeamertemplate*{headline}{TUDa2023}{
	\bool_if:NT \g__ptxcd_headrule_bool {
		\cs_if_exist:NF \ptxcd_beamer_headrule {
			\ptxcd_makeheadrule[color=identbarcolor,width=\paperwidth]{ptxcd_beamer_headrule}
		}
		\ptxcd_beamer_headrule\par\nointerlineskip
	}
	\bool_if:NTF \g__ptxcd_extended_space_bool {
		\bool_if:NTF \g__ptxcd_headrule_bool {
			\skip_vertical:n {\dim_eval:n {+\paperheight/38}}
			\strut
		} {
			\skip_vertical:n {\dim_eval:n {\paperheight/16}}
		}
	}{
		\skip_vertical:n {\dimexpr\paperheight/38}
		\hspace*{\beamer@leftmargin}\rlap{\usebeamertemplate***{title~in~head/foot}}
	}
	\hspace*{\fill}
	
	\bool_if:NT \g_ptxcd_headlinelogo_bool  {
	%partnerlogo
	\bool_if:NT \g__ptxcd_extended_space_bool \smash {
		\raisebox{\dimexpr-\height+\ht\strutbox}{
			\box_use:N \g__ptxcd_partnerlogo_box
		}
	}
	
	\skip_horizontal:n {\dimexpr\paperheight/38}
	%logo
	\bool_if:NTF \g__ptxcd_headrule_bool {
		\raisebox{2mm}[0pt][0pt]{\setlength{\fboxsep}{\z@}\colorbox{white}{\rule{\z@}{\dim_eval:n {\box_ht:N \g__ptxcd_logo_box+\box_ht:N \ptxcd_beamer_headrule_box + \box_dp:N \ptxcd_beamer_headrule_box+1pt}}\box_use:N \g__ptxcd_logo_box}}
			\hspace*{10pt}
	} {
		\bool_if:NT \g__ptxcd_extended_space_bool \smash {\box_use:N \g__ptxcd_logo_box}
		\hspace*{.7pt}
	}
	}
	\par
}

\setbeamertemplate{title~in~head/foot}{
	\bool_set_false:N \l_ptxcd_separate_bool
	\tl_if_empty:NF {\beamer@shorttitle} {
		\bool_set_true:N \l_ptxcd_separate_bool
		\text_uppercase:n {\beamer@shorttitle}
	}
	\tl_if_empty:NF {\beamer@shortauthor} {
		\bool_if:NT \l_ptxcd_separate_bool {
			\space/\space
		}
		\text_uppercase:n {\beamer@shortauthor}
	}
}


\defbeamertemplate*{sidebar~right}{TUDa2023}{
	\bool_if:NT \g_ptxcd_headlinelogo_bool  {
		\vspace{\c_ptxcd_logoheight_dim}
		\llap{\box_use:N \g__ptxcd_sublogo_box}
	}
}

\defbeamertemplate*{frametitle}{TUDa2023}[1][left]{%
	\nointerlineskip%
	\bool_if:NF \g__ptxcd_extended_space_bool
		{\vskip.55ex}
	\begin{beamercolorbox}[
		wd=\dim_eval:n {\bool_if:NT \g__ptxcd_extended_space_bool {-\box_wd:N \g__ptxcd_logo_box } \box_if_empty:NF \g__ptxcd_sublogo_box {-\box_wd:N \g__ptxcd_sublogo_box - 1em}+ \textwidth},
		]{frametitle}
	    \usebeamerfont{frametitle}%
	    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
	    \vphantom{Ü}
	    \bool_if:NT \g__ptxcd_uppercase_frametitle_bool \text_uppercase:n {\insertframetitle}\strut
	    \par%
	    {%
	      \ifx\insertframesubtitle\@empty%
	      \else%
	      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\strut\text_uppercase:n {\insertframesubtitle}\strut\par}%
	      \fi
	    }%
	    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
	\end{beamercolorbox}
	\vskip.5ex
}
\newcommand*{\setupTUDaFrame}[1]{
	\keys_set:nn {ptxcd/beamer/outer} {#1}
}

\mode
<all>

\endinput
