summaryrefslogtreecommitdiff
path: root/tex/context/base/prop-lay.mkii
blob: 77c48ca6ed2e46a46c8d8d0917aae25f93726fc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
%D \module
%D   [       file=prop-lay,
%D        version=2003.04.20,
%D          title=\CONTEXT\ Property Macros,
%D       subtitle=Layers,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Property Macros / Layers}

%D Highly experimental, will probably change/evolve. Also, quite certainly
%D we will no longer share code between mkii and mkiv.

\unprotect

\let\currentlayerproperty\empty

\def\checklayerproperty
  {\doifelse{\checkedpropertyparameter\v!printable\currentproperty}\v!no
     {\def\printviewerlayer{0}}
     {\def\printviewerlayer{1}}%
   \dodefineviewerlayer
     \currentproperty % tag
     {\checkedpropertyparameter\c!title\currentproperty}%
     {\checkedpropertyparameter\c!state\v!start}% visible or hidden
     {0}% type (1=frozen)
     {\printviewerlayer}}% 1=printable

\def\startlayerproperty
  {\let\currentlayerproperty\currentproperty
   \dostartviewerlayer\currentproperty}

\def\stoplayerproperty
  {\dostopviewerlayer
   \let\currentlayerproperty\previousproperty}

\def\domakelayerpropertylist
  {\iflocation
     \expandafter\domakeviewerlayerlist
   \else
     \expandafter\gobbleoneargument
   \fi}

\setglobalsystemreference \rt!exec \v!HideLayer   {hidelayer}
\setglobalsystemreference \rt!exec \v!VideLayer   {videlayer}
\setglobalsystemreference \rt!exec \v!ToggleLayer {togglelayer}

\setexecutecommandcheck {hidelayer}   \domakelayerpropertylist
\setexecutecommandcheck {videlayer}   \domakelayerpropertylist
\setexecutecommandcheck {togglelayer} \domakelayerpropertylist

% \currentlayerproperty
% \checklayerproperty
% \startlayerproperty
% \stoplayerproperty
% \domakelayerpropertylist

%D \starttext
%D
%D \setuppapersize[S4][S4]
%D \setuplayout[middle]
%D \setupcolors[state=start]
%D \setupinteraction[state=start,color=,contrastcolor=]
%D
%D \defineproperty [L1] [layer] [title=layer 1]
%D \defineproperty [L2] [layer] [title=layer 2]
%D
%D \button{HIDE   L1}[HideLayer{L1}]
%D \button{VIDE   L1}[VideLayer{L1}]
%D \button{TOGGLE L1}[ToggleLayer{L1}]
%D
%D \button{HIDE L2}[HideLayer{L2}]
%D \button{VIDE L2}[VideLayer{L2}]
%D \button{TOGGLE L2}[ToggleLayer{L2}]
%D
%D \noheaderandfooterlines \centerbox{\startoverlay
%D   {\definedfont[Mono at 150pt]%
%D    \startproperty[L1]\red   TEST\stopproperty}
%D   {\definedfont[Mono at 150pt]%
%D    \startproperty[L2]\green TEST\stopproperty}
%D \stopoverlay} \page
%D
%D \noheaderandfooterlines \centerbox{\startoverlay
%D   {\definedfont[Mono at 15pt]%
%D    \goto{\startproperty[L1]\red   TEST\stopproperty}[CloseDocument]}
%D   {\definedfont[Mono at 15pt]%
%D    \goto{\startproperty[L2]\green TEST\stopproperty}[CloseDocument]}
%D \stopoverlay} \page
%D
%D \startproperty[L1]
%D   level 1 \startproperty[L2]level 2 \stopproperty level 1
%D \stopproperty
%D
%D \startproperty[L1]
%D   level 1 \page \startproperty[L2]level 2 \stopproperty level 1
%D \stopproperty
%D
%D \stoptext

%D Handy for tracing:

\def\showlayoutcomponents
  {\let\startlayoutcomponent\dostartlayoutcomponent
   \let\stoplayoutcomponent \dostoplayoutcomponent}

\def\dodefinelayoutcomponent#1#2%
  {\doifelsenothing{#2}%
     {\defineproperty[#1][\s!layer]}%
     {\defineproperty[#1][\s!layer][\c!title=#2]}}

\def\dostartlayoutcomponent#1#2%
  {\doifelseproperty{#1}\donothing{\dodefinelayoutcomponent{#1}{#2}}%
   \startproperty[#1]}

\def\dostoplayoutcomponent
  {\stopproperty}

\let\startlayoutcomponent\gobbletwoarguments
\let\stoplayoutcomponent \relax

\protect \endinput

% \def\remaplayering
%   {\dodoubleargument\doremaplayering}
%
% \def\remaplayering[#1][#2]%
%   {\setvalue{\??lm#1}{#2}}
%
% \def\remappedlayering#1%
%   {\ifcsname\??lm#1\endcsname
%      \@EA\remappedlayering\csname\??lm#1\endcsname\else#1%
%    \fi}
%
% \def\startshowlayering#1#2%
%   {\ifshowlayering
%      \defineproperty[\remappedlayering{#1}][\s!layer][\c!titel=#2]%
%      \startproperty[\remappedlayering{#1}]%
%    \fi}