% beamerthemeMyTheme.sty
\ProvidesPackage{beamerthemeRootCommit}
\usetheme{Madrid} % Base theme

% Minted for syntax highlighting
\usepackage{minted}

% Support emojis
\usepackage{emoji}

% Support FontAwesome
\usepackage{fontawesome}

% Support videos
\usepackage{multimedia}

% Custom commands
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\yoctovar}[1]{\href{https://docs.yoctoproject.org/ref-manual/variables.html\#term-#1}{\texttt{#1}}}
\newcommand{\yoctoclass}[1]{\href{https://docs.yoctoproject.org/ref-manual/classes.html\##1}{\texttt{#1}}}
\newcommand{\oepath}[1]{\href{https://git.openembedded.org/openembedded-core/tree/#1}{\texttt{#1}}}
\newcommand{\oepathtitle}[1]{\texttt{#1} \hfill \href{https://git.openembedded.org/openembedded-core/tree/#1}{\emoji{link}}}
\newcommand{\yoctopath}[2]{\href{#1#2}{\texttt{#2}}}
\newcommand{\yoctopathtitle}[2]{\texttt{#2} \hfill \href{#1#2}{\emoji{link}}}
\newcommand{\urltitle}[1]{\texttt{#1} \hfill \href{#1}{\emoji{link}}}
\newcommand\kdoc[1]{\href{https://www.kernel.org/doc/html/latest/#1.html}{\texttt{#1}}}
\newcommand\kconfig[1]{\href{https://elixir.bootlin.com/linux/latest/K/ident/#1}{\texttt{#1}}}
\newcommand\kconfigval[2]{\href{https://elixir.bootlin.com/linux/latest/K/ident/#1}{\texttt{#1=#2}}}

% Info and warning boxes

\newcommand{\infoBox}[1]{%
  \noindent
  \begin{minipage}[t]{0.08\linewidth}
    \centering
    {\Large \emoji{pencil}}
  \end{minipage}%
  \begin{minipage}[t]{0.9\linewidth}
    \footnotesize #1
  \end{minipage}%
}

\newcommand{\quizBox}[3]{%
\begin{center}
  \Huge \emoji{question}\\
  \vspace{0.5cm}
  \small
  #1 \\
  \vspace{0.5cm}
  #2 \\
  \pause
  \vspace{0.5cm}
  Answer: \\
  \rotatebox{180}{#3}
\end{center}
}

% Define custom colors
\setbeamercolor{title}{bg=gray!50!black, fg=white}
\setbeamercolor{frametitle}{fg=white, bg=gray!50!black}
\setbeamercolor{structure}{fg=gray!70!black}

% Color for hyperlinks
\definecolor{linkcolor}{RGB}{30,60,150}
\hypersetup{
  colorlinks=true,
  allcolors=.,
  urlcolor=linkcolor,
}

% Footnotes
\setbeamerfont{footnote}{size=\tiny}
\setbeamercolor{footnote}{fg=gray}

% Define custom fonts
\setbeamerfont{title}{family=\sffamily, size=\Large, series=\bfseries}
\setbeamerfont{frametitle}{family=\sffamily, size=\Large, series=\bfseries}

% Very tiny fonts
\newcommand{\almosttiny}{\fontsize{6pt}{7pt}\selectfont}
\newcommand{\tinier}{\fontsize{5pt}{6pt}\selectfont}
\newcommand{\muchtinier}{\fontsize{4.5pt}{5.5pt}\selectfont}
\newcommand{\verytiny}{\fontsize{4pt}{5pt}\selectfont}

% Misc settings
\usepackage{caption}
\captionsetup{labelformat=empty} % Remove "Figure" from all captions

% Modify the footline
\setbeamertemplate{footline}{%
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=.25\paperwidth, ht=2.5ex, dp=1ex, center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.65\paperwidth, ht=2.5ex, dp=1ex, center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}}%
        \begin{beamercolorbox}[wd=.10\paperwidth, ht=2.5ex, dp=1ex, center]{page number in head/foot}%
            \usebeamerfont{page number in head/foot}\insertframenumber / \inserttotalframenumber
        \end{beamercolorbox}%
    \vskip0pt%
}

\setbeamertemplate{frametitle}
{%
  \nointerlineskip%
  \vskip1ex%
  \begin{beamercolorbox}[wd=\paperwidth,dp=1ex,ht=2.5ex]{frametitle}%
    \hspace*{1em}
    \insertframetitle%
    \hfill
    \raisebox{-0.25\height}{\includegraphics[height=0.7cm]{svg/rootcommit-white.pdf}}
    \hspace*{1em}
  \end{beamercolorbox}%
}

% Need to show sections
\AtBeginSection[]
{
  \begin{frame}{\small \inserttitle}
    \huge
    \begin{center}
      \insertsection
    \end{center}
  \end{frame}
}

% Need to show subsections
\AtBeginSubsection[]
{
  \begin{frame}{\small \inserttitle}
    \begin{center}
      \huge
      \insertsection
    \end{center}
    \begin{center}
      \Large
      \insertsubsection
    \end{center}
  \end{frame}
}

