• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Preventing default drawing of slider bar in custom NSSlider class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preventing default drawing of slider bar in custom NSSlider class


  • Subject: Re: Preventing default drawing of slider bar in custom NSSlider class
  • From: Ken Tozier <email@hidden>
  • Date: Sun, 18 Mar 2007 04:38:00 -0400


On Mar 18, 2007, at 4:35 AM, Mikael Gransell wrote:

Where does it leave parts of it behind? One the top and bottom of the scroller or all over?

The part that extends below the bottom edge of the slider track. Approximately the bottom third of the knob. If you resize the view it refreshes but if you drag the knob again, same deal.




On Mar 18, 2007, at 5:03 AM, Ken Tozier wrote:

Oy.

After 3 more hours of futzing, I can't get the knob to center on the slider bar without leaving part of itself behind when it moves. Anyone see what I'm doing wrong here?

Here's the draw knob method:

- (void) drawKnob:(NSRect) knobRect
{
   float        adjustedLeft        = knobRect.origin.x,
           knobWidth        = knobRect.size.width,
           knobHeight        = knobRect.size.height,
           maxRight            = maxXOrigin - knobWidth;

   if ((adjustedLeft) < 10)
       adjustedLeft    = 10;
   else if (adjustedLeft > maxRight)
       adjustedLeft    = maxRight;

adjustedKnobRect = NSMakeRect(adjustedLeft, knobRect.origin.y, knobWidth, knobHeight);

   // following line centers the knob correctly,
   // but when you drag it, half of the pixels are
   // left behind
   /*if (isFlipped)
       adjustedRect.origin.y += 4;*/

   [gSliderKnob drawInRect: adjustedKnobRect
               fromRect: NSZeroRect
               operation: NSCompositeSourceOver
               fraction: 1.0];
}


And here's the other draw stuff in case that sheds light on the problem


- (void) drawBarInside:(NSRect) inRect
               flipped:(BOOL) inFlipped
{
   // may need this for knob drawing
   isFlipped            = inFlipped;

   // update the rectangles for the slider rail
   [self updateGeometryWithFrame: inRect];

   // draw control images
   [gSliderBackgroundImage drawInRect: inRect
               fromRect: NSZeroRect
               operation: NSCompositeSourceOver
               fraction: 1.0];

   [gSliderTrackLeft drawInRect: leftRect
               fromRect: NSZeroRect
               operation: NSCompositeSourceOver
               fraction: 1.0];

   [gSliderTrackCenter drawInRect: middleRect
               fromRect: NSZeroRect
               operation: NSCompositeSourceOver
               fraction: 1.0];

   [gSliderTrackRight drawInRect: rightRect
               fromRect: NSZeroRect
               operation: NSCompositeSourceOver
               fraction: 1.0];

   [self drawKnob];
}

- (void) updateGeometryWithFrame:(NSRect) inFrame
{
adjustedSliderRect = NSMakeRect(inFrame.origin.x + 10, 0, inFrame.size.width - 20, inFrame.size.height);


float rectHeight = inFrame.size.height,
leftWidth = [gSliderTrackLeft size].width,
rightWidth = [gSliderTrackRight size].width,
centerWidth = adjustedSliderRect.size.width - leftWidth - rightWidth,
yOffset = (rectHeight - DefaultSliderBarHeight) / 2;


adjustedRight = adjustedSliderRect.origin.x + adjustedSliderRect.size.width;
leftRect = NSMakeRect(adjustedSliderRect.origin.x, yOffset, leftWidth, DefaultSliderBarHeight);
rightRect = NSMakeRect(adjustedRight - rightWidth, yOffset, rightWidth, DefaultSliderBarHeight);
middleRect = NSMakeRect(leftRect.origin.x + leftRect.size.width, yOffset, centerWidth, DefaultSliderBarHeight);


   minXOrigin        = 10;
   maxXOrigin        = adjustedRight;
}

- (BOOL)_usesCustomTrackImage
{
  return YES;
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40ardendo.se


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40comcast.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Preventing default drawing of slider bar in custom NSSlider class
      • From: Michael Watson <email@hidden>
References: 
 >Preventing default drawing of slider bar in custom NSSlider class (From: Ken Tozier <email@hidden>)
 >Re: Preventing default drawing of slider bar in custom NSSlider class (From: Mikael Gransell <email@hidden>)
 >Re: Preventing default drawing of slider bar in custom NSSlider class (From: Ken Tozier <email@hidden>)
 >Re: Preventing default drawing of slider bar in custom NSSlider class (From: Mikael Gransell <email@hidden>)
 >Re: Preventing default drawing of slider bar in custom NSSlider class (From: Ken Tozier <email@hidden>)
 >Re: Preventing default drawing of slider bar in custom NSSlider class (From: Mikael Gransell <email@hidden>)

  • Prev by Date: Re: Preventing default drawing of slider bar in custom NSSlider class
  • Next by Date: Re: Preventing default drawing of slider bar in custom NSSlider class
  • Previous by thread: Re: Preventing default drawing of slider bar in custom NSSlider class
  • Next by thread: Re: Preventing default drawing of slider bar in custom NSSlider class
  • Index(es):
    • Date
    • Thread