discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUstep app fails on Ubuntu 16 - found workaround


From: Andreas Höschler
Subject: Re: GNUstep app fails on Ubuntu 16 - found workaround
Date: Fri, 8 May 2020 20:00:25 +0200

Hi Fred,

@implementation NSButton (sizeToContent)

- (void)sizeToFit
{
  NSSize size = [_cell cellSize];
  if (size.height > 10000.0)
    {      
     NSLog(@"Reporting button::imagePosition %d", [self imagePosition]);
     NSLog(@"Reporting _cell::imagePosition %d", [_cell imagePosition]);
    }
  [self setFrameSize: size];
}

@end

Could you please move the logging code one level down into the NSButtonCell and report from there how this is calculated? Also report the image size as seen by the cell. You could check the value of s.height at the end of the method and if it is huge report textSize, imageSize and border

An image position of 2 should be NSImageLeft, which is fine.


NSButtonCell.m
==================
- (NSSize) cellSize
{
...
  if (imageToDisplay)
    {
      imageSize = [imageToDisplay size];

      NSLog(@"cellSize imageSize %@", NSStringFromSize(imageSize));

    }
...
      case NSImageLeft: 
      case NSImageRight: 
        s.width = imageSize.width + titleSize.width + GSCellTextImageXDist;
        NSLog(@"imageSize.height %f titleSize.height %f", imageSize.height, titleSize.height);
        s.height = MAX(imageSize.height, titleSize.height);
        break;
...

  // Add border size
  s.width += border.left + border.right;
  NSLog(@"border.top %f border.bottom %f", border.top, border.bottom);
  s.height += border.top + border.bottom;
  NSLog(@"returning s %@", NSStringFromSize(s));
...
}


2020-05-08 19:58:14.729 SOObjectBrowser[14224:14224] cellSize imageSize {width = 15; height = 15}
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] imageSize.height 15.000000 titleSize.height 10000000.000000
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] border.top 0.000000 border.bottom 0.000000
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] returning s {width = 18; height = 1e+07}
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] Reporting button::imagePosition 2
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] Reporting _cell::imagePosition 2
2020-05-08 19:58:14.730 SOObjectBrowser[14224:14224] Got height 10000004.000000. We correct this ...

The mess is caused by the titleSize!? :-( I haven't set a title since this is an image only button!

Regards,

 Andreas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]