%\RequirePackage{translate}

\ifthenelse{\boolean{imta@mode@concurtaf}}{
  \matiere{Fondements théoriques du développement des logiciels concurrents}
  \code{Concurrence}
  \type{}
}{}

\setboolean{imta@boolean@withSection}{true}
%\setboolean{imta@boolean@withAuthors}{true}

% Choix de la pr\'esentation des exercices
\SetSimple

\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}

\setbeamertemplate{sections/subsections in toc}[ball]
\usetheme{IMTA}

\def\inserttitle{\imta@var@titre}%
\def\beamer@shorttitle{\imta@var@titrecourt}%
\def\insertsubtitle{\imta@var@soustitre}%
\def\beamer@shortsubtitle{\imta@var@soustitrecourt}%


% Limitation de l'indentation des listes imbriqu\'ees
\setlength\leftmargini{1em}\setlength\leftmarginii{1em}\setlength\leftmarginiii{1em}

\renewcommand{\insertdocumentref}{
  \ifx\imta@var@type\@empty%
    \ifx\imta@var@code\@empty%
      \ifx\imta@var@matiere\@empty%
      \else%
        \imta@var@matiere{} %
      \fi%
      \ifx\imta@var@numero\@empty%
      \else%
        \imta@var@numero{}%
      \fi%
    \else%
      \imta@var@code{} %
      \ifx\imta@var@numero\@empty%
      \else%
        -- \imta@var@numero{}%
      \fi%
    \fi%
  \else%
    \imta@var@type{} %
    \ifx\imta@var@code\@empty%
      \ifx\imta@var@matiere\@empty%
      \else%
        -- \imta@var@matiere{} %
      \fi%
    \else%
      -- \imta@var@code{} %
    \fi%
    \ifx\imta@var@numero\@empty%
    \else%
      -- \imta@var@numero{}%
    \fi%
  \fi%
}

\ifthenelse{\boolean{imta@boolean@handout}}{%
  \RequirePackage{pgfpages}
  \pgfpagesuselayout{4 on 1}[a4paper,landscape]
}{}

  \AtBeginSection[%
  \ifthenelse{\boolean{imta@boolean@withSection}}{%
    \ifx\insertpart\empty%
    \begin{frame}{\translate{Progress}}
      \vfill
      \hfill\Large\insertsection\hfill\hfill\hfill
      \vfill
    \end{frame}
    \else%
    \begin{frame}{\insertpart}
      \insertsection
    \end{frame}
    \fi%
  }{}%
]{
  \ifthenelse{\boolean{imta@boolean@withSection}}{%
    \ifx\insertpart\empty%
    \begin{frame}{\translate{Progress}}
      \tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide]
    \end{frame}
    \else%
    \begin{frame}{\insertpart}
      \tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide]
    \end{frame}
    \fi%
  }{}%
}
% Controls the use of authors on the title page
\newboolean{imta@boolean@withParts}
\setboolean{imta@boolean@withParts}{true}
\newcommand*{\withParts}{\setboolean{imta@boolean@withParts}{true}}
\newcommand*{\withoutParts}{\setboolean{imta@boolean@withParts}{false}}

\AtBeginPart{
  \ifthenelse{\boolean{imta@boolean@withParts}}{%
    \begin{frame}{Partie \insertromanpartnumber{} : \insertpart}
      \tableofcontents[subsectionstyle=hide]
    \end{frame}
  }{}%
}

% Une modif de beamer pour retirer l'espace si on hide
\def\beamer@sectionintoc#1#2#3#4#5{%
  \ifnum\c@tocdepth>0%
  \ifnum#4=\beamer@showpartnumber%
  {
    \beamer@saveanother%
    \gdef\beamer@todo{}%
    \beamer@slideinframe=#1\relax%
    \expandafter\only\beamer@tocsections{\gdef\beamer@todo{%
        \beamer@tempcount=#5\relax%
        \advance\beamer@tempcount by\beamer@sectionadjust%
        \edef\inserttocsectionnumber{\the\beamer@tempcount}%
        \def\inserttocsection{\hyperlink{Navigation#3}{#2}}%
        \beamer@tocifnothide{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}%
        {
          \ifbeamer@pausesections\pause\fi%
          % Modif Ici
          % \ifx\beamer@toc@ooss\beamer@hidetext
          % \vskip1.5em
          % \else
          \vfill
          % \fi
          {%
            \hbox{\vbox{%
                \def\beamer@breakhere{\\}%
                \beamer@tocact{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}{section in toc}}}%
            \par%
          }%
        }%
      }
    }%
    \beamer@restoreanother%
  }
  \beamer@todo%
  \fi\fi%
}
