[latex3-commits] [git/LaTeX3-latex3-latex3] master: Allow for nesting bb data (7602dc0)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Feb 26 23:41:08 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/7602dc0a0bff2610b02b77ac7366a83c59988a00

>---------------------------------------------------------------

commit 7602dc0a0bff2610b02b77ac7366a83c59988a00
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Feb 26 22:41:08 2018 +0000

    Allow for nesting bb data


>---------------------------------------------------------------

7602dc0a0bff2610b02b77ac7366a83c59988a00
 l3experimental/l3draw/l3draw-scopes.dtx       |   59 +++++++++++++++++++++++--
 l3experimental/l3draw/l3draw.dtx              |   17 +++++++
 l3experimental/l3draw/testfiles/m3draw000.tlg |    4 ++
 3 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/l3experimental/l3draw/l3draw-scopes.dtx b/l3experimental/l3draw/l3draw-scopes.dtx
index 8cba8c3..19997fd 100644
--- a/l3experimental/l3draw/l3draw-scopes.dtx
+++ b/l3experimental/l3draw/l3draw-scopes.dtx
@@ -94,6 +94,19 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{macro}{\@@_reset_bb:}
+%   A simple auxiliary.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_reset_bb:
+  {
+    \dim_gset:Nn \g_@@_xmax_dim { -\c_max_dim }
+    \dim_gset:Nn \g_@@_xmin_dim {  \c_max_dim }
+    \dim_gset:Nn \g_@@_ymax_dim { -\c_max_dim }
+    \dim_gset:Nn \g_@@_ymin_dim {  \c_max_dim }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\draw_begin:, \draw_end:}
 %   Drawings are created by setting them into a box, then adjusting the box
 %   before inserting into the surroundings. At present the content is simply
@@ -114,10 +127,7 @@
       \int_gincr:N \g_@@_id_int
       \vbox_set:Nw \l_@@_main_box
         \driver_draw_begin:
-        \dim_gset:Nn \g_@@_xmax_dim { -\c_max_dim }
-        \dim_gset:Nn \g_@@_xmin_dim {  \c_max_dim }
-        \dim_gset:Nn \g_@@_ymax_dim { -\c_max_dim }
-        \dim_gset:Nn \g_@@_ymin_dim {  \c_max_dim }
+        \@@_reset_bb:
         \@@_path_reset_limits:
         \bool_set_true:N \l_@@_update_bb_bool
         \draw_transform_reset:
@@ -191,6 +201,47 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Suspending features}
+%
+% This section covers cases where some elements need to be inserted without
+% disturbing the rest of a drawing. This needs a little work due to the global
+% nature of various elements.
+%
+% \begin{variable}
+%   {\l_@@_xmax_dim, \l_@@_xmin_dim, \l_@@_ymax_dim, \l_@@_ymin_dim}
+%   Storage for the bounding box.
+%    \begin{macrocode}
+\dim_new:N \l_@@_xmax_dim
+\dim_new:N \l_@@_xmin_dim
+\dim_new:N \l_@@_ymax_dim
+\dim_new:N \l_@@_ymin_dim
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\draw_suspend_bb_begin:, \draw_suspend_bb_end:}
+%   The bounding box is simple: a straight group-based save and restore
+%   approach.
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_suspend_bb_begin:
+  {
+    \group_begin:
+      \dim_set_eq:NN \l_@@_xmax_dim \g_@@_xmax_dim
+      \dim_set_eq:NN \l_@@_xmin_dim \g_@@_xmin_dim
+      \dim_set_eq:NN \l_@@_ymax_dim \g_@@_ymax_dim
+      \dim_set_eq:NN \l_@@_ymin_dim \g_@@_ymin_dim
+      \@@_reset_bb:
+  }
+\cs_new_protected:Npn \draw_suspend_bb_end:
+  {
+      \dim_gset_eq:NN \g_@@_xmax_dim \l_@@_xmax_dim
+      \dim_gset_eq:NN \g_@@_xmin_dim \l_@@_xmin_dim
+      \dim_gset_eq:NN \g_@@_ymax_dim \l_@@_ymax_dim
+      \dim_gset_eq:NN \g_@@_ymin_dim \l_@@_ymin_dim
+    \group_end:
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index 03e591f..aa8a7c2 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -966,6 +966,23 @@
 %   This assignment is local.
 % \end{function}
 %
+% \subsection{Suspending drawing elements}
+%
+% Suspending drawing elements is necessary to allowing nesting of subparts.
+% These features have specific use requirements: the preconditions must be
+% met.
+%
+% \begin{function}{\draw_suspend_bb_begin:, \draw_suspend_bb_end:}
+%   \begin{syntax}
+%     \cs{draw_suspend_bb_begin:}
+%     ...
+%     \cs{draw_suspend_bb_begin:}
+%   \end{syntax}
+%   Suspends (and saves) calculation of the bounding box of a drawing,
+%   resetting the tracking data and allowing the bounding box of the
+%   nested content to be tracked.
+% \end{function}
+%
 % \end{documentation}
 %
 % \begin{implementation}
diff --git a/l3experimental/l3draw/testfiles/m3draw000.tlg b/l3experimental/l3draw/testfiles/m3draw000.tlg
index 63a5dc2..ed216a3 100644
--- a/l3experimental/l3draw/testfiles/m3draw000.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw000.tlg
@@ -25,6 +25,10 @@ Author: Joseph Wright
 \l__draw_main_box=\box...
 \g__draw_id_int=\count...
 \l__draw_linewidth_dim=\dimen...
+\l__draw_xmax_dim=\dimen...
+\l__draw_xmin_dim=\dimen...
+\l__draw_ymax_dim=\dimen...
+\l__draw_ymin_dim=\dimen...
 \g__draw_softpath_buffer_a_int=\count...
 \g__draw_softpath_buffer_b_int=\count...
 \g__draw_softpath_lastx_dim=\dimen...





More information about the latex3-commits mailing list