Diff for /chimera/BookmarksToolbar.mm between versions 1.10 and 1.11

version 1.10, 2002/04/19 01:08:30 version 1.11, 2002/04/19 02:15:03
Line 112 Line 112
   
 -(void)reflowButtonsStartingAtIndex: (int)aIndex  -(void)reflowButtonsStartingAtIndex: (int)aIndex
 {  {
  float sizeChange = 0;  float oldHeight = [self frame].size.height;
   float computedHeight = 18;
   int count = [mButtons count];    int count = [mButtons count];
   float currY = 1.0;    float currY = 1.0;
   float prevX = 2.0;    float prevX = 2.0;
Line 136 Line 137
   
     if ([self bounds].size.width < prevX) {      if ([self bounds].size.width < prevX) {
       // The previous button didn't fit.  We need to make a new row.        // The previous button didn't fit.  We need to make a new row.
       sizeChange += 18;  
       currY += 18;        currY += 18;
      [self setFrame: NSMakeRect([self frame].origin.x, [self frame].origin.y - 18.0,      computedHeight += 18;
                                 [self frame].size.width, [self frame].size.height + 18.0)];      if (computedHeight > oldHeight) {
      [self setNeedsDisplay: YES];        [self setFrame: NSMakeRect([self frame].origin.x, [self frame].origin.y+(oldHeight-computedHeight),
                                    [self frame].size.width, computedHeight)];
         [self setNeedsDisplay: YES];
 
         BookmarksButton* prevButton = [mButtons objectAtIndex: (i-1)];
         float y = [prevButton frame].origin.y;
       }
       
       prevX = 2;        prevX = 2;
       [button setFrame: NSMakeRect(prevX, currY, width, height)];        [button setFrame: NSMakeRect(prevX, currY, width, height)];
         prevX += [button frame].size.width + 2;
     }      }
           
     [button setNeedsDisplay: YES];      [button setNeedsDisplay: YES];
   }    }
   
     float currentHeight = [self frame].size.height;
     if (computedHeight != currentHeight) {
       [self setFrame: NSMakeRect([self frame].origin.x, [self frame].origin.y + (currentHeight - computedHeight),
                                  [self frame].size.width, computedHeight)];
       [self setNeedsDisplay: YES];
     }
     
     float sizeChange = computedHeight - oldHeight;
   if (sizeChange != 0) {    if (sizeChange != 0) {
     // We need to adjust the content area.      // We need to adjust the content area.
     NSView* view = [[[self window] windowController] getTabBrowser];      NSView* view = [[[self window] windowController] getTabBrowser];
Line 166 Line 182
   NSRect oldFrame = [self frame];    NSRect oldFrame = [self frame];
   [super setFrame:aRect];    [super setFrame:aRect];
   
  // See if we got bigger or smaller.  We could gain or lose a row.  if (oldFrame.size.width == aRect.size.width)
     return;
 
   int count = [mButtons count];
   if (count <= 2)
     return; // We have too few buttons to care.
       
     // Do some optimizations when we have only one row.
     if (aRect.size.height < 25) // We have only one row.
     {
       if (oldFrame.size.width < aRect.size.width)
         // We got bigger.  If we already only have one row, just bail.
         //        This will optimize for a common resizing case.
         return;
       else {
         // We got smaller.  Just go to the last button and see if it is outside
         // our bounds.
         BookmarksButton* button = [mButtons objectAtIndex:(count-1)];
         if ([button frame].origin.x + [button frame].size.width >
             [self bounds].size.width - 2) {
           // The button doesn't fit any more.  Reflow starting at this index.
           [self reflowButtonsStartingAtIndex:(count-1)];
         }
       }
     }
     else {
       // See if we got bigger or smaller.  We could gain or lose a row.
       [self reflowButtons];
     }
 }  }
   
 @end  @end

Removed from v.1.10  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>