% \iffalse meta-comment
%
% File: ltx-talk-title.dtx Copyright (C) 2025,2026 Joseph Wright
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "ltx-talk bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% The released version of this bundle is available from CTAN.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/josephwright/xbeameltx-talkr
%
% for those people who are interested.
%
% -----------------------------------------------------------------------
%
%<*driver>
\documentclass{l3doc}
% Additional commands needed in this source
\NewDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% ^^A As we are dealing with a class, this has to be done manually
% \def\filedate{2026-01-16}
% \def\fileversion{v0.3.11}
%
% \title{^^A
%   \pkg{ltx-talk-title} -- Title pages^^A
%   \thanks{This file describes \fileversion,
%     last revised \filedate.}^^A
% }
%
% \author{^^A
%  Joseph Wright^^A
%  \thanks{^^A
%    E-mail: \email{joseph@texdev.net}^^A
%   }^^A
% }
%
% \date{Released \filedate}
%
% \maketitle
%
% \begin{documentation}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{ltx-talk-title} implementation}
%
% Start the \pkg{DocStrip} guards.
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%
% Identify the internal prefix.
%    \begin{macrocode}
%<@@=talk>
%    \end{macrocode}
%
% \begin{variable}{\@author, \@date, \@institute, \@subtitle, \@title}
% \begin{variable}
%   {
%     \@shortauthor    ,
%     \@shortdate      ,
%     \@shortinstitute ,
%     \@shortsubtitle  ,
%     \@shorttitle
%   }
%   We create a set of keys and variables in one go. Following the classical
%   kernel approach, all of the underlying storage is global. The short values
%   will always be set in the following code so can be used automatically
%   anywhere we might want them.
%    \begin{macrocode}
\clist_map_inline:nn
  { author , date , institute , subtitle , title }
  {
    \keys_define:nn { talk / metadata }
      {
        #1 .tl_gset:c = @ #1 ,
        short- #1 .tl_gset:c = @short #1
      }
  }
%    \end{macrocode}
%   Allow empty values for author and title.
%    \begin{macrocode}
\tl_gclear:N \@author
\tl_gclear:N \@title
%    \end{macrocode}
%   As the date has a standard value, that has to be propagated.
%    \begin{macrocode}
\tl_gset_eq:NN \@shortdate \@date
%    \end{macrocode}
% \end{variable}
% \end{variable}
%
% \begin{macro}{\author, \date, \title}
%   Slightly repetitive but as we need to handle the tagging aspects, this is
%   easier than using a loop. The main aim is to add the short metadata
%   concept. Notice that keys are set before the main data storage in case
%   someone set the value as a key as well as a mandatory argument.
%    \begin{macrocode}
\RenewDocumentCommand \author { = { short-author } O { {#2} } m }
  {
    \keys_set:nn { talk / metadata } {#1}
    \tl_gset:Nn \@author {#2}
    \tl_gset_eq:NN \g__tag_title_author_tl \@author
    \keys_set_known:nn { hyp } {#1}
  }
\RenewDocumentCommand \date { = { short-date } O { {#2} } m }
  {
    \keys_set:nn { talk / metadata } {#1}
    \tl_gset:Nn \@date {#2}
  }
\RenewDocumentCommand \title { = { short-title } O { {#2} } m }
  {
    \keys_set:nn { talk / metadata } {#1}
    \tl_gset:Nn \@title {#2}
    \tl_gset_eq:NN \g__tag_title_title_tl \@title
    \keys_set_known:nn { hyp } {#1}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\institute, \subtitle}
%   Simple storage at present: unlike some of the kernel data, there is not
%   a lot to do here.
%    \begin{macrocode}
\NewDocumentCommand \institute { = { short-institute } O { {#2} } m }
  {
    \keys_set:nn { talk / metadata } {#1}
    \tl_gset:Nn \@institute {#2}
  }
\NewDocumentCommand \subtitle { = { short-subtitle } O { {#2} } m }
  {
    \keys_set:nn { talk / metadata } {#1}
    \tl_gset:Nn \@subtitle {#2}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{variable}
%   {
%     \l_@@_titlelem_after_skip ,
%     \l_@@_titlelem_before_skip ,
%     \l_@@_titlelem_color_tl ,
%     \l_@@_titlelem_font_tl ,
%     \l_@@_titlelem_tag_begin_tl ,
%     \l_@@_titlelem_tag_end_tl ,
%   }
%   As the various elements of the titlepage share certain characteristics, we
%   use a single template and split them as instances.
%    \begin{macrocode}
\NewTemplateType { titlepage-element } { 1 }
\DeclareTemplateInterface { titlepage-element } { talk } { 1 }
  {
    after-skip : length = 0em ,
    before-skip : length = 0em ,
    color : tokenlist = . ,
    font : tokenlist = \normalfont ,
    tag-begin : tokenlist = ,
    tag-end : tokenlist =
  }
\DeclareTemplateCode { titlepage-element } { talk } { 1 }
  {
    after-skip  = \l_@@_titlelem_after_skip ,
    before-skip = \l_@@_titlelem_before_skip ,
    color       = \l_@@_titlelem_color_tl ,
    font        = \l_@@_titlelem_font_tl ,
    tag-begin   = \l_@@_titlelem_tag_begin_tl ,
    tag-end     = \l_@@_titlelem_tag_end_tl
  }
  {
    \tl_if_empty:nF {#1}
      {
        \vspace { \l_@@_titlelem_before_skip }
        \group_begin:
          \tl_if_empty:NF \l_@@_titlelem_color_tl
            { \color_select:V \l_@@_titlelem_color_tl }
          \l_@@_titlelem_font_tl
          \l_@@_titlelem_tag_begin_tl
          #1
          \par
          \l_@@_titlelem_tag_end_tl
        \group_end:
        \vspace { \l_@@_titlelem_after_skip }
      }
  }
%    \end{macrocode}
%   Standard settings are taken from \cls{beamer} with minor adjustments.
%    \begin{macrocode}
\DeclareInstance { titlepage-element } { author } { talk }
  { before-skip = 1em }
\DeclareInstance { titlepage-element } { date } { talk }
  { after-skip = 0.5em }
\DeclareInstance { titlepage-element } { institute } { talk }
  { font = \scriptsize }
\DeclareInstance { titlepage-element } { subtitle } { talk }
  { before-skip = 0.25em , color = structure }
\DeclareInstance { titlepage-element } { title } { talk }
  {
    color = structure ,
    font = \Large ,
    tag-begin = \tag_struct_begin:n { tag = Title } ,
    tag-end = \tag_struct_end:
  }
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}
%   {
%     \l_@@_titlepage_order_clist  ,
%     \l_@@_titlepage_alignment_tl  ,
%     \l_@@_titlepage_framestyle_tl ,
%     \l_@@_frame_alignment_tl
%   }
%   Here, we deal with the overall style: notice that frame vertical alignment
%   actually applies elsewhere, which is why it doesn't show up in the template
%   code part. As a result, we have a slightly repetitive key interface.
%    \begin{macrocode}
\NewTemplateType { titlepage } { 0 }
\DeclareTemplateInterface { titlepage } { talk } { 0 }
  {
    element-order : commalist =
      {
        title     ,
        subtitle  ,
        author    ,
        institute ,
        date
      } ,
    framestyle : tokenlist = talk ,
    horizontal-alignment : choice { left , center ,  right } = center ,
    vertical-alignment : choice { bottom , center , stretch , top } = center
  }
\DeclareTemplateCode { titlepage } { talk } { 0 }
  {
    element-order = \l_@@_titlepage_order_clist ,
    framestyle = \l_@@_titlepage_framestyle_tl ,
    horizontal-alignment =
      {
        left = \tl_set:Nn \l_@@_titlepage_alignment_tl { flushleft } ,
        center = \tl_set:Nn \l_@@_titlepage_alignment_tl { center } ,
        right = \tl_set:Nn \l_@@_titlepage_alignment_tl { flushright }
      } ,
    vertical-alignment =
      {
        bottom = \tl_set:Nn \l_@@_frame_alignment_tl { bottom } ,
        center = \tl_set:Nn \l_@@_frame_alignment_tl { center } ,
        stretch = \tl_set:Nn \l_@@_frame_alignment_tl { stretch } ,
        top = \tl_set:Nn \l_@@_frame_alignment_tl { top }
      }
  }
  {
    \tl_if_empty:NF \l_@@_titlepage_framestyle_tl
      { \exp_args:NV \thispagestyle \l_@@_titlepage_framestyle_tl }
    \begin { \l_@@_titlepage_alignment_tl }
      \cs_set_protected:Npn \and { \quad }
      \clist_map_inline:Nn \l_@@_titlepage_order_clist
        {
          \ExpandArgs { nnv } \UseInstance { titlepage-element }
            {##1} { @ ##1 }
        }
    \end { \l_@@_titlepage_alignment_tl }
  }
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}{\maketitle}
%   A very simple setup.
%    \begin{macrocode}
\NewDocumentCommand \maketitle { O {} }
  {
    \bool_if:NTF \l_@@_frame_bool
      { \UseTemplate { titlepage } { talk } {#1} }
      {
        \begin { frame }
          \UseTemplate { titlepage } { talk } {#1}
        \end { frame }
      }
  }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
