\usetheme{Rochester}
\RequirePackage{pgf}
\RequirePackage{siunitx}
\RequirePackage[no-math]{fontspec}
\usepackage{fancyvrb,minted,tcolorbox,datetime}
\tcbuselibrary{skins,breakable,breakable}
\tcbuselibrary{minted,skins}
\usepackage{mwe}

% Hack to get notes in slide pilot
\input{spnotes.tex}

% Anführungszeichen:
\usepackage{csquotes} 
\setquotestyle[guillemets]{german}

% Schriften:
% \defaultfontfeatures[Noto Sans]
% {
%     Extension = .ttf,
%     UprightFont = NotoSans-Light,
%     ItalicFont = NotoSans-Italic,
%     BoldFont = NotoSans-Bold,
%     BoldItalicFont = NotoSans-BoldItalic
% }
% \setsansfont{Noto Sans}
\defaultfontfeatures[FFMetaPro]
{
    Extension = .TTF,
    UprightFont = FFMetaProLight,
    ItalicFont = FFMetaProLightIt,
    BoldFont = FFMetaProBold,
    BoldItalicFont = FFMetaProBoldIt
}
\defaultfontfeatures[AkkuratMono]
{
    Extension = .TTF,
    UprightFont = AkkuratMono-Regular.ttf
}
\setsansfont{FFMetaPro}
\setmonofont{DejaVu Sans Mono}
% \setmonofont{AkkuratMono-Regular}
\usefonttheme{professionalfonts} % Keine serifen im Mathemodus
\setbeamerfont{section in head/foot}{size=\tiny,series=\normalfont}
\setbeamerfont{frametitle}{size=\Large, series=\bf}
\sisetup{detect-all, math-rm = \ensuremath}

% Hintergründe:
\setbeamertemplate{background canvas}{
    \ifnum\c@framenumber=1% On title page:
        \includegraphics[height=\paperheight, width=\paperwidth]{back.pdf}
    \else% Other frames background:
      \ifnum\c@framenumber=\inserttotalframenumber% Last Page
        \includegraphics[height=\paperheight, width=\paperwidth]{back.pdf}
      \fi%
    \fi%
}

% Konfiguration:
\setbeamertemplate{navigation symbols}{}
\setbeamercovered{transparent=0}
%\beamer@onlytextwidthtrue

% Blöcke:
\setbeamertemplate{blocks}[default]
\setbeamercovered{invisible}

% Farben: 
\definecolor{uniwuelightgray} {HTML}{D2D4D5}
\definecolor{uniwueblue}      {HTML}{1F5394}
\definecolor{uniwueblue2}     {HTML}{e2e2f5}
\definecolor{uniwuegreen}     {HTML}{61ba33}
\definecolor{uniwuegreen2}    {HTML}{e8f5e2}
\definecolor{uniwueorange}    {HTML}{f7931d} 
\definecolor{uniwueorange2}   {HTML}{f5e2e2} 
\definecolor{uniwuered}       {HTML}{ba3633} 
\definecolor{note}            {HTML}{FEEFD6}
\setbeamercolor*{Title bar}{fg=black,bg=uniwuelightgray}
\setbeamercolor*{Location bar}{fg=uniwueblue,bg=uniwuelightgray}
\setbeamercolor*{frametitle}{parent=Title bar}
\setbeamercolor*{block title}{bg=uniwueblue,fg=white}
\setbeamercolor*{block body}{bg=uniwuelightgray, fg=black}
\setbeamercolor*{normal text}{bg=white,fg=black}
\setbeamercolor*{block title alerted}{bg=uniwuered,fg=white}
\setbeamercolor*{block body alerted}{bg=uniwuelightgray, fg=black}
\setbeamercolor*{block title example}{bg=uniwuegreen,fg=white}
\setbeamercolor*{block body example}{bg=uniwuelightgray, fg=black}
\setbeamercolor*{section in head/foot}{bg=uniwuelightgray,fg=uniwueblue}
\usecolortheme[named=uniwueblue]{structure}

\definecolor{terminalColor}{RGB}{38,50,56}
\definecolor{Button1}{RGB}{254,94,86}
\definecolor{Button2}{RGB}{254,188,45}
\definecolor{Button3}{RGB}{38,202,59}

% Numerierungen:
\setbeamertemplate{enumerate items}[default]
\setbeamercolor{enumerate subitem}{fg=gray}
\setbeamertemplate{section in toc}{\inserttocsectionnumber.~\color{black}\inserttocsection}
\setbeamercolor{itemize subitem}{fg=gray}

\addtobeamertemplate{block example begin}{}{
  \setbeamercolor{itemize item}{fg=uniwuegreen}%
  \setbeamercolor{itemize subitem}{fg=uniwuegreen}%
  \setbeamercolor{itemize subsubitem}{fg=uniwuegreen}%
  \setbeamercolor{enumerate item}{fg=uniwuegreen}%
  \setbeamercolor{enumerate subitem}{fg=uniwuegreen}%
  \setbeamercolor{enumerate subsubitem}{fg=uniwuegreen}%
}

\addtobeamertemplate{block alerted begin}{}{
  \setbeamercolor{itemize item}{fg=uniwuered}%
  \setbeamercolor{itemize subitem}{fg=uniwuered}%
  \setbeamercolor{itemize subsubitem}{fg=uniwuered}%
  \setbeamercolor{enumerate item}{fg=uniwuered}%
  \setbeamercolor{enumerate subitem}{fg=uniwuered}%
  \setbeamercolor{enumerate subsubitem}{fg=uniwuered}%
}


% Seitenabstände
\setbeamersize{text margin left=0.5cm, text margin right=0.5cm}

% Titel:
\beamer@headheight=0.09\paperwidth%
\setbeamertemplate{headline}{
}
\setbeamertemplate{frametitle}{%
    \vspace{-1pt} % TODO Herausfinden warum man das hier braucht?!
    \begin{beamercolorbox}[left, leftskip=\beamer@leftmargin, rightskip=\beamer@rightmargin, wd=\paperwidth, ht=\beamer@headheight]{frametitle}
        \usebeamerfont{frametitle}%
        \vbox to\beamer@headheight{\vfil\hbox{\insertframetitle}\vfil}%
        \hfill%     
        \vbox to\beamer@headheight{\vfil\hbox{\includegraphics[width=2.85cm]{Logo-EN.pdf}}\vfil}%
    \end{beamercolorbox}%
}

% Fußzeile:
\setbeamertemplate{footline}
{
    \begin{beamercolorbox}[leftskip=\beamer@leftmargin, rightskip=\beamer@rightmargin, wd=\paperwidth, ht=0.28\beamer@headheight, sep=0.1cm]{Location bar}
        \usebeamerfont{section in head/foot}%
        \color{black}\insertshortauthor{} | \hypersetup{hidelinks}~MEMSYS~2024
        \hfill
        \insertframenumber/\inserttotalframenumber%
    \end{beamercolorbox}
}

% Titelseite (Kopiert von Standard Template)
\setbeamertemplate{title page}
{%
    \vspace{-16pt} % TODO Herausfinden warum man das hier braucht?!
    \begingroup
    \begin{beamercolorbox}[left, leftskip=\beamer@leftmargin, rightskip=\beamer@rightmargin, wd=\paperwidth, ht=\beamer@headheight]{frametitle}
        \usebeamerfont{frametitle}%
        \vbox to\beamer@headheight{\vfil\hbox{\insertframetitle}\vfil}%
        \hfill%     
        \vbox to\beamer@headheight{\vfil\hbox{\includegraphics[width=2.85cm]{Logo-EN.pdf}}\vfil}%
    \end{beamercolorbox}%
    \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=north west, inner sep=0pt,outer sep=0pt] at (current page.north west){\includegraphics[height=\beamer@headheight, keepaspectratio]{Uni_logo.pdf}};
    \end{tikzpicture}
    \endgroup
    \begingroup
      \vfill
        \centering
        \begin{beamercolorbox}[sep=8pt,center]{title}
            \usebeamerfont{title}\textbf{\inserttitle}\par%
            \ifx\insertsubtitle\@empty%
            \else%
              \vskip0.25em%
              {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
            \fi%
        \end{beamercolorbox}%
        \vskip1em\par
        \begin{beamercolorbox}[sep=8pt,center]{author}
            \usebeamerfont{author}\insertauthor
        \end{beamercolorbox}
        \begin{beamercolorbox}[sep=8pt,center]{institute}
            \usebeamerfont{institute}\insertinstitute
        \end{beamercolorbox}
        \begin{beamercolorbox}[sep=8pt,center]{date}
            \usebeamerfont{date}\insertdate
        \end{beamercolorbox}\vskip0.5em
        {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
    \endgroup
    \vfill
}

% Zwischenkapitel:
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center]{title}
    \hypersetup{hidelinks}\usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

% Custom Column Definiton von Marei:
\newlength{\ColumnSep}
\setlength{\ColumnSep}{2\tabcolsep}

\ExplSyntaxOn
\newcounter{columncount}
\newlength{\columntotalwidth}
\NewDocumentEnvironment{Columns}{O{} +b}{}{%
	\setcounter{columncount}{0}
	\renewcommand\Column[2]{
		\stepcounter{columncount}
	}
	#2
	\setlength{\columntotalwidth}{\dimexpr\linewidth-\thecolumncount\ColumnSep+\ColumnSep}
	\renewcommand\Column[2]{
			\begin{column}{##1\columntotalwidth}
			##2
			\end{column}
	}
	\begin{columns}[onlytextwidth,#1]
		#2
	\end{columns}
}
\ExplSyntaxOff

\newcommand{\Column}[2]{}

% Line numbers in listings
\renewcommand{\theFancyVerbLine}{\sffamily
    \textcolor[rgb]{0.25,0.25,0.25}{\scriptsize
        \oldstylenums{\arabic{FancyVerbLine}}}}

% Terminal: https://tex.stackexchange.com/questions/609014/is-there-a-package-that-displays-a-terminal-screen-with-code-with-listings-or-mi
\newtcblisting{terminal}{
  listing engine=minted,
  minted style=native,
  minted language=C++,
  enhanced,
  colback=terminalColor,
  colframe=terminalColor,
  listing only,
  title={\hspace{-3mm}\tikz {
      \node[circle,fill=Button1,inner sep=3pt] (c) at (-0.25,0){};
      \node[circle,fill=Button2,inner sep=3pt] (c) at (0.25,0){};
      \node[circle,fill=Button3,inner sep=3pt] (c) at (0.75,0){};
  }}
}

\newtcblisting{python}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=python,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{vhdl}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=vhdl,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{vhdl-small}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=vhdl,
    minted options={linenos=true,numbersep=3mm,texcl=true, fontsize=\footnotesize},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{vhdl-scriptsize}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=vhdl,
    minted options={linenos=true,numbersep=3mm,texcl=true, fontsize=\scriptsize},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{vhdl-tiny}{
  listing engine=minted,
  colback=uniwuelightgray,
  colframe=uniwuelightgray,
  arc=0mm,
  boxrule=0pt,
  listing only,
  left=2mm,
  right=2mm,
  top=2mm,
  bottom=2mm,
  minted style=tango,
  minted language=vhdl,
  minted options={fontsize=\tiny},
  enhanced
}

\newtcblisting{verilog}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=verilog,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{verilog-small}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=tango,
    minted language=verilog,
    minted options={linenos=true,numbersep=3mm,texcl=true,fontsize=\small},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{verilog-tiny}{
  listing engine=minted,
  colback=uniwuelightgray,
  colframe=uniwuelightgray,
  arc=0mm,
  boxrule=0pt,
  listing only,
  left=2mm,
  right=2mm,
  top=2mm,
  bottom=2mm,
  minted style=tango,
  minted language=verilog,
  minted options={fontsize=\tiny},
  enhanced
}

\newtcblisting{cpp}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=trac,
    minted language=C++,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{cpp-tiny}{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwuelightgray,
    arc=0mm,
    boxrule=0pt,
    listing only,
    left=2mm,
    right=2mm,
    top=2mm,
    bottom=2mm,
    minted style=trac,
    minted language=C++,
    minted options={fontsize=\tiny},
    enhanced
}

\newtcblisting{cpp-small}{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwuelightgray,
    arc=0mm,
    boxrule=0pt,
    listing only,
    left=2mm,
    right=2mm,
    top=2mm,
    bottom=2mm,
    minted style=trac,
    minted language=C++,
    minted options={fontsize=\small},
    enhanced
}

\newtcblisting{cpp-scriptsize}{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwuelightgray,
    arc=0mm,
    boxrule=0pt,
    listing only,
    left=2mm,
    right=2mm,
    top=2mm,
    bottom=2mm,
    minted style=trac,
    minted language=C++,
    minted options={fontsize=\scriptsize},
    enhanced
}

\newtcblisting{clang}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=trac,
    minted language=C,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{asm}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=trac,
    minted language=gas,
    minted options={linenos=true,numbersep=3mm,texcl=true},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}

\newtcblisting{asm-small}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=trac,
    minted language=gas,
    minted options={linenos=true,numbersep=3mm,texcl=true,fontsize=\small},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}


\newtcblisting{asm-tiny}[1][]{
    listing engine=minted,
    colback=uniwuelightgray,
    colframe=uniwueblue,
    arc=0mm,
    boxrule=0pt,
    listing only,
    title={\hspace{-4.5mm}#1},
    minted style=trac,
    minted language=gas,
    minted options={linenos=true,numbersep=3mm,texcl=true,fontsize=\tiny},
    left=5mm,
    enhanced,
    overlay={\begin{tcbclipinterior}
      \fill[black!25] (frame.south west) rectangle ([xshift=5mm]frame.north west);
    \end{tcbclipinterior}}
}
