Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextPainter.getPreferredHeight() with calculateWrappedHeight ignores horizontal padding from wrapper painter #92

Open
thomasa299792 opened this issue Jun 20, 2024 · 0 comments

Comments

@thomasa299792
Copy link

(Forwarded from https://bugs.eclipse.org/bugs/show_bug.cgi?id=583350)

I encountered this in v2.0.5, but the TextPainter code appears to be the same in 2.4.0.

The method TextPainter.getPreferredHeight(), when calculateWrappedHeight is set, computes the text to display based off cell bounds adjusted for grid lines -- but not adjusted for any horizontal padding added by a wrapping PaddingDecorator.

    ICellPainter cellPainter = new TextPainter(m_shouldAutoWrap, false);
    cellPainter = new PaddingDecorator( cellPainter, 
        V_PADDING, H_PADDING, V_PADDING, H_PADDING );

As a consequence, the preferred cell height can be too low when the cell width is just below that required to avoid wrapping the text.

And then the preferred height of the row can be too low, and setting that incorrect preferred height can lead to the row not being tall enough to display the actual wrapping when trimming is considered.

    table.doCommand( new TurnViewportOffCommand());
    int[] rowPositions = new int[] { 0 }; // header row
    int[] gridRowHeights = MaxCellBoundsHelper.getPreferredRowHeights(
        table.getConfigRegistry(),
	new GCFactory(table),
	table,
	rowPositions);
    if (gridRowHeights != null) {
        table.doCommand( new MultiRowResizeCommand(
            table, rowPositions, gridRowHeights));
    }
    table.doCommand( new TurnViewportOnCommand());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant