summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/grph-inc.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/grph-inc.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/grph-inc.mkiv58
1 files changed, 48 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/grph-inc.mkiv b/Master/texmf-dist/tex/context/base/grph-inc.mkiv
index aa2157b9fa8..633130ea939 100644
--- a/Master/texmf-dist/tex/context/base/grph-inc.mkiv
+++ b/Master/texmf-dist/tex/context/base/grph-inc.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Figure Inclusion,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%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
@@ -19,6 +19,8 @@
%D - alternative images
%D - a few more obscure things
+% use framedcommandhandler
+
\registerctxluafile{grph-inc}{1.001}
\registerctxluafile{grph-fil}{1.001}
\registerctxluafile{grph-u3d}{1.001} % this will change
@@ -98,9 +100,9 @@
\def\figurefullname {\ctxlua{figures.tprint("used","fullname")}}
\def\noffigurepages {\ctxlua{figures.tprint("used","pages",0)}}
-\def\figurefilepath {\ctxsprint{file.dirname (figures.get("used","fullname"))}}
-\def\figurefilename {\ctxsprint{file.nameonly(figures.get("used","fullname"))}}
-\def\figurefiletype {\ctxsprint{file.extname (figures.get("used","fullname"))}}
+\def\figurefilepath {\cldcontext{file.dirname (figures.get("used","fullname"))}}
+\def\figurefilename {\cldcontext{file.nameonly(figures.get("used","fullname"))}}
+\def\figurefiletype {\cldcontext{file.extname (figures.get("used","fullname"))}}
\let\naturalfigurewidth \figurenaturalwidth
\let\naturalfigureheight \figurenaturalheight
@@ -136,7 +138,7 @@
\appendtoks \resetexternalfigures \to \everyoverlay
\appendtoks \resetexternalfigures \to \everybeforepagebody % not really needed
-\def\resetfigureusersettings
+\def\resetfigureusersettings % if we use a command handler we can simply define a new instance
{%
\let\@@efmethod \empty
\let\@@eflabel \empty
@@ -225,8 +227,29 @@
\def\docheckfiguremps #1{\doprocessmpslikefigure{#1}}
\def\docheckfiguremprun #1#2{\doprocesstexlikefigure{\useMPrun{#1}{#2}}}
+% \def\doscalefigure
+% {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}}
+
\def\doscalefigure
- {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}}
+ {\global\setbox\foundexternalfigure\vbox{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
+
+% quick hack: chaining \??ef via \s!parent happens when this is also a commandhandler
+
+\definescale
+ [\v!figure]
+ [\c!hfactor =\@@efhfactor ,
+ \c!wfactor =\@@efwfactor ,
+ \c!factor =\@@effactor ,
+ \c!maxwidth =\@@efmaxwidth ,
+ \c!maxheight=\@@efmaxheight,
+ \c!xscale =\@@efxscale ,
+ \c!yscale =\@@efyscale ,
+ \c!scale =\@@efscale ,
+ \c!sx =\@@efsx ,
+ \c!sy =\@@efsy ,
+ \c!width =\@@efwidth ,
+ \c!height =\@@efheight ,
+ \c!lines =\@@eflines ]
\newconditional\testexternalfigureonly
@@ -234,7 +257,7 @@
% \externalfigure[demo.svg]
% \externalfigure[demo.svg][conversion=png]
-\def\calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \cmd label filename parent_id preset current
+\unexpanded\def\calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \cmd label filename parent_id preset current
{\dontcomplain
\restorecatcodes
\forgetall
@@ -267,6 +290,7 @@
height = "\@@efheight", % can be crap
} }%
\ctxlua{figures.identify()}%
+ % also mode: checkpresense only
\ifconditional\testexternalfigureonly
\ifcase\figurestatus \else
\ctxlua{figures.check()}%
@@ -300,7 +324,9 @@
\egroup
\egroup}
-\def\signalexternalfigure % global
+\newsystemmode\v!figure
+
+\def\signalexternalfigure % global (dup call to status)
{\ifcase\figurestatus
\global\resetsystemmode\v!figure % todo, also: \v!resource
\else
@@ -381,9 +407,21 @@
\let\getfiguredimensionsonly\getfiguredimensions
-\def\doiffigureelse#1%
+% \unexpanded\def\doiffigureelse#1%
+% {\getfiguredimensions[#1]% so data is available !
+% \ifdim\figurewidth=\zeropoint % todo: \figurestatus
+% \expandafter\secondoftwoarguments
+% \else
+% \expandafter\firstoftwoarguments
+% \fi}
+
+% \unexpanded\def\doiffigureelse#1% just low level call
+% {\getfiguredimensions[#1]% so data is available ! ... grouped so status is local
+% \doifmodeelse{*\v!figure}\firstoftwoarguments\secondoftwoarguments} % mode is set global
+
+\unexpanded\def\doiffigureelse#1%
{\getfiguredimensions[#1]% so data is available !
- \ifdim\figurewidth=\zeropoint % todo: \figurestatus
+ \ifcase\figurestatus
\expandafter\secondoftwoarguments
\else
\expandafter\firstoftwoarguments