In this case now inset dimensions are dynamic as it will depend on position of inset. Current implementation of dimensions has 3 members {wid - width, ascent - asc, des-descent}. With three box implementation, I think we will need four members
{ wid1-width of first row, wid2-width of last row, asc-ascent, des-descent}. Now to compute dimensions, I have thought something like below: max_width (Maximum width of current viewport) (x,y) (current position) There will be 2 cases: 1) text of inset has only one row: fig1: [[ original inset text: This is inset text. with 3 box inset implementation: This is the normal text.This is the normal text.[[This is inset text.]]This is original text again. ]] fig2: [[ original inset text: This is inset text.This is inset text.This is inset text. with 3 box inset implementation: This is the normal text.This is the normal text.[[This is inset text. This is inset text.]]This is the normal text again. ]] In this case, if (max_width - x) > width of row of original text then **fig1** w1=width of row of original text w2=0 else **fig2** w1= max_width - x w2= width of row of original text - w1 2) text of inset has more than one rows: fig3: [[ Original inset Text Foot This is the foonote which is pretty long, and what LyX would normally do is put this whole thing on a few lines by itself. What we want is for it to flow with the normal text. with 3 box inset implementation: This is the normal text. This is the normal text.[[Foot This is the foonote which is pretty long, and what LyX would normally do is put this whole thing on a few lines by itself. What we want is for it to flow with the normal text.]] This is the normal text again. ]] fig4: [[ Original inset text: Foot This is the foonote which is pretty long, and what LyX would normally do is put this whole thing on a few lines by itself. What we want is for it to flow with the normal text.This is inset text. This is inset text. This is inset text. with 3 box inset implementation: This is the normal text. This is the normal text.[[Foot This is the foonote which is pretty long, and what LyX would normally do is put this whole thing on a few lines by itself. What we want is for it to flow with the normal text.This is inset text. This is inset text. This is inset text.]] This is the normal text again. ]] In this case, w1= max_width - x if (max_width - x) > width of last row of original text then **fig3** w2= max_width + width of last row of original text - w1 else **fig4** w2= width of last row of original text - w1 and there will be n+1 rows in inset if original text of inset has n rows With this information and current position coordinates, polygon covering inset text can be drawn easily. Now with this implementation, I think I have to re-implement methods like TextMetrics:drawParagraph, TextMetrics:redoParagraph ,methods in rowPainter class and maybe some others because with current implementation, text is painted row by row in original text and with new implementation of 3 box model of insets, rows in original text is not same as rows painted in workarea (like in fig3 and fig4) With nested Insets complications may increase (I am not sure at this moment) .