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

Panel border is invisible sometimes. #343

Closed
abhaynath opened this issue May 28, 2024 · 2 comments · Fixed by #352
Closed

Panel border is invisible sometimes. #343

abhaynath opened this issue May 28, 2024 · 2 comments · Fixed by #352
Labels
bug Something isn't working

Comments

@abhaynath
Copy link

I am using the latest version of Dock.

Sometimes the border is getting invisible if the panel is dragged.

Adding screenshots and the axaml file for reference.

My monitor resolution is 1366x768 if is resolution specific issue.

XAML :
xaml.txt

img1
img2

@wieslawsoltes
Copy link
Owner

It's probably issue with screen resolution and DPI, probably related to math in splitter control calculations.

@wieslawsoltes wieslawsoltes added the bug Something isn't working label Jun 1, 2024
@OlivierMiracle
Copy link
Contributor

OlivierMiracle commented Aug 14, 2024

I have read through the ProportionalStackPanel.cs. I was assuming that multiplying by proportion variable causes the issue which turned out to be the case.

In ArrangeOverride and MeasureOverride methods when calculating Width/Height of the children the following formula is used:

  // case Orientation.Horizontal
  var width = Math.Max(0, (arrangeSize.Width - splitterThickness) * proportion);

  // case Orientation.Vertical
  var height = Math.Max(0, (arrangeSize.Height - splitterThickness) * proportion);

I have allowed myself to write some helper function to calculate the proper width/height of the control:

private double CalculateDimension(double dimension, double proportion, int childIndex)
{
    var childDimension = dimension * proportion;
    var flooredChildDimension = Math.Floor(childDimension);
    
    // checks whether division doesn't leave a fraction
    if (childDimension == flooredChildDimension)
        return Math.Max(0, flooredChildDimension);
    else
    {
        // if so, it assigns the divided pixel to the first control in proportional split
        var isFirst = childIndex == 0 ? 1 : 0;
        return Math.Max(0, flooredChildDimension + isFirst);
    }
}

Then it's used like this:

var height = CalculateDimension(arrangeSize.Height - splitterThickness, proportion, i);

border-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants