%% beamerthemegc3.sty
%%
%% Beamer theme for GC3.UZH.
%% Based on Beamer theme "uzhneu" by Corporate Design templates for
%% the University of Zurich, October 2010)
%%
%% Original copyright 2010 by Juergen Spitzmueller <spitzmueller@ds.uzh.ch>
%% Modification copyright 2012 Riccardo Murri <riccardo.murri@uzh.ch>
%%
%% This template can be redistributed and/or modified under the terms
%% of the GNU Public License, version 2 or later.

%% Theme options:
%% - formal: Logo and header on the front page
%% - informal: No logo or Uni header on the front page
\newif\if@uzhinformal
\@uzhinformalfalse
%% - deutsch: Use german version of the logo etc.
\newif\if@uzhdeutsch
\@uzhdeutschfalse

%% Beamer pass-through options
\DeclareOptionBeamer{compress}{\beamer@compresstrue}
\DeclareOptionBeamer{deutsch}{\@uzhdeutschtrue}
\DeclareOptionBeamer{german}{\@uzhdeutschtrue}
\ProcessOptionsBeamer

%% Theme options
\DeclareOption{deutsch}{\@uzhdeutschtrue}
\DeclareOption{german}{\@uzhdeutschtrue}
\DeclareOption{informal}{\@uzhinformaltrue}
\DeclareOption{formal}{\@uzhinformalfalse}
\ProcessOptions

\mode<presentation>

%% PERSONAL DATA (ADJUST TO YOUR NEEDS) %%%%%%%%%%%%%%%%
%
% Define your unit (e.g. Institute)
\providecommand\uzhunit{GC3: Grid Computing Competence Center}
% If your institute has a key visual ("Kernsujet"),
% uncomment the following and adjust the file name
% (key-visual), if necessary:
%\pgfdeclareimage[height=1.56cm]{kernsujet}{key-visual}
%
%% END OF PERSONAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% Variables (Logo, Uni name, etc.)
\if@uzhdeutsch%
  \pgfdeclareimage[height=.9cm]{uzhlogo}{uzh_logo_d_pos}
  \def\uzh{Universit\"at Z\"urich}
  \def\framepagination{Seite \insertframenumber}
\else%
  \pgfdeclareimage[height=.9cm]{uzhlogo}{uzh_logo_e_pos}
  \def\uzh{University of Zurich}
  \def\framepagination{Page \insertframenumber}
\fi%


%% Common settings (used both in the "formal" and "informal" styles)

% adjust margins
\setbeamersize{text margin left=1.25cm}
\setbeamersize{text margin right=1.25cm}

% fonts
\usefonttheme{default}
\RequirePackage{bookman}% use freely-available Bookman for anything, not just headings
\RequirePackage{eulervm}% math font that blends better with Bookman
\setbeamerfont{title}{size={\fontsize{20}{24pt}\selectfont},parent=structure,series=\bfseries}
\setbeamerfont{subtitle}{size={\fontsize{9}{11pt}\selectfont},series=\mdseries}
\setbeamerfont{author}{size={\fontsize{9}{11pt}\selectfont},series=\mdseries}
\setbeamerfont{footline}{size={\fontsize{5}{7pt}\selectfont}}% originally also: shape=\itshape
\setbeamercolor{footline}{fg=black}
\setbeamerfont{frametitle}{parent=structure,size={\fontsize{12}{14pt}\selectfont},series=\bfseries}
\setbeamerfont{framesubtitle}{parent=frametitle,size=\footnotesize}
\setbeamerfont{uzhunit}{size={\fontsize{7}{9pt}\selectfont},series=\bfseries,family=\sffamily}

% colors
\usecolortheme{default}
\definecolor{uzh@blue}{RGB}{0,40,165}
\definecolor{uzh@grey}{RGB}{163,173,183}
\definecolor{uzh@orange}{RGB}{220,96,39}
\setbeamercolor{structure}{fg=uzh@blue}
\setbeamercolor{titlelike}{fg=black}
\setbeamercolor{title}{fg=uzh@blue}
\setbeamercolor{frametitlelike}{fg=uzh@blue}
\setbeamercolor{frametitle}{parent=frametitlelike}
\setbeamercolor{framesubtitle}{parent=frametitle}
\setbeamercolor{mini frame}{parent=structure}
\setbeamercolor{sepline}{fg=uzh@grey,bg=uzh@grey}
\setbeamercolor{partpage}{fg=white,bg=uzh@grey}
\setbeamercolor{itemize item}{fg=black}
\setbeamercolor{enumerate item}{fg=black}
\RequirePackage{url}
\def\UrlFont{\sffamily\color{uzh@orange}}

% Inner Theme
\useinnertheme{default}

% Layout/placement
\useoutertheme{default}

% date
\newcommand{\leadingzero}[1]{\ifnum #1<10 0\the#1\else\the#1\fi}
\AtBeginDocument{%
  \@ifundefined{addto}{}{%
    \addto\captionsngerman{\def\datengerman{\def\today{\leadingzero{\day}.\leadingzero{\month}.\the\year}}}%
    \addto\captionsenglish{\def\dateenglish{\def\today{\leadingzero{\day}/\leadingzero{\month}/\the\year}}}%
  }
}

% Placement of frame titles
\defbeamertemplate*{frametitle}{uzh}[1][left]
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \vskip .7em
  \begin{beamercolorbox}[#1,wd=\the\@tempdima, leftskip=1.25cm]{}
   \begin{minipage}{\textwidth}
    \raggedright
    \usebeamerfont{frametitle}%
    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
    \strut\insertframetitle\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
  \end{minipage}
  \end{beamercolorbox}%
}

% Part page
\defbeamertemplate*{part page}{uzh}[1][left]
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \newlength\frameheightmhead
  \setlength\frameheightmhead{\textheight}
  \addtolength\frameheightmhead{1.55em}
  \newlength\frameheightohead
  \setlength\frameheightohead{\textheight}
  \addtolength\frameheightohead{-.7em}
  %
  \vspace*{-.13em}
  \begin{beamercolorbox}[wd=\the\@tempdima, ht=\frameheightmhead, leftskip=1.25cm]{partpage}
    \usebeamerfont{frametitle}%
    \vskip .7em
    \insertpart\\%
    \vspace*{\frameheightohead}
   \end{beamercolorbox}%
}

\defbeamertemplate{footline}{part page}{}

% no navigation symbols
\setbeamertemplate{navigation symbols}{}

% pagination (excluding appendices)
\def\insertpresentationframenumber{\inserttotalframenumber}

\let\oldappendix\appendix
\renewcommand*\appendix{%
\if@filesw
    \immediate\write\@auxout{\string\@writefile{nav}%
       {\noexpand\headcommand{\noexpand\def\noexpand\insertpresentationframenumber{\the\c@framenumber}}}}
\fi
\renewcommand\framepagination{\appendixname\ (\insertframenumber )}
\oldappendix}

% Misc.
\setbeamercovered{transparent}
\setbeamertemplate{sections in toc}[sections numbered]

% Itemize items
\defbeamertemplate*{itemize item}{uzh}{\hbox{--}}
\defbeamertemplate*{itemize subitem}{uzh}{\hbox{--}}
\defbeamertemplate*{itemize subsubitem}{uzh}{\hbox{--}}

% Bibliography
\setbeamertemplate{bibliography item}[triangle]
\renewcommand{\@cite}[2]{\textcolor{structure}{#1\if@tempswa :\,#2\fi}}
\setbeamertemplate{bibliography entry title}{ }
\setbeamertemplate{bibliography entry location}{ }
\setbeamertemplate{bibliography entry note}{ }
\setbeamercolor{bibliography entry author}{use=structure,fg=structure.fg}
\setbeamercolor{bibliography entry title}{use=normal text,fg=normal text.fg}
\setbeamercolor{bibliography entry location}{use=normal text,fg=normal text.fg}
\setbeamercolor{bibliography entry note}{use=normal text,fg=normal text.fg}

% Notes
\defbeamertemplate*{note page}{uzh}
{%
  {%
    \scriptsize
%    \insertvrule{.25\paperheight}{white!90!black}
%    \vskip-.25\paperheight
    \nointerlineskip
    \vbox{
      \hfill\insertslideintonotes{0.7}\hskip-\Gm@rmargin\hskip0pt%
%      \vskip-0.25\paperheight%
      \vfil}%
  }%
  \vskip.25em
  \nointerlineskip
  \insertnote
}

%% "formal" UZH look

% Title page
\defbeamertemplate*{title page}{uzh}[1][]
{
  \vskip.4em
    \begin{beamercolorbox}[sep=0pt,left,#1]{title}
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.5em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{titlelike}\insertsubtitle\par}%
      \fi%
    \end{beamercolorbox}%
    \vskip0.5em%
    \begin{beamercolorbox}[sep=0pt,left,#1]{author}
      \usebeamerfont{author}\insertauthor\par%
      \ifx\insertinstitute\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{institute}\insertinstitute\par}%
      \fi%
    \end{beamercolorbox}
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \vfill
}

% headline
\defbeamertemplate*{headline}{uzh}
{%
      \begin{beamercolorbox}[sep=0.25cm]{}
        \pgfuseimage{uzhlogo}\par
        \vspace*{1.6mm}\hspace*{10mm}\usebeamerfont{uzhunit}\uzhunit
      \end{beamercolorbox}
      \vspace*{-1.8mm}
      \begin{beamercolorbox}[wd=\textwidth,ht=.2mm]{sepline}
      \end{beamercolorbox}
      %% Test if a key visual is defined and insert it, if so.
      {\def\pgf@imagename{pgf@image@kernsujet}%
       \pgf@tryextensions{\pgf@imagename}{\pgfalternateextension}%
       \expandafter\pgfutil@ifundefined\expandafter{\pgf@imagename}%
       {}%
       {
        \begin{pgfpicture}
        \put(186.5,0.75){\pgfuseimage{kernsujet}}
        \end{pgfpicture}
       }%
      }%
}

% footline
\defbeamertemplate*{footline}{uzh}
{\hspace{\beamer@leftmargin}%
        \usebeamerfont{footline}%
        \insertshorttitle
        \hfill
        \ifx\uzhunit\@empty%
        \uzh
        \else%
        \uzh, \uzhunit
        \fi%
        \hfill
        \ifx\beamer@shortdate\@empty%
        \else
        \insertshortdate%
        \fi
        %\framepagination%
        \hspace*{\beamer@rightmargin}
        \vskip2ex
}

% footline
\defbeamertemplate*{footline}{title page}
{\hspace{\beamer@leftmargin}%
        \usebeamerfont{footline}%
        \ifx\beamer@shortdate\@empty%
        \else
        \insertshortdate%
        \fi
        \hfill
        %\framepagination%
        \hspace*{\beamer@rightmargin}
        \vskip2ex
}

%% "informal" look

% headline
\defbeamertemplate{headline}{title page}
{%
      \begin{beamercolorbox}[sep=0.25cm]{}
        \pgfuseimage{uzhlogo}\par
        \vspace*{1.6mm}\hspace*{10mm}\usebeamerfont{uzhunit}\uzhunit
      \end{beamercolorbox}
      \vspace*{-1.8mm}
      \begin{beamercolorbox}[wd=\textwidth,ht=.2mm]{sepline}
      \end{beamercolorbox}
      %% Test if a key visual is defined and insert it, if so.
      {\def\pgf@imagename{pgf@image@kernsujet}%
       \pgf@tryextensions{\pgf@imagename}{\pgfalternateextension}%
       \expandafter\pgfutil@ifundefined\expandafter{\pgf@imagename}%
       {}%
       {
        \begin{pgfpicture}
        \put(186.5,0.75){\pgfuseimage{kernsujet}}
        \end{pgfpicture}
       }%
      }%
}

% footline
\defbeamertemplate*{footline}{informal}
{\hspace{\beamer@leftmargin}%
        \usebeamerfont{footline}%
        \hspace{1em}%
        \ifx\uzhunit\@empty%
        \uzh
        \else%
        \uzh, \uzhunit
        \fi%
        \hfill
        \insertshorttitle
        \hfill
        \ifx\beamer@shortdate\@empty%
        \else%
        \hspace{1em}\insertshortdate%
        \fi
        %\framepagination%
        \hspace*{\beamer@rightmargin}
        \vskip2ex
}

\setbeamertemplate{headline}{}

% Title page
\defbeamertemplate*{title page}{informal}[1][]
{
  \vskip4.6em
    \begin{beamercolorbox}[sep=0pt,left,#1]{title}
      \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.5em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{titlelike}\insertsubtitle\par}%
      \fi%
    \end{beamercolorbox}%
    \vskip.7em\par
    \begin{beamercolorbox}[sep=0pt,left,#1]{author}
      \usebeamerfont{author}\insertauthor\par%
      \ifx\insertinstitute\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{institute}\insertinstitute\par}%
      \fi%
    \end{beamercolorbox}
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \vfill
}

% Part page
\defbeamertemplate*{part page}{informal}[1][left]
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \newlength\frameheightmhead
  \setlength\frameheightmhead{\textheight}
  \addtolength\frameheightmhead{1.5em}
  \newlength\frameheightohead
  \setlength\frameheightohead{\textheight}
  \addtolength\frameheightohead{-.7em}
%
  \vspace*{-.11em}
  \begin{beamercolorbox}[wd=\the\@tempdima, ht=\paperheight, leftskip=1.25cm]{partpage}
    \usebeamerfont{frametitle}%
    \vskip .7em
    \insertpart\\%
    \vspace*{\frameheightohead}
   \end{beamercolorbox}%
}


%% choose one of the two looks

\if@uzhinformal%
  \AtBeginPart{%
     \setbeamertemplate{footline}[part page]
     \frame{\partpage}
     \setbeamertemplate{footline}[informal]
  }
    \def\maketitle{%
    \ifbeamer@inframe
        \titlepage
    \else
         \setbeamertemplate{footline}[title page]
         \frame{\titlepage}
         \setbeamertemplate{footline}[uzh]
    \fi
  }
\else%
  \AtBeginPart{%
     \setbeamertemplate{footline}[part page]
     \frame{\partpage}
     \setbeamertemplate{footline}[uzh]
  }
  \def\maketitle{%
    \ifbeamer@inframe
        \titlepage
    \else
         \setbeamertemplate{headline}[title page]
         \setbeamertemplate{footline}[title page]
         \frame{\titlepage}
         \setbeamertemplate{headline}{}
         \setbeamertemplate{footline}[informal]
    \fi
  }
\fi

\mode
<all>
