Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix thin lines between cells and right side empty blocks #106

Merged
merged 2 commits into from
Feb 21, 2022

Conversation

Jugen
Copy link
Contributor

@Jugen Jugen commented Feb 21, 2022

Fixes FXMisc/RichTextFX#1091 Thin horizontal lines appear between lines of text when rapidly scrolling vertically
Also fixes FXMisc/RichTextFX#1092 Horizontal scrolling of a CodeArea can result in large empty blocks in the upper right of the viewport (although unfortunately white blocks still briefly flash with this change).

@Jugen Jugen merged commit 1f32ed8 into master Feb 21, 2022
@Jugen Jugen deleted the fix-thin-lines-between-cells branch February 21, 2022 16:35
@Jugen Jugen changed the title Fix thin lines between cells 2 Fix thin lines between cells and right side empty blocks Feb 21, 2022
@tchudyk
Copy link
Contributor

tchudyk commented Sep 10, 2022

Hi.
Probably, after this commit I have noticed a negative impact on RichTextFx - during typing text in editor it starts "minimally" scrolling.

I see, that in this commit there is Math.round(offset) in VirtualizedScrollPane:

   private void setVPosition(double pos) {
        // ....
        content.estimatedScrollYProperty().setValue((double) Math.round(offset));
    }

But farther, when this action goes to VirtualFlow class - to method:

void setLengthOffset(double pixels) {
        double total = totalLengthEstimateProperty().getOrElse(0.0);
        double length = sizeTracker.getViewportLength();
        double max = Math.max(total - length, 0);
        double current = lengthOffsetEstimate.getValue();

        if(pixels > max) pixels = max;
        if(pixels < 0) pixels = 0;

        double diff = pixels - current;
        if(diff == 0) {
            // do nothing
        } else if(Math.abs(diff) <= length) { // distance less than one screen
            navigator.scrollCurrentPositionBy(diff);
        } else {
            jumpToAbsolutePosition(pixels);
        }
    }

The incoming pixels value is rounded, but value in variable current is not rounded, and when we compute diff:

double diff = pixels - current;

... there is very often computed value 0.5 (but it should be 0) and VirtualFlow moves visible content by this diff (navigator.scrollCurrentPositionBy(diff)) instead of // do nothing

(This setLengthOffset method is executed there because is bound by property in VirtualFlow constructor:
lengthOffsetEstimate = new StableBidirectionalVar<>( sizeTracker.lengthOffsetEstimateProperty(), this::setLengthOffset );)

@tchudyk
Copy link
Contributor

tchudyk commented Sep 11, 2022

I Have created a proposal fix for this in my PR: #112

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants