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

  • ... Andreas Höschler via Discussion list for the GNUstep programming environment
    • ... Andreas Höschler via Discussion list for the GNUstep programming environment
      • ... Andreas Höschler via Discussion list for the GNUstep programming environment
        • ... Andreas Höschler via Discussion list for the GNUstep programming environment
          • ... Riccardo Mottola
            • ... Andreas Höschler via Discussion list for the GNUstep programming environment
            • ... Fred Kiefer
            • ... Fred Kiefer
            • ... Andreas Höschler via Discussion list for the GNUstep programming environment
            • ... Fred Kiefer
            • ... Andreas Höschler via Discussion list for the GNUstep programming environment
            • ... Fred Kiefer
            • ... Andreas Höschler via Discussion list for the GNUstep programming environment
            • ... Fred Kiefer
            • ... Fred Kiefer
            • ... Andreas Höschler via Discussion list for the GNUstep programming environment
            • ... Fred Kiefer
            • ... Riccardo Mottola
        • ... Riccardo Mottola
    • ... Riccardo Mottola

Reply via email to