% Style Beamer Hadoly - Adel Daouzli 2018
% entete navigation 3 elem - V0.1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%                        ENTÊTE                        %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% liste de navigation entête à 3 éléments (http://tex.stackexchange.com/a/96836)
\makeatletter
       \newcount\c@p
       \newcount\c@m
       \newcount\c@pp
       \newcount\c@mm
\def\insertsectionnavigation#1{%
  \hbox to #1{%
    \vbox{
     {\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
     \vskip0.5625ex%
     \def\slideentry##1##2##3##4##5##6{}%
     \def\sectionentry##1##2##3##4##5{%
       \ifnum##5=\c@part%
           \def\insertsectionhead{##2}%
           \def\insertsectionheadnumber{##1}%
           \def\insertpartheadnumber{##5}%
           \c@p=\c@section%
           \c@m=\c@section%
           \c@pp=\c@section%
           \c@mm=\c@section%
           \advance\c@m by -1 %
           \advance\c@p by 1 %
           \advance\c@mm by -2 %
           \advance\c@pp by 2 %
           %     
           \ifnum \c@section=1
               \ifnum\c@section=##1%
                   \setbox\beamer@tempbox=\hbox{%
                        \hyperlink{Navigation##3}{\hbox to #1{%
                            {\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm\hfil}
                            }}
                   }%
               \else%
                   \ifnum##1=\c@p%
                       \setbox\beamer@tempbox=\hbox{%
                             \hyperlink{Navigation##3}{%
                                 \hbox to #1{%
                                 {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}
                             }
                       }
                     %
                   \else%
                       \ifnum##1=\c@pp%
                           \setbox\beamer@tempbox=\hbox{%
                               \hyperlink{Navigation##3}{\hbox to #1{%
                               {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}}
                           }%
                   %
                       \else%
                   %
                       \fi%
                   \fi%
                   %
               \fi%%  
           \else%
               \ifnum \c@section=\beamer@sectionmax
                   \ifnum\c@section=##1%
                       \setbox\beamer@tempbox=\hbox{%
                           \hyperlink{Navigation##3}{\hbox to #1{%
                           {\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm\hfil}}}
                       }%
                   \else%
                       \ifnum##1=\c@m%
                           \setbox\beamer@tempbox=\hbox{%
                              \hyperlink{Navigation##3}{\hbox to #1{%
                              {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}}
                           }
                     %
                       \else%
                           \ifnum##1=\c@mm%
                               \setbox\beamer@tempbox=\hbox{%
                                   \hyperlink{Navigation##3}{\hbox to #1{%
                                   {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}}
                                }%
                   %
                           \else%
                   %
                           \fi%
                       \fi%
                   %
                   \fi%%
               \else%
                   \ifnum\c@section=##1%
                       \setbox\beamer@tempbox=\hbox{%
                           \hyperlink{Navigation##3}{\hbox to #1{%
                           {\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm\hfil}}}
                       }%
                   \else%
                       \ifnum##1=\c@m%
                           \setbox\beamer@tempbox=\hbox{%
                               \hyperlink{Navigation##3}{\hbox to #1{%
                               {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}}
                           }
                     %
                       \else%
                           \ifnum##1=\c@p%
                               \setbox\beamer@tempbox=\hbox{%
                                   \hyperlink{Navigation##3}{\hbox to #1{%
                                   {\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm\hfil}}}
                               }%
                   %
                           \else%
                   %
                           \fi%
                       \fi%
                   %
                   \fi%%
                %
               \fi
           \fi
                %

           \ht\beamer@tempbox=1.6875ex%
           \dp\beamer@tempbox=0.75ex%
           \box\beamer@tempbox
       \fi
     }%
     \dohead\vskip0.5625ex
     }
    }%vbox
    \hfil
  }
}

% Permet d'utiliser \insertframetitle dans le headline
\def\insertframetitle{}

%%%%%%%%%%%%%   Entête

\setbeamertemplate{headline}%
{%
    \ifnumequal{\c@framenumber}{1}{%
          % pas d'entête sur la première page
          % suppression de l'espace d'entête
          \vspace*{\headheight}
    }{%
          % entête pour toutes les autre pages
          \leavevmode%
          \@tempdimb=3em%
          \ifdim\@tempdimb>0pt%
            \advance\@tempdimb by 1.825ex%
%
            % bloc gauche avec les 3 titres de section
            \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
              \vbox to\@tempdimb{%
                \vfil%
                \insertsectionnavigation{.5\paperwidth}%
                \vfil%
              }
            \end{beamercolorbox}%
%
            % bloc droit avec le numéro de page
            \begin{beamercolorbox}[right,wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
              \vbox to\@tempdimb {%
                  \vfil
                  %\parbox[fg=white]{0.9\paperwidth}{%
                      \textcolor{white}{\insertframetitle\strut\hskip0.3cm\insertpagenumber\hskip0.3cm}
                  %}
                  \vfil
              }%
            \end{beamercolorbox}%
          \fi%
  }%
}

% Permet de ne pas afficher de titre dans le corps du slide. Titre qui en plus
% de prendre de la place inutilement - alors que présent dans l'entête -
% est invisible car affiché en blanc sur fond blanc !
\makeatletter
\setbeamertemplate{frametitle}{%
}
\makeatletter


\makeatother
