mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 12:41:01 +00:00
offset calulation fixes and optimization
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16258 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e1dd0679b1
commit
da3b4b0583
1 changed files with 41 additions and 33 deletions
|
@ -486,7 +486,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned howMany = [_itemCells count];
|
unsigned howMany = [_itemCells count];
|
||||||
unsigned wideTitleView = 1;
|
unsigned wideTitleView = 1;
|
||||||
float neededImageAndTitleWidth = 0.0;
|
float neededImageAndTitleWidth = 0.0;
|
||||||
float neededKeyEquivalentWidth = 0.0;
|
float neededKeyEquivalentWidth = 0.0;
|
||||||
float neededStateImageWidth = 0.0;
|
float neededStateImageWidth = 0.0;
|
||||||
|
@ -550,21 +550,22 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
anImageAndTitleWidth = anImageWidth;
|
anImageAndTitleWidth = anImageWidth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
anImageAndTitleWidth += aStateImageWidth;
|
|
||||||
|
|
||||||
if (aStateImageWidth > neededStateImageWidth)
|
if (aStateImageWidth > neededStateImageWidth)
|
||||||
neededStateImageWidth = aStateImageWidth;
|
neededStateImageWidth = aStateImageWidth;
|
||||||
|
|
||||||
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
||||||
{
|
neededImageAndTitleWidth = anImageAndTitleWidth;
|
||||||
neededImageAndTitleWidth = anImageAndTitleWidth;
|
|
||||||
wideTitleView = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
||||||
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
||||||
|
|
||||||
// Popup menu has only one item with nibble image
|
// Title view width less than item's left part width
|
||||||
|
if ((anImageAndTitleWidth + aStateImageWidth)
|
||||||
|
> neededImageAndTitleWidth)
|
||||||
|
wideTitleView = 0;
|
||||||
|
|
||||||
|
// Popup menu has only one item with nibble or arrow image
|
||||||
if (anImageWidth)
|
if (anImageWidth)
|
||||||
popupImageWidth = anImageWidth;
|
popupImageWidth = anImageWidth;
|
||||||
}
|
}
|
||||||
|
@ -573,36 +574,43 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
_stateImageWidth = neededStateImageWidth;
|
_stateImageWidth = neededStateImageWidth;
|
||||||
_imageAndTitleWidth = neededImageAndTitleWidth;
|
_imageAndTitleWidth = neededImageAndTitleWidth;
|
||||||
_keyEqWidth = neededKeyEquivalentWidth;
|
_keyEqWidth = neededKeyEquivalentWidth;
|
||||||
|
|
||||||
|
accumulatedOffset = _horizontalEdgePad;
|
||||||
if (howMany)
|
if (howMany)
|
||||||
{
|
{
|
||||||
// Calculate the offsets and cache them.
|
// Calculate the offsets and cache them.
|
||||||
if (neededStateImageWidth)
|
if (neededStateImageWidth)
|
||||||
{
|
{
|
||||||
_stateImageOffset = accumulatedOffset += _horizontalEdgePad;
|
_stateImageOffset = accumulatedOffset;
|
||||||
accumulatedOffset += neededStateImageWidth;
|
accumulatedOffset += neededStateImageWidth += _horizontalEdgePad;
|
||||||
}
|
}
|
||||||
|
|
||||||
_imageAndTitleOffset = accumulatedOffset += _horizontalEdgePad;
|
if (neededImageAndTitleWidth)
|
||||||
accumulatedOffset += neededImageAndTitleWidth;
|
{
|
||||||
|
_imageAndTitleOffset = accumulatedOffset;
|
||||||
if (neededKeyEquivalentWidth)
|
accumulatedOffset += neededImageAndTitleWidth;
|
||||||
{
|
}
|
||||||
_keyEqOffset = accumulatedOffset += (2 * _horizontalEdgePad);
|
|
||||||
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
if (wideTitleView)
|
||||||
}
|
{
|
||||||
else
|
_keyEqOffset = accumulatedOffset = neededImageAndTitleWidth
|
||||||
{
|
+ (3 * _horizontalEdgePad);
|
||||||
if (wideTitleView && [_menu supermenu] != nil)
|
}
|
||||||
accumulatedOffset += 15 + 3 + 2;
|
else
|
||||||
else
|
{
|
||||||
accumulatedOffset += 3 * _horizontalEdgePad;
|
_keyEqOffset = accumulatedOffset += (2 * _horizontalEdgePad);
|
||||||
}
|
}
|
||||||
|
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
||||||
|
|
||||||
|
if ([_menu supermenu] != nil && neededKeyEquivalentWidth < 8)
|
||||||
|
{
|
||||||
|
accumulatedOffset += 8 - neededKeyEquivalentWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accumulatedOffset += 5 + neededImageAndTitleWidth + 3 + 2;
|
accumulatedOffset += neededImageAndTitleWidth + 3 + 2;
|
||||||
if (wideTitleView && [_menu supermenu] != nil)
|
if ([_menu supermenu] != nil)
|
||||||
accumulatedOffset += 15;
|
accumulatedOffset += 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue