Two-part @Graphic vs. xsize etc

Valery Ushakov <[email protected]> Thu, 6 Mar 2014 04:17:17 +0400
Newsgroups gmane.comp.type-setting.lout
Message-ID <[email protected]>
I have stumbled into a problem with two-part left parameter of
@Graphic.  When the second part is emitted the values of xsize etc
might have been overwritten by nested calls to @Graphic inside the
right parameter.

Attached is a small example that demonstrates what I'm after.
@TightCurveBox symbol includes a workaround to save/restore the
values.  Calling LoutCurveBox in the "after" part is visually better
since it avoids cell background painting over the box.

I wonder if lout should re-emit a call to LoutGraphic before the
second part if it's not empty.

-uwe
graphic2.lt (text/plain, 971 B)
@SysInclude { diag }
@SysInclude { tbl }
@SysInclude { doc }

def @TightCurveBox
  named radius { 0.5f }
  right x
{
  @VContract @HContract 0p @HShift {
    {
      # XXX: save arguments for LoutGraphic - they will be overwritten
      # by any calls to @Graphic inside right arg
      xsize ysize xmark ymark loutf loutv louts

      # add clip to the graphic state of right arg
      grestore LoutCurveBox clip newpath gsave

      // # after right arg is emitted 
      LoutGraphic # restore values that might have been overwritten

      LoutCurveBox stroke
    }
    @Graphic { radius @HShift @OneRow x }
  }
}


@Document
//
@Text @Begin
@LP
@TightCurveBox
  radius { 0.6f } # @Tbl's default margin
@Tbl
  aformat {
    @Cell
      paint { lightgrey }
      font { Bold }
      indent { ctr }
      rulebelow { yes }
     { A }
  }
  bformat { @Cell A }
{
  @Rowa A { Title }

  @Rowb rulebelow { yes } A { foo }

  @Rowb A { bar }
  @Rowb A { buzz }
}
@End @Text