summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3experimental/l3draw-scopes.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3experimental/l3draw-scopes.dtx')
-rw-r--r--macros/latex/contrib/l3experimental/l3draw-scopes.dtx106
1 files changed, 96 insertions, 10 deletions
diff --git a/macros/latex/contrib/l3experimental/l3draw-scopes.dtx b/macros/latex/contrib/l3experimental/l3draw-scopes.dtx
index 7065afd267..baa2239e9f 100644
--- a/macros/latex/contrib/l3experimental/l3draw-scopes.dtx
+++ b/macros/latex/contrib/l3experimental/l3draw-scopes.dtx
@@ -44,7 +44,7 @@
% }^^A
% }
%
-% \date{Released 2021-07-12}
+% \date{Released 2021-08-04}
%
% \maketitle
%
@@ -60,6 +60,14 @@
%<@@=draw>
% \end{macrocode}
%
+% This sub-module covers more-or-less the same ideas as
+% \texttt{pgfcorescopes.code.tex}. At present, equivalents of the
+% following are currently absent:
+% \begin{itemize}
+% \item \cs{pgftext}: This is covered at this level by the coffin-based
+% interface \cs{draw_coffin_use:Nnn}
+% \end{itemize}
+%
% \subsection{Drawing environment}
%
% \begin{variable}
@@ -142,6 +150,7 @@
}
\cs_new_protected:Npn \draw_end:
{
+ \@@_baseline_finalise:w
\exp_args:NNNV \hbox_set_end:
\clist_set:Nn \l_draw_layers_clist \l_draw_layers_clist
\@@_layers_insert:
@@ -154,15 +163,7 @@
\dim_gzero:N \g_@@_ymax_dim
\dim_gzero:N \g_@@_ymin_dim
}
- \hbox_set:Nn \l_@@_main_box
- {
- \skip_horizontal:n { -\g_@@_xmin_dim }
- \box_move_down:nn { \g_@@_ymin_dim }
- { \box_use_drop:N \l_@@_main_box }
- }
- \box_set_ht:Nn \l_@@_main_box
- { \g_@@_ymax_dim - \g_@@_ymin_dim }
- \box_set_dp:Nn \l_@@_main_box { 0pt }
+ \@@_finalise:
\box_set_wd:Nn \l_@@_main_box
{ \g_@@_xmax_dim - \g_@@_xmin_dim }
\mode_leave_vertical:
@@ -172,6 +173,91 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_finalise:}
+% \begin{macro}{\@@_finalise_baseline:n}
+% Finalising the (vertical) size of the output depends on whether we have
+% an explicit baseline or not. To allow for that, we have two functions, and
+% the one that's used depends on whether the user has set a baseline. Notice
+% that in contrast to \pkg{pgf} we \emph{do} allow for a non-zero depth if
+% the explicit baseline is above the lowest edge of the initial bounding box.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_finalise:
+ {
+ \hbox_set:Nn \l_@@_main_box
+ {
+ \skip_horizontal:n { -\g_@@_xmin_dim }
+ \box_move_down:nn
+ { \g_@@_ymin_dim }
+ { \box_use_drop:N \l_@@_main_box }
+ }
+ \box_set_dp:Nn \l_@@_main_box { 0pt }
+ \box_set_ht:Nn \l_@@_main_box
+ { \g_@@_ymax_dim - \g_@@_ymin_dim }
+ }
+\cs_new_protected:Npn \@@_finalise_baseline:n #1
+ {
+ \hbox_set:Nn \l_@@_main_box
+ {
+ \skip_horizontal:n { -\g_@@_xmin_dim }
+ \box_move_down:nn
+ {#1}
+ { \box_use_drop:N \l_@@_main_box }
+ }
+ \box_set_dp:Nn \l_@@_main_box
+ {
+ \dim_max:nn
+ { #1 - \g_@@_ymin_dim }
+ { 0pt }
+ }
+ \box_set_ht:Nn \l_@@_main_box
+ { \g_@@_ymax_dim + #1 }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Baseline position}
+%
+% \begin{variable}{\l_@@_baseline_bool, \l_@@_baseline_dim}
+% For tracking the explicit baseline and whether it is active.
+% \begin{macrocode}
+\bool_new:N \l_@@_baseline_bool
+\dim_new:N \l_@@_baseline_dim
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\draw_baseline:n}
+% A simple setting of the baseline along with the flag we need to know that
+% it is active.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_baseline:n #1
+ {
+ \bool_set_true:N \l_@@_baseline_bool
+ \dim_set:Nn \l_@@_baseline_dim { \fp_to_dim:n {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_baseline_finalise:w}
+% Rather than use a global data structure, we can arrange to put the baseline
+% value at the right group level with a small amount of shuffling. That happens
+% here.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_baseline_finalise:w #1 \@@_finalise:
+ {
+ \bool_if:NTF \l_@@_baseline_bool
+ {
+ \use:x
+ {
+ \exp_not:n {#1}
+ \@@_finalise_baseline:n { \dim_use:N \l_@@_baseline_dim }
+ }
+ }
+ { #1 \@@_finalise: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Scopes}
%
% \begin{variable}{\l_@@_linewidth_dim}