% \iffalse
%<*color>
% \fi\file{theme/mu/beamercolorthemefibeamer-mu.sty}
% This is the base color theme for presentations written at the
% Masaryk University in Brno.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fibeamer/theme/mu/%
  beamercolorthemefibeamer-mu}[2015/08/26]
%    \end{macrocode}
% \begin{macro}{\darkframes}
% The |darkframes| environment switches the color definitions to
% render the enclosed frames in dark colors. This is a dummy
% definition, which will be overridden by the subsequently loaded
% color theme in the presentation mode.
%    \begin{macrocode}
\newenvironment{darkframes}{}{}
%    \end{macrocode}
% \end{macro}
% The rest of the theme will be ignored outside the presentation
% mode.
%    \begin{macrocode}
\mode<presentation>
%    \end{macrocode}
% The theme loads the following packages, which will be used by the
% subsequently loaded color theme specific to a faculty:
% \begin{itemize}
%   \item\textsf{listings} -- This package is used for code
%     listings. The subsequently loaded color theme will specify
%     source code coloring for the package.
%   \item\textsf{ifthen} -- This package is used to construct
%     compound conditionals.
%   \item\textsf{tikz} -- This package is used to create gradient
%     background for dark slides.
% \end{itemize}
%    \begin{macrocode}
  \RequirePackage{listings}
  \RequirePackage{ifthen}
  \RequirePackage{tikz}
%    \end{macrocode}
% \begin{macro}{\iffibeamer@dark}
% The |\iffibeamer@dark| conditional will be switched on and off by
% the subsequently loaded color theme based on whether or not the
% given frame is being typeset in light or dark colors. This
% information will be used by outer themes to insert the correct
% logo into each frame.
%    \begin{macrocode}
  \newif\iffibeamer@dark\fibeamer@darkfalse
%    \end{macrocode}
% \end{macro}
% A frame that is either title or dark, as specified by the value
% of the |\iffibeamer@dark| conditional, will have a gradient
% background. The |fibeamer@backgroundInner| and
% |fibeamer@backgroundOuter| colors will be defined by the
% subsequently loaded color theme.
%    \begin{macrocode}
\defbeamertemplate*{background canvas}{fibeamer}{%
  \ifthenelse{%
    \boolean{fibeamer@dark} \OR \c@framenumber=0
  }{%
    \begin{tikzpicture}
      \clip (0,\fibeamer@clipbottom) rectangle
        (\paperwidth,\fibeamer@cliptop);
      \path [inner color = fibeamer@backgroundInner,
             outer color = fibeamer@backgroundOuter]
        (0,0) rectangle (\paperwidth,\paperwidth);
    \end{tikzpicture}
  }{}}
\mode
<all>
%    \end{macrocode}
% \iffalse
%</color>
%<*font>
% \fi\file{theme/mu/beamerfontthemefibeamer-mu.sty}
% This is the base font theme for presentations written at the
% Masaryk University in Brno. The theme has no effect outside the
% presentation mode.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fibeamer/theme/mu/%
  beamerfontthemefibeamer-mu}[2015/08/26]
\mode<presentation>
  \setbeamerfont{normal text}{size=\normalsize}
  \setbeamerfont{title}{size=\LARGE, series=\bfseries}
  \setbeamerfont{subtitle}{parent=normal text, size=\Large}
  \setbeamerfont{frametitle}{size=\Large}
  \setbeamerfont{framesubtitle}{size=\large, shape=\itshape}
  \setbeamerfont{description item}{series=\bfseries}
  \setbeamerfont{author}{size=\large}
\mode
<all>
%    \end{macrocode}
% \iffalse
%</font>
%<*inner>
% \fi\file{theme/mu/beamerinnerthemefibeamer-mu.sty}
% This is the base inner theme for presentations written at the
% Masaryk University in Brno. The theme has no effect outside the
% presentation mode.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fibeamer/theme/mu/%
  beamerinnerthemefibeamer-mu}[2015/08/26]
\defbeamertemplate*{itemize item}{fibeamer}{$\bullet$}
\defbeamertemplate*{itemize subitem}{fibeamer}{\---}
\defbeamertemplate*{itemize subsubitem}{fibeamer}{\guillemotright}
\setbeamertemplate{bibliography item}{\insertbiblabel}
%    \end{macrocode}
% \iffalse
%</inner>
%<*outer>
% \fi\file{theme/mu/beamerouterthemefibeamer-mu.sty}
% This is the base outer theme for presentations written at the
% Masaryk University in Brno. The theme has no effect outside the
% presentation mode.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fibeamer/theme/mu/%
  beamerouterthemefibeamer-mu}[2015/08/26]
\mode<presentation>
%    \end{macrocode}
% The theme uses the following packages:
% \begin{itemize}
%   \item\textsf{ifthen} -- This package is used to construct
%     compound conditionals.
%   \item\textsf{ifpdf} -- This package is used to check, whether
%     the document is being typeset in DVI mode. If it is, then
%     the |\pdfpagewidth| and |\pdfpageheight| dimensions are
%     defined, so that positioning in TikZ works correctly.
%     \changes{v1.0.1}{2015/10/02}{Added DVI output support. [VN]}
%     ^^A <http://tex.stackexchange.com/a/246631/70941>
%   \item\textsf{tikz} -- This package is used to position the
%     logo and the frame number on a frame.
%   \item\textsf{pgfcore} -- This package is used to draw the
%     dashed line at the title frame.
% \end{itemize}
%    \begin{macrocode}
  \RequirePackage{ifthen}
  \RequirePackage{ifpdf}
  \ifpdf\else
    \@ifundefined{pdfpagewidth}{\newdimen\pdfpagewidth}{}
    \@ifundefined{pdfpageheight}{\newdimen\pdfpageheight}{}
    \pdfpagewidth=\paperwidth
    \pdfpageheight=\paperheight
  \fi
  \RequirePackage{tikz}
  \RequirePackage{pgfcore}
%    \end{macrocode}
% This part of the outer theme defines the geometry of the frames
% along with other dimensions.
%    \begin{macrocode}
% The logo dimensions
  \newlength{\fibeamer@logowidth}
  \setlength{\fibeamer@logowidth}{15mm}
  \newlength{\fibeamer@logoheight}
  \setlength{\fibeamer@logoheight}{1.32\fibeamer@logowidth}
  % The logo padding
  \newlength{\fibeamer@logopad}
  \setlength{\fibeamer@logopad}{0.25\fibeamer@logowidth}
  % The footer padding
  \newlength{\fibeamer@footerpad}
  \setlength{\fibeamer@footerpad}{\fibeamer@logopad}
  % The side margins
  \newlength{\fibeamer@margin}
  \setlength{\fibeamer@margin}{\fibeamer@logopad}
  \addtolength\fibeamer@margin{0.5\fibeamer@logowidth}
  \setbeamersize{
    text margin left=\fibeamer@margin,
    text margin right=\fibeamer@margin}
  % The upper margin
  \newlength{\fibeamer@titleline}
  \setlength{\fibeamer@titleline}{0.5\fibeamer@logoheight}
  \usebeamerfont{frametitle}%
  \addtolength\fibeamer@titleline{-1em}
  % The background clipping
  \newlength{\fibeamer@clipbottom}
  \setlength{\fibeamer@clipbottom}{\paperwidth}
  \addtolength\fibeamer@clipbottom{-\paperheight}
  \setlength{\fibeamer@clipbottom}{0.5\fibeamer@clipbottom}
  \newlength{\fibeamer@cliptop}
  \setlength{\fibeamer@cliptop}{\paperwidth}
  \addtolength\fibeamer@cliptop{-\fibeamer@clipbottom}
%    \end{macrocode}
% The outer theme completely culls the bottom navigation.
%    \begin{macrocode}
  \defbeamertemplate*{navigation symbols}{fibeamer}{}
%    \end{macrocode}
% The outer theme also culls the headline and replaces it with
% either a dark or light version of the faculty logo, based on the
% value of the |\iffibeamer@dark| conditional, which is controlled by
% the color theme.
%    \begin{macrocode}
  \defbeamertemplate*{headline}{fibeamer}{%
    \begin{tikzpicture}[overlay,remember picture]
      \node[anchor=north east,xshift=-\fibeamer@logopad]
      at (current page.north east) {
        \ifthenelse{\boolean{fibeamer@dark}\OR\c@framenumber=0}{
          \includegraphics[width=\fibeamer@logowidth]%
            {\fibeamer@logo-dark}
        }{
          \includegraphics[width=\fibeamer@logowidth]%
            {\fibeamer@logo-light}
        }
      };
    \end{tikzpicture}}
%    \end{macrocode}
% The frame title is positioned on the axis of the faculty logo.
%    \begin{macrocode}
  \defbeamertemplate*{frametitle}{fibeamer}{%
    \vskip\fibeamer@titleline
    \usebeamercolor[fg]{frametitle}%
    \usebeamerfont{frametitle}%
      \insertframetitle\par%
    \usebeamercolor[fg]{framesubtitle}%
    \usebeamerfont{framesubtitle}%
      \insertframesubtitle}
%    \end{macrocode}
% The footline contains the frame number. It is flushed right and
% aligned with the faculty logo.
%    \begin{macrocode}
  \defbeamertemplate*{footline}{fibeamer}{%
    \ifnum\c@framenumber=0\else%
      \begin{tikzpicture}[overlay]
        \node[anchor=south east,yshift=\fibeamer@footerpad,
          xshift=-\fibeamer@footerpad] at (current page.south east) {
          \usebeamercolor[fg]{framenumber}%
          \usebeamerfont{framenumber}%
          \insertframenumber/\inserttotalframenumber
        };
      \end{tikzpicture}
    \fi}
%    \end{macrocode}
% The title frame contains the |\title| vertically positioned to
% the upper $\phi^{-1}$ of the page, where $\phi$ refers to the
% golden ratio, and underlined with a dashed line. At the bottom
% of the page, there is the |\subtitle| followed by the |\author|.
%    \begin{macrocode}
  \defbeamertemplate*{title page}{fibeamer}{%
    % This is slide 0
    \setcounter{framenumber}{0}

    % Input the title
    \usebeamerfont{title}%
    \usebeamercolor[fg]{title}%
    \begin{minipage}[b][2\baselineskip][b]{\textwidth}%
      \raggedright%
      \inserttitle%
    \end{minipage}
    \vskip-.5\baselineskip

    % Input the dashed line
    \begin{pgfpicture}
      \pgfsetlinewidth{2pt}
      \pgfsetroundcap
      \pgfsetdash{{0pt}{4pt}}{0cm}

      \pgfpathmoveto{\pgfpoint{0mm}{0mm}}
      \pgfpathlineto{\pgfpoint{\textwidth}{0mm}}

      \pgfusepath{stroke}
    \end{pgfpicture}
    \vfill
    
    % Input the subtitle
    \usebeamerfont{subtitle}%
    \begin{minipage}{\textwidth}
      \raggedright%
      \insertsubtitle%
    \end{minipage}\vskip.25\baselineskip

    % Input the author's name
    \usebeamerfont{author}%
    \begin{minipage}{\textwidth}
      \raggedright%
      \insertauthor%
    \end{minipage}}

\mode
<all>
%    \end{macrocode}
% \iffalse
%</outer>
% \fi
