Revision: 12393 http://sourceforge.net/p/skim-app/code/12393 Author: hofman Date: 2021-07-16 14:06:52 +0000 (Fri, 16 Jul 2021) Log Message: ----------- Override drawingRectForBounds: for centered text field cell
Modified Paths: -------------- trunk/SKCenteredTextFieldCell.m Modified: trunk/SKCenteredTextFieldCell.m =================================================================== --- trunk/SKCenteredTextFieldCell.m 2021-07-14 14:42:20 UTC (rev 12392) +++ trunk/SKCenteredTextFieldCell.m 2021-07-16 14:06:52 UTC (rev 12393) @@ -38,26 +38,14 @@ #import "SKCenteredTextFieldCell.h" -#define TEXT_OFFSET 1.0 @implementation SKCenteredTextFieldCell -- (NSRect)centeredFrame:(NSRect)cellFrame inView:(NSView *)view { - CGFloat height = [self cellSizeForBounds:cellFrame].height; - if (height < NSHeight(cellFrame)) { - cellFrame.origin.y += floor(0.5 * (NSHeight(cellFrame) - height)); - cellFrame.origin.y += [view isFlipped] ? TEXT_OFFSET : -TEXT_OFFSET; - cellFrame.size.height = height; - } - return cellFrame; +- (NSRect)drawingRectForBounds:(NSRect)rect { + CGFloat height = [self cellSizeForBounds:rect].height; + if (height < NSHeight(rect)) + rect = NSInsetRect(rect, 0.0, 0.5 * (NSHeight(rect) - height)); + return [super drawingRectForBounds:rect]; } -- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { - [super drawInteriorWithFrame:[self centeredFrame:cellFrame inView:controlView] inView:controlView]; -} - -- (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view { - return [super expansionFrameWithFrame:[self centeredFrame:cellFrame inView:view] inView:view]; -} - @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit