attr-lay.mkiv /size: 3734 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=attr-lay,
3%D        version=2007.06.06,
4%D          title=\CONTEXT\ Attribute Macros,
5%D       subtitle=Viewerlayers,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Attribute Macros / Viewerlayers}
15
16%D Currently there is a limitation in mixed inline usage. This has to do with the fact
17%D that we have a stacked model but cannot determine where to revert to (as we can
18%D have AABBCCAA ranges). Maybe I'll solve that one day. It only affects nested inline
19%D layers and these make not much sense anyway. We'd have to store the complete nesting
20%D stack in the attribute in order to be able to cross pages and that demands a new
21%D mechanism.
22
23\unprotect
24
25\registerctxluafile{attr-lay}{}
26
27% needs to work over stopitemize grouping etc
28
29\installcorenamespace{viewerlayer}
30
31\installcommandhandler \??viewerlayer {viewerlayer} \??viewerlayer
32
33\setupviewerlayer
34  [\c!state=\v!start,
35   \c!title=,
36   \c!export=\v!yes, % exportable is ugly
37   \c!printable=\v!yes,
38   \c!scope=\v!local, % maybe global but needs checking with layout
39   \c!method=\v!none]
40
41\appendtoks
42  \clf_defineviewerlayer
43       tag       {\currentviewerlayer}%
44       title     {\viewerlayerparameter\c!title}%
45       visible   {\viewerlayerparameter\c!state}%
46       editable  {\v!yes}%
47       export    {\viewerlayerparameter\c!export}%
48       printable {\viewerlayerparameter\c!printable}%
49       scope     {\viewerlayerparameter\c!scope}%
50  \relax
51  \doif{\viewerlayerparameter\c!method}\v!command
52    {\setuxvalue{\e!start#1}{\startviewerlayer[\currentviewerlayer]}%
53     \setuxvalue{\e!stop #1}{\stopviewerlayer}}%
54\to \everydefineviewerlayer
55
56\unexpanded\def\startviewerlayer[#1]{\clf_startviewerlayer{#1}}% not grouped
57\unexpanded\def\stopviewerlayer     {\clf_stopviewerlayer}     % not grouped
58\unexpanded\def\viewerlayer     [#1]{\groupedcommand
59                                    {\clf_startviewerlayer{#1}}% grouped
60                                    {\clf_stopviewerlayer}}    % grouped
61
62% some day we will keep this at the lua end as the info is only needed there
63
64\newtoks\currentviewerlayertoks % soon we can set macros at the lua end
65
66\def\currentviewerlayer{\the\currentviewerlayertoks}
67
68\appendtoks
69    \let\currentviewerlayer\empty
70\to \everybeforepagebody
71
72% layout components are implemented rather directly (speed)
73
74\installcorenamespace{layoutcomponentattribute}
75
76\def\attr_layoutcomponent_initialize#1%
77  {\edef\layoutcomponentboxattribute{\clf_definedlayoutcomponent{#1}}%
78   \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}%
79   \expandafter\glet\csname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute}
80
81\def\attr_layoutcomponent_set#1% make this faster
82  {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname
83   \ifx\layoutcomponentboxattribute\relax
84     \attr_layoutcomponent_initialize{#1}% get rid of { }
85   \fi}
86
87\def\attr_layoutcomponent_reset
88  {\let\layoutcomponentboxattribute\empty}
89
90\let\setlayoutcomponentattribute  \gobbleoneargument
91\let\resetlayoutcomponentattribute\relax
92\let\layoutcomponentboxattribute  \empty
93
94\unexpanded\def\showlayoutcomponents
95  {\let\setlayoutcomponentattribute  \attr_layoutcomponent_set
96   \let\resetlayoutcomponentattribute\attr_layoutcomponent_reset}
97
98\unexpanded\def\attr_layoutcomponent_cleanup
99  {\clf_cleanuplayers}
100
101\appendtoks
102    \attr_layoutcomponent_cleanup
103\to \everyshipout
104
105\protect \endinput
106