%% This is file `beamerinnerthemeTUDa.sty' version 3.40 (2024-07-01)
%% 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}
\ProvidesExplPackage{beamerinnerthemeTUDa}{2024-04-21}{3.37}{Inner~beamer~theme~of~tuda-ci}

\int_new:N \g__ptxcd_beamer_toc_col_int

\tl_if_exist:NF \g__ptxcd_design_tl {
	\tl_new:N \g__ptxcd_design_tl
	\keys_define:nn {ptxcd/beamer} {
		design .choice:,
		design / 2023 .code:n = {
			\tl_gset:Nn  \g__ptxcd_design_tl {2023}
			\PassOptionsToClass{aspectratio=169}{beamer}
		},
		design / 2008 .code:n = {
			\tl_gset:Nn  \g__ptxcd_design_tl {2008}
		},
		design .initial:n = 2023,
		design2023 .meta:n = {design=2023},
		design2008 .meta:n = {design=2008},
	}
}

\keys_define:nn {ptxcd/beamer/inner} {
	author-on-title .bool_gset:N = \g_ptxcd_authorontitle_bool,
	author-on-title .initial:n = false,
	author-on-title .default:n = true,
	authorontitle .meta:n = {author-on-title=#1},
	toc-columns .choices:nn =  {one,two,auto} {
		\int_gset_eq:NN \g__ptxcd_beamer_toc_col_int  \l_keys_choice_int
	},
	toc-columns / 1 .meta:n = {toc-columns=one},
	toc-columns / 2 .meta:n = {toc-columns=two},
	toc-columns .initial:n = auto,
	design .meta:nn = {ptxcd/beamer} {design=#1}
}

\ProcessKeyOptions[ptxcd/beamer/inner]

\ExplSyntaxOff
\RequirePackage{trimclip}
\ExplSyntaxOn

\box_new:N \l__ptxcd_titlegraphic_box
\box_new:N \l__ptxcd_titlehead_box
\dim_new:N \l__ptxcd_titlegraphic_ht_dim
\dim_new:N \l__ptxcd_titlegraphic_wd_dim

\box_if_exist:NF \g__ptxcd_logo_box {
	\dim_new:N \g__ptxcd_beamer_logosep_dim
	\dim_new:N \l__ptxcd_beamer_extraindent_dim
	\dim_new:N \g__ptxcd_beamer_sep_dim
	\box_new:N \g__ptxcd_logo_box
}

\cs_set:Nn \__ptxcd_block_colorsep: {.75ex}

\RenewDocumentCommand{\titlegraphic}{sm}{
	\IfBooleanTF{#1}{
		\def\inserttitlegraphic{
			\hbox_set:Nn \l__ptxcd_titlegraphic_box {\raisebox{\depth}{#2}}
			\box_resize_to_wd:Nn \l__ptxcd_titlegraphic_box {\width}
			\dim_compare:nTF {\box_ht:N \l__ptxcd_titlegraphic_box - \height> \c_zero_dim}
			{
				\dim_set:Nn \l_tmpa_dim {.5\box_ht:N \l__ptxcd_titlegraphic_box - .5\height}
				\clipbox{0pt~\dim_eval:n{\l_tmpa_dim}~0pt~\dim_eval:n{\l_tmpa_dim}}{\box_use:N \l__ptxcd_titlegraphic_box}
			}{
				\box_resize_to_ht:Nn \l__ptxcd_titlegraphic_box {\height}
				\dim_set:Nn \l_tmpa_dim {(\box_wd:N \l__ptxcd_titlegraphic_box - \width) / 2}
				\clipbox{\dim_eval:n{\l_tmpa_dim}~0pt~\dim_eval:n{\l_tmpa_dim}~0pt}{\box_use:N \l__ptxcd_titlegraphic_box}
			}
		}
	}{
		\def\inserttitlegraphic{#2}
	}
}

\useinnertheme{TUDa\g__ptxcd_design_tl}

% Blocks
\defbeamertemplate*{block~begin}{TUDa}{
	\par\vskip\medskipamount%
	\begin{beamercolorbox}[wd=\dimexpr\linewidth+2\l__ptxcd_beamer_extraindent_dim,sep=.5pt,
		leftskip=\dim_eval:n {\dim_compare:nTF {\l__ptxcd_beamer_extraindent_dim>\c_zero_dim} {\l__ptxcd_beamer_extraindent_dim-\beamer@colbox@sep} {\__ptxcd_block_colorsep:}},
	]{block~title}
	\ifx\insertblocktitle\@empty
	\else
	\begin{beamercolorbox}[colsep*=\__ptxcd_block_colorsep:,
		 wd=\dimexpr\linewidth-1pt-1.5ex\relax]{block~title}
		\usebeamerfont*{block title}\insertblocktitle%
	\end{beamercolorbox}%
	\ifbeamercolorempty[bg]{block~title}
	{}
	{\ifbeamercolorempty[bg]{block~body}{}{\par\nointerlineskip\vskip-0.5pt}}%
	\leavevmode
	\fi
	\begin{beamercolorbox}[colsep*=\__ptxcd_block_colorsep:,vmode, wd=\dimexpr\linewidth-1.5ex-1pt\relax]{block~body}%
		\usebeamerfont{block~body}%
		\ifbeamercolorempty[bg]{block~body}{\vskip-.25ex}{\vskip-\__ptxcd_block_colorsep:}\vbox{}%
}
\defbeamertemplate*{block~end}{TUDa}
	{\end{beamercolorbox}\end{beamercolorbox}\vskip\smallskipamount}

\defbeamertemplate*{block~alerted~begin}{TUDa}{
	\par\vskip\medskipamount%
	\begin{beamercolorbox}[
		wd=\dimexpr\linewidth+2\l__ptxcd_beamer_extraindent_dim,
		sep=1.5pt,
		leftskip=\dim_eval:n {\dim_compare:nTF {\l__ptxcd_beamer_extraindent_dim>\c_zero_dim} {\l__ptxcd_beamer_extraindent_dim-\beamer@colbox@sep} {\__ptxcd_block_colorsep:}},
	]{block~frame~alerted}
	\ifx\insertblocktitle\@empty
	\else
	\begin{beamercolorbox}[wd=\dim_eval:n {\linewidth-1.5ex-3pt},colsep*=\__ptxcd_block_colorsep:]{block~title~alerted}
		\usebeamerfont*{block~title~alerted}\insertblocktitle%
	\end{beamercolorbox}%
	\vskip1.5pt\par\nointerlineskip
	\fi
	\leavevmode
	\usebeamerfont{block~body~alerted}%
	\begin{beamercolorbox}[wd=\dim_eval:n {\linewidth-1.5ex-3pt},colsep*=\__ptxcd_block_colorsep:]{block~body~alerted}%
}
\defbeamertemplate*{block~alerted~end}{TUDa}
	{\end{beamercolorbox}\end{beamercolorbox}\vskip\smallskipamount}


\defbeamertemplate*{block~example~begin}{TUDa}{
	\par\vskip\medskipamount%
	\begin{beamercolorbox}[
		wd=\dimexpr\linewidth+2\l__ptxcd_beamer_extraindent_dim,
		sep=1.5pt,
		leftskip=\dim_eval:n {\dim_compare:nTF {\l__ptxcd_beamer_extraindent_dim>\c_zero_dim} {\l__ptxcd_beamer_extraindent_dim-\beamer@colbox@sep} {\__ptxcd_block_colorsep:}},
		]{block~frame~example}
	\ifx\insertblocktitle\@empty
	\else
	\begin{beamercolorbox}[wd=\dim_eval:n {\linewidth-1.5ex-3pt},colsep*=\__ptxcd_block_colorsep:]{block~title~example}
		\usebeamerfont*{block~title~example}\insertblocktitle%
	\end{beamercolorbox}%
\vskip1.5pt\par\nointerlineskip
	\fi
	\leavevmode
	\usebeamerfont{block~body~example}%
	\begin{beamercolorbox}[wd=\dim_eval:n {\linewidth-1.5ex-3pt},colsep*=\__ptxcd_block_colorsep:]{block~body~example}%
}
\defbeamertemplate*{block~example~end}{TUDa}
	{\end{beamercolorbox}\end{beamercolorbox}\vskip\smallskipamount}



\endinput
