cjwl / cocotron

The Cocotron
http://cocotron.org
MIT License
412 stars 103 forks source link

Frame rect vs. Layout (Alignment) rect of UI elements #3

Closed cyclaero closed 9 years ago

cyclaero commented 9 years ago

I am working on the display optimization of NSComboBox elements which look somewhat rough in my Windows application:

mac os xwindows 7 rough

In NSComboCoxCell.m, I added the following private method:

- (void)_frame2layoutRect:(NSRect *)rect
{
   switch ([self controlSize])
   {
      case NSRegularControlSize:
         rect->size.width  -= 3.0;
         rect->size.height -= 4.0;
         break;

      case NSSmallControlSize:
         rect->size.width  -= 3.0;
         rect->size.height -= 3.0;
         break;

      case NSMiniControlSize:
         rect->size.width  -= 3.0;
         rect->size.height -= 4.0;
         break;
   }
}

Together with some minor changes to said cell implementation, the NSComboBox layout resembles much better its Mac OS X counterpart.

windows 7 fine

My question is now, is this the appropriate measure for tackling layout issues of UI elements, or do you have a better one in mind. There are a handfull of other elements which could benefit from some layout improvements as well, and I think it would be good to establish some sort of a model for doing it the right way.

cjwl commented 9 years ago

The first thing that comes to mind is the NSCell methods such as

cyclaero commented 9 years ago

OK! I am back working on the combo box. It got also other problems beyond simple layout displacements. Once I ironed out everything, I will commit the changes to my fork, and we may discuss that in more detail.

cyclaero commented 9 years ago

I finished rectification of NSComboBox appearance and behaviour and I commit the changes to my fork.