[Tex/LaTex] Beamer: how to change the mini frames coloring

beamercolormini-framesnavigation

I want to do the following changes to the mini frames coloring:
All previous frames almost the same solid color as the background so that the squares are barely visible.
The current frame and all future frames the color of the foreground.

    \documentclass{beamer}
    \usetheme{Frankfurt}
    \usecolortheme{dove}
    \setbeamercolor{section in head/foot}{fg=white, bg=black}
\definecolor{dark-gray}{gray}{0.10} %color for the navigation squares


    \makeatletter
\setbeamertemplate{mini frame}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
\setbeamertemplate{mini frame in current subsection}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfsetfillcolor{dark-gray}
    \pgfusepath{fill}
  \end{pgfpicture}%
}

\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \advance\beamer@xpos by1\relax%
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 2pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section=#1%
            \ifnum\c@subsection<#2%
              \usebeamercolor[fg]{mini frame}%
              \ifnum\c@subsectionslide=#3%
                \usebeamertemplate{mini frame}%\beamer@minislidehilight%
              \else%
                \usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
              \fi%
            \else%
              \usebeamercolor{mini frame}%
              \color{fg!50!bg}%
              \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
            \fi%
          \else%
            \usebeamercolor{mini frame}%
            \color{fg!50!bg}%
            \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
          \fi%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }


\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor~~\beamer@ifempty{\insertshortinstitute}{}{(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

    \begin{document}

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    1
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    2
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    3
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    4
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    5
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    6
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    7
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    8
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    9
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    10
                \end{frame}                 

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    11
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    12
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    13
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    14
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    15
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    16
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    17
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    18
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    19
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    20
                \end{frame}

    \end{document}

This is an update to a question I posted earlier: Beamer: how to change the mini frames from circles to rectangles, but since it was answered and I suspect that the answer to the updated question is going to differ from the original question I posted this as a new question.

Best Answer

To color the mini frames of slides already shown gray and the current and all future frames white, the existing solution can be modified like this:

\documentclass{beamer}
\usetheme{Frankfurt}
\usecolortheme{dove}
\setbeamercolor{section in head/foot}{fg=white, bg=black}
\definecolor{dark-gray}{gray}{0.10} %color for the navigation squares

\makeatletter
\setbeamertemplate{mini frame}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}

\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \advance\beamer@xpos by1\relax%
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 2pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section>#1%
            \color{dark-gray}%
          \else%
            \ifnum\c@section=#1%
              \ifnum\c@subsection>#2%
                \color{dark-gray}%
              \else%
                \ifnum\c@subsection=#2%
                  \ifnum\c@subsectionslide>#3%
                    \color{dark-gray}%
                  \else%
                    \color{white}%
                  \fi%
                \else%
                  \color{white}%
                \fi%
              \fi%
            \else%
              \color{white}%
            \fi%
          \fi%
          \usebeamertemplate{mini frame}%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }

\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor~~\beamer@ifempty{\insertshortinstitute}{}{(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

\begin{document}

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    1
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    2
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    3
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    4
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    5
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    6
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    7
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    8
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    9
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    10
                \end{frame}                 

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    11
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    12
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    13
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    14
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    15
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    16
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    17
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    18
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    19
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    20
                \end{frame}

    \end{document}

headline of slide 7, with the previous frames colored gray and the current and future frames color white

Explanation

The decision whether a mini frame should be colored gray or white is made in ll. 39-59, where the section, subsection, and "frame in subsection" numbers of the currently processed mini frame are subsequently compared to the actual position in the presentation. This is necessary as the "absolute" frame number of the current mini frame isn't available.