Revision: 15672 http://sourceforge.net/p/skim-app/code/15672 Author: hofman Date: 2025-08-17 16:38:37 +0000 (Sun, 17 Aug 2025) Log Message: ----------- Move level indicator call code to view class files
Modified Paths: -------------- trunk/SKLevelIndicator.h trunk/SKLevelIndicator.m trunk/Skim.xcodeproj/project.pbxproj Removed Paths: ------------- trunk/SKLevelIndicatorCell.h trunk/SKLevelIndicatorCell.m Modified: trunk/SKLevelIndicator.h =================================================================== --- trunk/SKLevelIndicator.h 2025-08-17 16:33:02 UTC (rev 15671) +++ trunk/SKLevelIndicator.h 2025-08-17 16:38:37 UTC (rev 15672) @@ -2,11 +2,11 @@ // SKLevelIndicator.h // Skim // -// Created by Christiaan Hofman on 19/04/2019. +// Created by Christiaan Hofman on 10/31/08. /* - This software is Copyright (c) 2019 + This software is Copyright (c) 2007 Christiaan Hofman. All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,3 +41,7 @@ @interface SKLevelIndicator : NSLevelIndicator @end + + +@interface SKLevelIndicatorCell : NSLevelIndicatorCell +@end Modified: trunk/SKLevelIndicator.m =================================================================== --- trunk/SKLevelIndicator.m 2025-08-17 16:33:02 UTC (rev 15671) +++ trunk/SKLevelIndicator.m 2025-08-17 16:38:37 UTC (rev 15672) @@ -2,11 +2,11 @@ // SKLevelIndicator.m // Skim // -// Created by Christiaan Hofman on 19/04/2019. +// Created by Christiaan Hofman on 10/31/08. /* - This software is Copyright (c) 2019 + This software is Copyright (c) 2007 Christiaan Hofman. All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -37,7 +37,7 @@ */ #import "SKLevelIndicator.h" -#import "SKLevelIndicatorCell.h" +#import "NSGeometry_SKExtensions.h" @implementation SKLevelIndicator @@ -50,3 +50,74 @@ } @end + +#pragma mark - + +@implementation SKLevelIndicatorCell + +#define EDGE_HEIGHT 4.0 + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { + BOOL drawDiscreteContinuous = ([self levelIndicatorStyle] == NSDiscreteCapacityLevelIndicatorStyle) && (NSWidth(cellFrame) + 1.0 < 3.0 * [self maxValue]); + if (drawDiscreteContinuous) + [self setLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle]; + CGFloat cellHeight = [self cellSize].height; + if (fabs(NSHeight(cellFrame) - cellHeight) <= 0.0) { + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; + [super drawWithFrame:cellFrame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + } else if (NSHeight(cellFrame) <= 2.0 * (cellHeight - EDGE_HEIGHT)) { + NSRect topFrame, bottomFrame, frame = cellFrame; + NSDivideRect(cellFrame, &topFrame, &bottomFrame, floor(0.5 * NSHeight(cellFrame)), NSMinYEdge); + frame.size.height = cellHeight; + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:topFrame] addClip]; + [super drawWithFrame:frame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; + frame.origin.y = NSMaxY(bottomFrame) - cellHeight; + [super drawWithFrame:frame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + } else { + NSRect topFrame, bottomFrame, restFrame, frame = cellFrame, midFrame; + NSDivideRect(cellFrame, &topFrame, &bottomFrame, cellHeight - EDGE_HEIGHT, NSMinYEdge); + NSDivideRect(bottomFrame, &bottomFrame, &restFrame, cellHeight - EDGE_HEIGHT, NSMaxYEdge); + frame.size.height = cellHeight; + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:topFrame] addClip]; + [super drawWithFrame:frame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + do { + NSDivideRect(restFrame, &midFrame, &restFrame, fmin(cellHeight - 2.0 * EDGE_HEIGHT, NSHeight(restFrame)), NSMinYEdge); + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:midFrame] addClip]; + frame.origin.y = NSMinY(midFrame) - EDGE_HEIGHT; + [super drawWithFrame:frame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + } while (NSHeight(restFrame) > 0.0); + frame.origin.y = NSMaxY(bottomFrame) - cellHeight; + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; + [super drawWithFrame:frame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + } + if (drawDiscreteContinuous) + [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; +} + +- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle { + if (@available(macOS 10.14, *)) { + if ([self levelIndicatorStyle] == NSLevelIndicatorStyleRelevancy && [[self controlView] isKindOfClass:[NSLevelIndicator class]]) { + if (backgroundStyle == NSBackgroundStyleEmphasized) + [[self controlView] setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; + else + [[self controlView] setAppearance:nil]; + } + } + [super setBackgroundStyle:backgroundStyle]; +} + +@end + Deleted: trunk/SKLevelIndicatorCell.h =================================================================== --- trunk/SKLevelIndicatorCell.h 2025-08-17 16:33:02 UTC (rev 15671) +++ trunk/SKLevelIndicatorCell.h 2025-08-17 16:38:37 UTC (rev 15672) @@ -1,43 +0,0 @@ -// -// SKLevelIndicatorCell.h -// Skim -// -// Created by Christiaan Hofman on 10/31/08. -/* - This software is Copyright (c) 2007 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <Cocoa/Cocoa.h> - - -@interface SKLevelIndicatorCell : NSLevelIndicatorCell -@end Deleted: trunk/SKLevelIndicatorCell.m =================================================================== --- trunk/SKLevelIndicatorCell.m 2025-08-17 16:33:02 UTC (rev 15671) +++ trunk/SKLevelIndicatorCell.m 2025-08-17 16:38:37 UTC (rev 15672) @@ -1,108 +0,0 @@ -// -// SKLevelIndicatorCell.m -// Skim -// -// Created by Christiaan Hofman on 10/31/08. -/* - This software is Copyright (c) 2007 - Christiaan Hofman. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SKLevelIndicatorCell.h" -#import "NSGeometry_SKExtensions.h" - -#define EDGE_HEIGHT 4.0 - -@implementation SKLevelIndicatorCell - -- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { - BOOL drawDiscreteContinuous = ([self levelIndicatorStyle] == NSDiscreteCapacityLevelIndicatorStyle) && (NSWidth(cellFrame) + 1.0 < 3.0 * [self maxValue]); - if (drawDiscreteContinuous) - [self setLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle]; - CGFloat cellHeight = [self cellSize].height; - if (fabs(NSHeight(cellFrame) - cellHeight) <= 0.0) { - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; - [super drawWithFrame:cellFrame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - } else if (NSHeight(cellFrame) <= 2.0 * (cellHeight - EDGE_HEIGHT)) { - NSRect topFrame, bottomFrame, frame = cellFrame; - NSDivideRect(cellFrame, &topFrame, &bottomFrame, floor(0.5 * NSHeight(cellFrame)), NSMinYEdge); - frame.size.height = cellHeight; - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:topFrame] addClip]; - [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; - frame.origin.y = NSMaxY(bottomFrame) - cellHeight; - [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - } else { - NSRect topFrame, bottomFrame, restFrame, frame = cellFrame, midFrame; - NSDivideRect(cellFrame, &topFrame, &bottomFrame, cellHeight - EDGE_HEIGHT, NSMinYEdge); - NSDivideRect(bottomFrame, &bottomFrame, &restFrame, cellHeight - EDGE_HEIGHT, NSMaxYEdge); - frame.size.height = cellHeight; - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:topFrame] addClip]; - [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - do { - NSDivideRect(restFrame, &midFrame, &restFrame, fmin(cellHeight - 2.0 * EDGE_HEIGHT, NSHeight(restFrame)), NSMinYEdge); - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:midFrame] addClip]; - frame.origin.y = NSMinY(midFrame) - EDGE_HEIGHT; - [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - } while (NSHeight(restFrame) > 0.0); - frame.origin.y = NSMaxY(bottomFrame) - cellHeight; - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; - [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - } - if (drawDiscreteContinuous) - [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; -} - -- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle { - if (@available(macOS 10.14, *)) { - if ([self levelIndicatorStyle] == NSLevelIndicatorStyleRelevancy && [[self controlView] isKindOfClass:[NSLevelIndicator class]]) { - if (backgroundStyle == NSBackgroundStyleEmphasized) - [[self controlView] setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; - else - [[self controlView] setAppearance:nil]; - } - } - [super setBackgroundStyle:backgroundStyle]; -} - -@end Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2025-08-17 16:33:02 UTC (rev 15671) +++ trunk/Skim.xcodeproj/project.pbxproj 2025-08-17 16:38:37 UTC (rev 15672) @@ -252,7 +252,6 @@ CEDB6A7A228F596000F93C87 /* SKColorPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = CEDB6A78228F596000F93C87 /* SKColorPicker.m */; }; CEDC7B1A2913CD2500032269 /* SKLoupeController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEDC7B192913CD2500032269 /* SKLoupeController.m */; }; CEDE68E5201FDCB5000D881A /* SKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = CEDE68E3201FDCB4000D881A /* SKKeychain.m */; }; - CEE0F5EB0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */; }; CEE106150BCBB72C00BF2D3E /* SKNotesDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE106140BCBB72C00BF2D3E /* SKNotesDocument.m */; }; CEE176E40DBD5B0C00E6C317 /* PDFDocumentView_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE176E30DBD5B0C00E6C317 /* PDFDocumentView_SKExtensions.m */; }; CEE229390BFB7CE9002B746B /* ReleaseNotes.rtf in Resources */ = {isa = PBXBuildFile; fileRef = CE54AA8E0BBC037400008750 /* ReleaseNotes.rtf */; }; @@ -1196,8 +1195,6 @@ CEDC7B192913CD2500032269 /* SKLoupeController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SKLoupeController.m; sourceTree = "<group>"; }; CEDE68E3201FDCB4000D881A /* SKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKKeychain.m; sourceTree = "<group>"; }; CEDE68E4201FDCB4000D881A /* SKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKKeychain.h; sourceTree = "<group>"; }; - CEE0F5E90EBB3DEC000A7A8C /* SKLevelIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKLevelIndicatorCell.h; sourceTree = "<group>"; }; - CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKLevelIndicatorCell.m; sourceTree = "<group>"; }; CEE106130BCBB72C00BF2D3E /* SKNotesDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKNotesDocument.h; sourceTree = "<group>"; }; CEE106140BCBB72C00BF2D3E /* SKNotesDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKNotesDocument.m; sourceTree = "<group>"; }; CEE176E20DBD5B0C00E6C317 /* PDFDocumentView_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFDocumentView_SKExtensions.h; sourceTree = "<group>"; }; @@ -1881,8 +1878,6 @@ CE454B50226E33150034FD6B /* SKHighlightingTableRowView.m */, CE792F72226D12C40005BE9F /* SKLevelIndicator.h */, CE792F73226D12C40005BE9F /* SKLevelIndicator.m */, - CEE0F5E90EBB3DEC000A7A8C /* SKLevelIndicatorCell.h */, - CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */, CE4BC12D0C357A0300C2AF03 /* SKLineWell.h */, CE4BC12E0C357A0300C2AF03 /* SKLineWell.m */, CEA575CC0B9206E60003D2E7 /* SKNoteOutlineView.h */, @@ -2944,7 +2939,6 @@ CE05A86F0E90ED950060BB07 /* SKTextFieldSheetController.m in Sources */, CEAA8F2F0EA2A86200C16FE4 /* SKNoteText.m in Sources */, CE7611650EA49D1400301E45 /* SKPrintableView.m in Sources */, - CEE0F5EB0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m in Sources */, CE0A3C8E0EBF3AAA00526C74 /* NSResponder_SKExtensions.m in Sources */, CE19E7A9275B7BC1007EBD8B /* SKDisplayPrefs.m in Sources */, CE32531F0F4723EA0021BADD /* SKMainWindowController_Actions.m in Sources */, 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