%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%===styled by===%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%===ashish revar===%%%%%%%%%%%%%%%%%%
%%%%%%%%%%===ashishrevar@gmail.com===%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%===9909298846===%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This material is subject to the LaTeX Project Public License

\def\beamer@nirmabeamer@version{0.1}
\ProvidesPackage{beamerthemenirma}
\RequirePackage{beamerbasethemes}[2004/10/07] \RequirePackage{pgf}

% To have normal text etc in sans-serif, but equations in serif.
\usefonttheme[onlymath]{serif}

%-------------------------------------------------------------------------------
%                                                               detect PDF-LaTeX

\newif\ifpdf
\ifx\pdfoutput\undefined\pdffalse\else\pdftrue\fi


%-------------------------------------------------------------------------------
%                                                                    color stuff

%\definecolor{nirmablue}{cmyk} {1.0,0,0,0.58}  % WUR 'petrol' blue
%\definecolor{nirmagreen}{cmyk}{0.55,0,0.77,0} % WUR green

%                                               % RGB           CMYK                PMS
\definecolor{nirmablue}{rgb}{0,0.298,0.471}       %   0  76 120   1    0  0    0.58   3025
\definecolor{nirmagreen}{rgb}{0.502,0.729,0.392}  % 128 186 100   0.55 0  0.77 0      360
\definecolor{nirmaorange}{rgb}{0.918,0.698,0}     % 234 178   0

\def\normalcolorhack{
\usebeamercolor{normal text}
\color{fg}
\def\normalcolor{\color{normal text.fg}}
}

\def\setanysheetcolors{
\setbeamercolor*{local structure}{fg=nirmaorange}
\setbeamercolor*{title}{fg=nirmagreen}
\setbeamercolor*{subitem}{parent=item,fg=nirmagreen}

\setbeamercolor*{logobar}{fg=nirmablue} }

\def\setwhitesheetcolors{
\setbeamercolor*{normal text}{fg=nirmablue,bg=white}
\setbeamercolor*{alerted text}{fg=nirmagreen}
\setbeamercolor*{structure}{fg=nirmablue} \setanysheetcolors }

\def\setbluesheetcolors{
\setbeamercolor*{normal text}{fg=white,bg=nirmablue}
\setbeamercolor*{alerted text}{fg=nirmagreen}
\setbeamercolor*{structure}{fg=white} \setanysheetcolors }

% Enforce blue-on-white when making handouts.

\mode<handout>{\let\setbluesheetcolors=\setwhitesheetcolors}


%-------------------------------------------------------------------------------
%                                                               font definitions

\setbeamerfont{title}{size=\huge}
\setbeamerfont{subtitle}{size=\LARGE}
\setbeamerfont{author}{}
\setbeamerfont{institution}{size=\small}

% my own fonts
\setbeamerfont{logobar}{}

%-------------------------------------------------------------------------------
%                                                             basic layout stuff

\newlength\barheight\setlength\barheight{\paperheight}
\divide\barheight by 12

%-------------------------------------------------------------------------------
%                                                                     \underline

\newdimen\ul@depth

\def\underline#1{%
\par\noindent
\@tempdima=\textwidth
\advance\@tempdima by \beamer@leftmargin
\advance\@tempdima by \beamer@rightmargin
\setbox0=\hbox to \@tempdima{\hspace*{\beamer@leftmargin}#1\hfill}%
\hspace*{-\beamer@leftmargin}%
\global\ul@depth=\dp0%
\hbox to \@tempdima{\vbox{\box0\vskip-\ul@depth\hrule}}}%

%-------------------------------------------------------------------------------
%                                                                     picture bar

% user-command to change the picture bar used:
\def\picturebar#1{\def\@picturebar{#1}}
\def\@picturebar{nirma-picturebar}
\titlegraphic{\hspace*{-\Gm@lmargin}\includegraphics[width=\paperwidth]{\@picturebar}}

%-------------------------------------------------------------------------------
%                                                                     title page

\setbeamertemplate{title page}
{
% The main title is typeset on a thin rule, forming a box that that is 2 unit-bars high.
\vbox to 2\barheight{%
\vfill
{\usebeamerfont{title}\usebeamercolor[fg]{title}\underline{\inserttitle}}}
% The optional subtitle
\ifx\insertsubtitle\@empty\else%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}
\fi
\vskip0pt plus 1filll
% Author
{\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor}
% Institution
\vskip4pt
{\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute}
\vskip0pt plus 1filll
% WUR picture bar. Defined above.
\inserttitlegraphic
% Cancel the 4pt skip that beamer inserts above the footline.
\vspace*{-4pt}
}


%-------------------------------------------------------------------------------
%                                                                    frame title

\setbeamertemplate{frametitle}{%
  \vbox to \barheight{\vfill\underline{\insertframetitle}}}

%-------------------------------------------------------------------------------
%                                                                       logo bar

\newlength\logobarheight\setlength\logobarheight{\barheight}
\newlength\logosep\setlength\logosep{0.5\logobarheight}

\pgfdeclareimage[height=\logobarheight]{NU-logo}{nu}%Main logo of Nirma
\pgfdeclareimage[height=0.6\logobarheight]{NWO-logo}{nwo}%Second level logo
\pgfdeclareimage[height=\logobarheight]{Alterra-logo}{alterra}%Third level logo

% these are availabe to users for constructing their logo
\def\nulogo{\pgfuseimage{NU-logo}}
\def\alterralogo{\pgfuseimage{Alterra-logo}}
\def\nwologo{\hbox{\vbox to \logobarheight{\vfill\hbox{\pgfuseimage{NWO-logo}}\vfill}}}

% Initially, have an empty logo bar
\let\logobarlogo=\relax

% routine to add a logo
\def\addlogo#1{%
  \ifx\logobarlogo\relax
    \def\logobarlogo{#1}
  \else
    \g@addto@macro{\logobarlogo}{\hspace{\logosep}}
    \g@addto@macro{\logobarlogo}{#1}
  \fi
  }

% routine to reset the logo bar (i.e. for using the Alterra logo instead
\def\resetlogo{\let\logobarlogo=\relax}

\def\logobartext#1{\gdef\@logobartext{#1}}
\def\@logobartext{}

\def\buildlogobar{%
  \noindent\hbox to \paperwidth{%
    \hspace*{\logosep}
    \logobarlogo
    \ifx\logobarlogo\relax\else\hspace{\logosep}\fi
    \hfill
    \hbox{\vbox to \logobarheight{\vfill\hbox{{\usebeamerfont{logobar}\usebeamercolor[fg]{logobar}\@logobartext}}\vfill}}%
    \hspace*{\logosep}}}


\def\whitesheetfootline{
  \begin{pgfpicture}{0cm}{0cm}{\the\paperwidth}{\the\logobarheight}
    % Draw a blue line to mark the logo bar
    \pgfsetstrokecolor{nirmablue}
    \pgfpathmoveto{\pgfpoint{0pt}{\the\logobarheight}}
    \pgfpathlineto{\pgfpoint{\the\paperwidth}{\the\logobarheight}}
    \pgfusepath{stroke}
    % Make a TeX box containing the actual logo bar contents, and place it at the lower-left
    \pgftext[left,bottom]{\buildlogobar}
   \end{pgfpicture}
}

\def\bluesheetfootline{
  \begin{pgfpicture}{0cm}{0cm}{\the\paperwidth}{\the\logobarheight}
    % Draw a white rectangle to mark the logo bar
    \pgfsetfillcolor{white}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\paperwidth}{\the\logobarheight}}
    \pgfusepath{fill}
    % Make a TeX box containing the actual logo bar contents, and place it at the lower-left
    \pgftext[left,bottom]{\buildlogobar}
  \end{pgfpicture}
}

%-------------------------------------------------------------------------------
%                                                           blue vs white sheets

\def\bluesheets{
%\setbeamertemplate{background}{\bluesheetbackground}
\setbeamertemplate{footline}{\bluesheetfootline}
\setbluesheetcolors
\normalcolorhack
\gdef\debug{[bluesheets set]]}
}

\def\whitesheets{
%\setbeamertemplate{background}{\whitesheetbackground}
\setbeamertemplate{footline}{\whitesheetfootline}
\setwhitesheetcolors
\normalcolorhack
}

%-------------------------------------------------------------------------------
%                                                                          setup

\bluesheets

% Disable the navigation buttons
\setbeamertemplate{navigation symbols}{}

% Use the Wageningen University logo by default
\addlogo{\nulogo}

\endinput
