% Copyright (c) 2013-26 Stephane GALLAND <galland@arakhne.org>
%
% UTBM logo and name are registered and owned by the
% "Universite de Technologie de Belfort-Montbeliard".
%
% UBE logo and name are registered and owned by the
% "Universite Bourgogne Europe".
%
% CIAD logo and name are registered and owned by the
% "Laboratoire Connaissance et Intelligence Artificielle Distribuées".
% 
% This program is free library; you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as
% published by the Free Software Foundation; either version 3 of the
% License, or any later version.
%
% This library is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; see the file COPYING.  If not,
% write to the Free Software Foundation, Inc., 59 Temple Place - Suite
% 330, Boston, MA 02111-1307, USA.
%
\ProvidesPackage{beamerinnerthemeCIAD}[2026/05/20]

\DeclareOptionBeamer{language}{\gdef\beamer@innertheme@ciad@lang{#1}}
%\ExecuteOptionsBeamer{left}
\ProcessOptionsBeamer

\mode<presentation>

%------------------------------------
% General configuration

\useinnertheme{rectangles}

%------------------------------------
% Footnotes
\global\let\footnoterule\relax % no rule for footnotes
\setbeamertemplate{footnote}[default]

%------------------------------------
% Standard Blocks
\setbeamertemplate{blocks}[default,shadow=false]

% Issue #16: The size of the block title must follow the size of the enclosing context.
\setbeamerfont{block title}{size={}}

% Remove space before the block
\addtobeamertemplate{block begin}{\vskip -\medskipamount}{}
%\addtobeamertemplate{block end}{\vskip \smallskipamount}{}

%------------------------------------
% Code

% Create the style for the pseudo-code or programs
\defbeamertemplate*{code basic style}{default}{%
	\tiny%
}
\defbeamertemplate*{code inline style}{default}{%
	\normalcolor%
}
\defbeamertemplate*{code identifier style}{default}{%
	\ttfamily%
}
\defbeamertemplate*{code keyword style}{default}{%
	\bfseries%
}

%------------------------------------
% Definition Block

% Redefine the style for definition blocks
\BeforeBeginEnvironment{definition}{%
	\setbeamercolorXXX{block title saved}{fg=block title.fg,bg=block title.bg}%
	\setbeamercolorXXX{block body saved}{fg=block body.fg,bg=block body.bg}%
	\setbeamercolorXXX{block title}{fg=block title definition.fg, bg=block title definition.bg}%
	\setbeamercolorXXX{block body}{fg=block body definition.fg, bg=block body definition.bg}%
}
\AfterEndEnvironment{definition}{
	\setbeamercolorXXX{block title}{fg=block title saved.fg, bg=block title saved.bg}%
	\setbeamercolorXXX{block body}{fg=block body saved.fg, bg=block body saved.bg}%
}

% Define new block for definitions
\newenvironment<>{definitionblock}[1]{%
	\begin{actionenv}#2%
	\setbeamercolorXXX{block title saved}{fg=block title.fg,bg=block title.bg}%
	\setbeamercolorXXX{block body saved}{fg=block body.fg,bg=block body.bg}%
	\setbeamercolorXXX{block title}{fg=block title definition.fg, bg=block title definition.bg}%
	\setbeamercolorXXX{block body}{fg=block body definition.fg, bg=block body definition.bg}%
	\begin{block}{#1}%
}{%
	\end{block}%
	\end{actionenv}%
	\setbeamercolorXXX{block title}{fg=block title saved.fg, bg=block title saved.bg}%
	\setbeamercolorXXX{block body}{fg=block body saved.fg, bg=block body saved.bg}%
}

%------------------------------------
% Theorem Block

\setbeamertemplate{theorem begin}{%
	\begin{\inserttheoremblockenv}%
		{%
			\ifthenelse{\equal{\inserttheoremblockenv}{definitionblock}}{%
				\ifx\inserttheoremaddition\@empty%
				\inserttheoremname%
				\else%
				\inserttheoremaddition%
				\fi%
			}{%
				\inserttheoremname%
				\ifx\inserttheoremaddition\@empty\else\ (\inserttheoremaddition)\fi%
			}%
		}%
	}

%------------------------------------
% Content of the library slide

\defbeamertemplate*{library slide content}{default}{%
	\begin{picture}(0,0)(0,0)%
		\put(-28.5,-72){%
			\begin{tikzpicture}%
			\path[fill=lawn.bg](0,0) rectangle (5,5);%
			\path[fill=library slide.bg](5,0) rectangle (16,5);%
			\end{tikzpicture}%
		}%
		\put(0,0){\raisebox{-.5\height}{\includegraphics[height=4cm]{\beamer@theme@ciad@libraryslide@picture}}}%
		\put(120,0){%
			\begin{minipage}[c]{.65\linewidth}%
				\usebeamerfont{library slide}\usebeamercolor[fg]{library slide}%
				\begin{raggedright}%
					\nohyphens{\textbf{\beamer@theme@ciad@libraryslide@title}}%
					\ifthenelse{\equal{a\beamer@theme@ciad@libraryslide@subtitle}{a}}{}{%
						\\ \nohyphens{\small\beamer@theme@ciad@libraryslide@subtitle}%
					} \\[.5cm]%
					\nohyphens{\beamer@theme@ciad@libraryslide@authors} \\[.5cm]%
					\nohyphens{\beamer@theme@ciad@libraryslide@how} \\[.25cm]%
					\nohyphens{ISBN \beamer@theme@ciad@libraryslide@isbn}%
				\end{raggedright}%
			\end{minipage}%
		}
	\end{picture}%
}

\mode
<all>

\endinput
