Modified panel UI
This commit is contained in:
Binary file not shown.
@@ -20,8 +20,8 @@
|
||||
73B2C7C027355B030053A44D /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731C6C6D25724025002E9709 /* OverlayView.swift */; };
|
||||
73B2C7C127355B060053A44D /* LibUniWinC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B2C7BC273559C80053A44D /* LibUniWinC.swift */; };
|
||||
73B2C7C52736ACE00053A44D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B2C7C42736ACE00053A44D /* AppDelegate.swift */; };
|
||||
73FC88632753777D0024BABB /* PanelWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73FC88622753777D0024BABB /* PanelWrapper.swift */; };
|
||||
73FC886427537FEC0024BABB /* PanelWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73FC88622753777D0024BABB /* PanelWrapper.swift */; };
|
||||
73FC88632753777D0024BABB /* CustomPanelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73FC88622753777D0024BABB /* CustomPanelHelper.swift */; };
|
||||
73FC886427537FEC0024BABB /* CustomPanelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73FC88622753777D0024BABB /* CustomPanelHelper.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -60,7 +60,7 @@
|
||||
73B2C7C42736ACE00053A44D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
73DFCB7722B8ED3300DA41F2 /* LibUniWinC.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LibUniWinC.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
73DFCB7A22B8ED3300DA41F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
73FC88622753777D0024BABB /* PanelWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanelWrapper.swift; sourceTree = "<group>"; };
|
||||
73FC88622753777D0024BABB /* CustomPanelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPanelHelper.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -163,7 +163,7 @@
|
||||
73575EF822BE18B200E9F019 /* LibUniWinC.mm */,
|
||||
7306572424F1F87900FAB8BC /* README.md */,
|
||||
731C6C6D25724025002E9709 /* OverlayView.swift */,
|
||||
73FC88622753777D0024BABB /* PanelWrapper.swift */,
|
||||
73FC88622753777D0024BABB /* CustomPanelHelper.swift */,
|
||||
);
|
||||
path = LibUniWinC;
|
||||
sourceTree = "<group>";
|
||||
@@ -352,7 +352,7 @@
|
||||
73B2C7C127355B060053A44D /* LibUniWinC.swift in Sources */,
|
||||
73B2C793273559A60053A44D /* DebugUniWinCApp.swift in Sources */,
|
||||
73B2C7C52736ACE00053A44D /* AppDelegate.swift in Sources */,
|
||||
73FC886427537FEC0024BABB /* PanelWrapper.swift in Sources */,
|
||||
73FC886427537FEC0024BABB /* CustomPanelHelper.swift in Sources */,
|
||||
73B2C7C027355B030053A44D /* OverlayView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -378,7 +378,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
73FC88632753777D0024BABB /* PanelWrapper.swift in Sources */,
|
||||
73FC88632753777D0024BABB /* CustomPanelHelper.swift in Sources */,
|
||||
73B2C7BD273559C80053A44D /* LibUniWinC.swift in Sources */,
|
||||
731C6C6E25724025002E9709 /* OverlayView.swift in Sources */,
|
||||
73575EF922BE18B200E9F019 /* LibUniWinC.mm in Sources */,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// OpenPanel.swift
|
||||
// CustomPanelHelper.swift
|
||||
// LibUniWinC
|
||||
//
|
||||
// Created by owner on 2021/11/28.
|
||||
@@ -9,11 +9,11 @@
|
||||
import Cocoa
|
||||
import AppKit
|
||||
|
||||
class PanelWrapper {
|
||||
class CustomPanelHelper {
|
||||
public let panel : NSSavePanel
|
||||
let customAccessoryView = NSView(frame: NSRect(x:0, y:0, width:300, height:40))
|
||||
var popup = NSPopUpButton(frame: NSRect(x:100, y:5, width:200, height:25))
|
||||
var label = NSTextField(frame: NSRect(x: 10, y:5, width: 80, height:25))
|
||||
let customAccessoryView = NSView(frame: NSRect(x:0, y:0, width:400, height:40))
|
||||
var popup = NSPopUpButton(frame: NSRect(x:80, y:5, width:300, height:25))
|
||||
var label = NSTextField(frame: NSRect(x: 10, y:3, width: 70, height:25))
|
||||
var shouldAddSubView : Bool = false
|
||||
var extArray : [[String]?] = []
|
||||
|
||||
@@ -22,16 +22,15 @@ class PanelWrapper {
|
||||
self.panel = panel
|
||||
|
||||
customAccessoryView.autoresizingMask = [.width, .height]
|
||||
popup.autoresizingMask = [.width, .height]
|
||||
//popup.autoresizingMask = [.width, .height]
|
||||
|
||||
label.stringValue = "File type : "
|
||||
//label.string = "File type : "
|
||||
label.alignment = NSTextAlignment.right
|
||||
//label.alignment = NSTextAlignment.right
|
||||
label.isBordered = false
|
||||
label.isSelectable = false
|
||||
label.isEditable = false
|
||||
label.backgroundColor = NSColor.clear
|
||||
label.textColor = NSColor.white
|
||||
|
||||
popup.pullsDown = false
|
||||
popup.action = #selector(onFileTypeChanged(_:))
|
||||
@@ -74,6 +73,7 @@ class PanelWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a file type filter
|
||||
@objc func onFileTypeChanged(_ sender: Any?) {
|
||||
panel.allowedFileTypes = extArray[popup.indexOfSelectedItem]
|
||||
}
|
||||
@@ -968,7 +968,7 @@ public class LibUniWinC : NSObject {
|
||||
/// - bufferSize: Size of UTF-16 string buffer
|
||||
@objc public static func openFilePanel(lpSettings: UnsafeRawPointer, lpBuffer: UnsafeMutablePointer<UniChar>?, bufferSize: UInt32) -> Bool {
|
||||
let panel = NSOpenPanel()
|
||||
let panelUtil = PanelWrapper(panel: panel)
|
||||
let panelHelper = CustomPanelHelper(panel: panel)
|
||||
|
||||
let pPanelSettings = lpSettings.bindMemory(to: PanelSettings.self, capacity: MemoryLayout<PanelSettings>.size)
|
||||
let ps = pPanelSettings.pointee
|
||||
@@ -982,7 +982,7 @@ public class LibUniWinC : NSObject {
|
||||
panel.allowsMultipleSelection = PanelFlag.AllowMultipleSelection.containedIn(value: ps.flags)
|
||||
panel.showsHiddenFiles = PanelFlag.ShowHidden.containedIn(value: ps.flags)
|
||||
//panel.allowedFileTypes = fileTypes
|
||||
panelUtil.addFileTypes(text: getStringFromUtf16Array(textPointer: ps.filterText))
|
||||
panelHelper.addFileTypes(text: getStringFromUtf16Array(textPointer: ps.filterText))
|
||||
panel.isAccessoryViewDisclosed = true // これをしないと Options ボタンを押すまでファイルタイプ選択が出ない
|
||||
|
||||
panel.message = getStringFromUtf16Array(textPointer: ps.titleText)
|
||||
@@ -1040,7 +1040,7 @@ public class LibUniWinC : NSObject {
|
||||
/// - bufferSize: Size of UTF-16 string buffer
|
||||
@objc public static func openSavePanel(lpSettings: UnsafeRawPointer, lpBuffer: UnsafeMutablePointer<UniChar>?, bufferSize: UInt32) -> Bool {
|
||||
let panel = NSSavePanel()
|
||||
let panelUtil = PanelWrapper(panel: panel)
|
||||
let panelHelper = CustomPanelHelper(panel: panel)
|
||||
|
||||
let pPanelSettings = lpSettings.bindMemory(to: PanelSettings.self, capacity: MemoryLayout<PanelSettings>.size)
|
||||
let ps = pPanelSettings.pointee;
|
||||
@@ -1061,7 +1061,7 @@ public class LibUniWinC : NSObject {
|
||||
}
|
||||
panel.nameFieldStringValue = initialFile.lastPathComponent
|
||||
//panel.allowedFileTypes = fileTypes
|
||||
panelUtil.addFileTypes(text: getStringFromUtf16Array(textPointer: ps.filterText))
|
||||
panelHelper.addFileTypes(text: getStringFromUtf16Array(textPointer: ps.filterText))
|
||||
panel.allowsOtherFileTypes = true
|
||||
|
||||
panel.canCreateDirectories = true //PanelFlag.CanCreateDirectories.containedIn(value: ps.flags)
|
||||
|
||||
Reference in New Issue
Block a user