%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 / Hans Hagen \& Ton Otten}]
%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. 

\unprotect 

\def\initlayerproperty#1#2%
  {\dodefineviewerlayer 
     {#1}% tag 
     {\getvalue{\??py#1\c!titel}}% title 
     {1}% visible
     {0}% type (1=frozen)
     {0}% printable
   \setgvalue{\e!start#1}{\getvalue{start#2property}{#1}}%
   \getvalue{\e!start#1}}

\def\startlayerproperty#1%
  {\dostartviewerlayer{#1}}   

\def\stoplayerproperty
  {\dostopviewerlayer}

\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

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

% \defineproperty [debugging]  [layer] [title=debugging]
% \defineproperty [navigation] [layer] [title=navigation]

%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 

\fetchruntimecommand \showlayoutcomponents {\f!propprefix\s!run}

\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}][layer][\c!titel=#2]%
%      \startproperty[\remappedlayering{#1}]%
%    \fi}
