%
% Tema para beamer: LALIC
%
% Por Jander Moreira, 2018-2021
%
%
% Outer theme (definição do espaço fora do conteúdo: cabeçalhos, rodapés)

\mode<presentation>

\RequirePackage{tikz}
\usetikzlibrary{positioning, calc, shapes.misc, math}

\defbeamertemplate*{frametitle}{lalic}[1][]
{
    \begin{beamercolorbox}[wd=\paperwidth, ht=2cm]{frametitle}
		\begin{tikzpicture}[
				overlay, remember picture, 
				faixa do titulo/.style = {
					fill = lalictitlebackground,
					rounded rectangle,
					rounded rectangle west arc = 20, 
					rounded rectangle west arc = none, 
					minimum height = 2.5em,
					minimum width = 0.995\paperwidth,
					anchor = south west,
				},
				fonte titulo/.style = {
					text = lalicfonttitle,
					anchor = west, 
					text depth = 0.25ex,
					font = \Large\bfseries,
				},
				fonte subtitulo/.style = {
					text = lalicfonttitle,
					anchor = west, 
					text depth = 0.25ex,
					font = \normalsize,
				},
			]
%			    \useasboundingbox(0, 0) rectangle (\the\paperwidth, \the\paperheight);
			    
				\node (barra) [faixa do titulo] at (0, 0) {};%
				
				\ifx\insertframesubtitle\@empty{%
					\draw[line width = 3pt, line cap = round,
						draw = lalicbackground]%
						($(barra.south west) + (0, 0.5em)$) --
							++(\textwidth, 0);
					\node[fonte titulo] at ($(barra.west) + (0, 0.1em)$) {\insertframetitle};
				}
				\else{%
					\draw[line width = 2.5pt, line cap = round,
						draw = lalicbackground]%
						($(barra.west) - (0, 0.15em)$) --
						++(\textwidth, 0);
					\node[fonte titulo]%
						at ($(barra.north west) - (0, 0.7em)$) {\insertframetitle};
					\node[fonte subtitulo]%
						at ($(barra.south west) + (0, 0.5em)$) %
						{\raisebox{0.25ex}{$\rhd$}%
							\hspace{0.5em}\insertframesubtitle};
				}
				\fi
		\end{tikzpicture}
    \end{beamercolorbox}
}

\newlength{\progressbar}
\setlength{\progressbar}{1.1\linewidth}
\setbeamertemplate{footline}{%
	\begin{beamercolorbox}[center]{}
		\ifnum\thepage>1\relax%
			\begin{tikzpicture}%[overlay, remember picture]
				\pgfmathparse{\insertframenumber/\inserttotalframenumber}
				\coordinate (progresso)
					at (\pgfmathresult * \progressbar, 0);
				\draw[thick] (0, 0) -- (progresso);
				\draw[dotted] (progresso) --(\progressbar, 0);
				\node[fill = white, rounded corners, draw, anchor = east]
					at (progresso) {\insertframenumber};
			\end{tikzpicture}
			\vskip3pt
			\insertnavigation{0.98\linewidth}
		\fi
		\vskip01cm
	\end{beamercolorbox}
}


\mode<all>