1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- //
- // KMBotaLeftView.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/11/22.
- //
- import Cocoa
- class KMBotaLeftView: NSView {
- var segmentedControl: KMSegmentedControl = {
- let view = KMSegmentedControl()
- return view
- }()
-
- override init(frame frameRect: NSRect) {
- super.init(frame: frameRect)
-
- self.initSubview()
- self.initDefaultValue()
- }
-
- required init?(coder: NSCoder) {
- super.init(coder: coder)
-
- self.initSubview()
- self.initDefaultValue()
- }
-
- func initSubview() {
- self.addSubview(self.segmentedControl)
- }
-
- func initDefaultValue() {
- self.segmentedControl.direction = .vertical
- self.segmentedControl.setSegmentCount(5, with: 44)
- self.segmentedControl.setImage(NSImage(named: KMImageNameUXIconSidetabbarThumbnailNor)!, for: 0)
- self.segmentedControl.setImage(NSImage(named: KMImageNameUXIconSidetabbarOutlineNor)!, for: 1)
- self.segmentedControl.setImage(NSImage(named: KMImageNameUXIconSidetabbarAnnotationNor)!, for: 2)
- self.segmentedControl.setImage(NSImage(named: KMImageNameUXIconSidetabbarSnapshotNor)!, for: 3)
- self.segmentedControl.setImage(NSImage(named: KMImageNameUXIconSidetabbarSearchNor)!, for: 4)
- self.segmentedControl.setToolTip(KMLocalizedString("View Thumbnails", nil), for: 0)
- self.segmentedControl.setToolTip(KMLocalizedString("View Outline", nil), for: 1)
- self.segmentedControl.setToolTip(KMLocalizedString("View Notes", nil), for: 2)
- self.segmentedControl.setToolTip(KMLocalizedString("View Snapshots", nil), for: 3)
- self.segmentedControl.setToolTip(KMLocalizedString("Search", nil), for: 4)
- self.segmentedControl.selectedSegment = UInt8.max
- self.segmentedControl.wantsLayer = true
- self.segmentedControl.layer?.backgroundColor = KMAppearance.Layout.l_1Color().cgColor
- }
-
- override func layout() {
- super.layout()
-
- self.segmentedControl.frame = self.bounds
- }
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- }
-
- override func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
- super.interfaceThemeDidChanged(appearance)
-
- self.segmentedControl.appearance = .init(named: appearance)
- self.segmentedControl.wantsLayer = true
- // self.segmentedControl.layer?.backgroundColor = KMAppearance.Layout.l_1Color().cgColor
- if KMAppearance.isDarkMode() {
- self.segmentedControl.layer?.backgroundColor = NSColor.km_init(hex: "#393B3E", alpha: 1).cgColor
- } else {
- self.segmentedControl.layer?.backgroundColor = NSColor.km_init(hex: "#EBECF0", alpha: 1).cgColor
- }
- }
- }
|