Skip to content

Commit 42db05b

Browse files
committed
Use separate header
1 parent 25d695b commit 42db05b

File tree

3 files changed

+44
-68
lines changed

3 files changed

+44
-68
lines changed

Plug-Ins/Dialog Editor/Base.lproj/DialogEditorWindow.xib

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@
2727
<rect key="frame" x="0.0" y="0.0" width="750" height="352"/>
2828
<autoresizingMask key="autoresizingMask"/>
2929
<subviews>
30-
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Fh-0b-ukU">
31-
<rect key="frame" x="0.0" y="19" width="140" height="333"/>
30+
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KAD-4V-AoR">
31+
<rect key="frame" x="10" y="332" width="38" height="16"/>
32+
<textFieldCell key="cell" lineBreakMode="clipping" title="Items" id="KDh-dT-uvo">
33+
<font key="font" metaFont="system"/>
34+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
35+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
36+
</textFieldCell>
37+
</textField>
38+
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Fh-0b-ukU">
39+
<rect key="frame" x="-1" y="19" width="140" height="310"/>
3240
<clipView key="contentView" id="yzF-me-2u9">
33-
<rect key="frame" x="0.0" y="0.0" width="140" height="333"/>
41+
<rect key="frame" x="1" y="1" width="138" height="308"/>
3442
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3543
<subviews>
3644
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" tableStyle="fullWidth" columnReordering="NO" columnResizing="NO" autosaveColumns="NO" rowHeight="19" rowSizeStyle="automatic" viewBased="YES" id="SXP-nf-vKb">
37-
<rect key="frame" x="0.0" y="0.0" width="140" height="333"/>
45+
<rect key="frame" x="0.0" y="0.0" width="138" height="308"/>
3846
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3947
<size key="intercellSpacing" width="4" height="0.0"/>
4048
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -72,7 +80,7 @@
7280
</tableCellView>
7381
</prototypeCellViews>
7482
</tableColumn>
75-
<tableColumn identifier="name" width="102" minWidth="40" maxWidth="1000" id="m5e-Zg-wTM">
83+
<tableColumn identifier="name" width="100" minWidth="40" maxWidth="1000" id="m5e-Zg-wTM">
7684
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
7785
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
7886
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
@@ -85,11 +93,11 @@
8593
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
8694
<prototypeCellViews>
8795
<tableCellView id="zJ9-W4-t1j">
88-
<rect key="frame" x="32" y="0.0" width="106" height="19"/>
96+
<rect key="frame" x="32" y="0.0" width="104" height="19"/>
8997
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
9098
<subviews>
9199
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6E4-he-kXH">
92-
<rect key="frame" x="0.0" y="2" width="106" height="16"/>
100+
<rect key="frame" x="0.0" y="2" width="104" height="16"/>
93101
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
94102
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="yUn-gp-emC">
95103
<font key="font" usesAppearanceFont="YES"/>
@@ -116,7 +124,7 @@
116124
<constraint firstAttribute="width" constant="140" id="9Qj-yE-Qk1"/>
117125
</constraints>
118126
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="HRO-mv-7U2">
119-
<rect key="frame" x="0.0" y="317" width="140" height="16"/>
127+
<rect key="frame" x="1" y="289" width="138" height="16"/>
120128
<autoresizingMask key="autoresizingMask"/>
121129
</scroller>
122130
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="sc9-9d-soM">
@@ -152,21 +160,14 @@ CA
152160
<binding destination="-2" name="enabled" keyPath="hasSelection" id="QVe-k1-K8y"/>
153161
</connections>
154162
</button>
155-
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yy0-Hk-gX9">
156-
<rect key="frame" x="49" y="-2" width="92" height="23"/>
157-
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" enabled="NO" refusesFirstResponder="YES" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="lKy-Oa-6Xm">
158-
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
159-
<font key="font" metaFont="system"/>
160-
</buttonCell>
161-
</button>
162163
<scrollView autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PtH-kU-h2h">
163-
<rect key="frame" x="140" y="-1" width="410" height="354"/>
164+
<rect key="frame" x="138" y="-1" width="412" height="354"/>
164165
<clipView key="contentView" id="Yh0-a6-CPU">
165-
<rect key="frame" x="1" y="1" width="408" height="352"/>
166+
<rect key="frame" x="1" y="1" width="410" height="352"/>
166167
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
167168
<subviews>
168169
<view translatesAutoresizingMaskIntoConstraints="NO" id="z3g-LT-GbE" userLabel="Document View" customClass="DITLDocumentView" customModule="Dialog_Editor" customModuleProvider="target">
169-
<rect key="frame" x="0.0" y="0.0" width="408" height="352"/>
170+
<rect key="frame" x="0.0" y="0.0" width="410" height="352"/>
170171
<constraints>
171172
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="352" id="2ok-LD-llg"/>
172173
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="408" id="bug-DB-Y7b"/>
@@ -590,22 +591,22 @@ CA
590591
<constraint firstItem="xEy-8p-fqk" firstAttribute="top" secondItem="18" secondAttribute="top" id="178-XT-t9W"/>
591592
<constraint firstAttribute="bottom" secondItem="hZi-eC-nKL" secondAttribute="bottom" constant="-1" id="3vd-q5-L9g"/>
592593
<constraint firstItem="InT-xk-iKM" firstAttribute="height" secondItem="hZi-eC-nKL" secondAttribute="height" id="4XN-ni-bAs"/>
593-
<constraint firstItem="7Fh-0b-ukU" firstAttribute="leading" secondItem="18" secondAttribute="leading" id="DV1-Hg-HVY"/>
594+
<constraint firstItem="7Fh-0b-ukU" firstAttribute="leading" secondItem="18" secondAttribute="leading" constant="-1" id="DV1-Hg-HVY"/>
594595
<constraint firstItem="PtH-kU-h2h" firstAttribute="top" secondItem="18" secondAttribute="top" constant="-1" id="FJ2-HP-YCk"/>
595-
<constraint firstItem="yy0-Hk-gX9" firstAttribute="leading" secondItem="InT-xk-iKM" secondAttribute="trailing" constant="-1" id="HvH-Lx-z08"/>
596+
<constraint firstItem="SXP-nf-vKb" firstAttribute="top" secondItem="KAD-4V-AoR" secondAttribute="bottom" constant="4" id="IOX-o4-Kfb"/>
597+
<constraint firstItem="KAD-4V-AoR" firstAttribute="leading" secondItem="18" secondAttribute="leading" constant="12" id="Nmc-th-jHQ"/>
596598
<constraint firstItem="xEy-8p-fqk" firstAttribute="leading" secondItem="PtH-kU-h2h" secondAttribute="trailing" id="O8s-I2-Emi"/>
597-
<constraint firstItem="PtH-kU-h2h" firstAttribute="leading" secondItem="7Fh-0b-ukU" secondAttribute="trailing" id="R1g-iK-nwg"/>
599+
<constraint firstItem="PtH-kU-h2h" firstAttribute="leading" secondItem="7Fh-0b-ukU" secondAttribute="trailing" constant="-1" id="R1g-iK-nwg"/>
598600
<constraint firstItem="InT-xk-iKM" firstAttribute="leading" secondItem="hZi-eC-nKL" secondAttribute="trailing" constant="-1" id="T9d-zx-bFo"/>
599-
<constraint firstItem="yy0-Hk-gX9" firstAttribute="centerY" secondItem="hZi-eC-nKL" secondAttribute="centerY" id="XY9-zz-DqW"/>
600601
<constraint firstItem="InT-xk-iKM" firstAttribute="width" secondItem="hZi-eC-nKL" secondAttribute="width" id="ZBM-ZH-i2x"/>
601602
<constraint firstAttribute="bottom" secondItem="xEy-8p-fqk" secondAttribute="bottom" id="bYy-Of-dAK"/>
602-
<constraint firstItem="yy0-Hk-gX9" firstAttribute="height" secondItem="hZi-eC-nKL" secondAttribute="height" id="e5x-ER-9fE"/>
603+
<constraint firstItem="z3g-LT-GbE" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="KAD-4V-AoR" secondAttribute="trailing" constant="12" id="dQV-yG-Tvv"/>
603604
<constraint firstAttribute="trailing" secondItem="xEy-8p-fqk" secondAttribute="trailing" id="fku-Hg-YAz"/>
604605
<constraint firstAttribute="bottom" secondItem="PtH-kU-h2h" secondAttribute="bottom" constant="-1" id="uj4-vb-8rd"/>
605606
<constraint firstItem="hZi-eC-nKL" firstAttribute="leading" secondItem="18" secondAttribute="leading" constant="-1" id="vA7-0M-2VA"/>
606607
<constraint firstItem="hZi-eC-nKL" firstAttribute="top" secondItem="7Fh-0b-ukU" secondAttribute="bottom" constant="-1" id="vdC-fW-KbV"/>
607-
<constraint firstItem="7Fh-0b-ukU" firstAttribute="top" secondItem="18" secondAttribute="top" id="wd0-sS-4bu"/>
608-
<constraint firstItem="yy0-Hk-gX9" firstAttribute="trailing" secondItem="7Fh-0b-ukU" secondAttribute="trailing" constant="1" id="yJ2-Yl-68B"/>
608+
<constraint firstItem="KAD-4V-AoR" firstAttribute="top" secondItem="18" secondAttribute="top" constant="4" id="vxa-QN-vQz"/>
609+
<constraint firstItem="z3g-LT-GbE" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="InT-xk-iKM" secondAttribute="trailing" constant="-1" id="zOz-ti-fks"/>
609610
</constraints>
610611
</view>
611612
<point key="canvasLocation" x="202" y="324"/>

Plug-Ins/Dialog Editor/DITLDocumentView.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ class DITLDocumentView: NSView {
3131
}
3232

3333
override func mouseDown(with event: NSEvent) {
34-
let selection = items.filter(\.selected)
35-
for item in selection {
36-
item.selected = false
37-
}
38-
if !selection.isEmpty {
39-
controller?.selectionDidChange()
40-
}
34+
controller?.deselectAll(self)
4135
}
4236

4337
func updateMinSize() {

Plug-Ins/Dialog Editor/DialogEditorWindowController.swift

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DialogEditorWindowController: AbstractEditor, ResourceEditor {
6464
isSelectingItems = true
6565
let indices = items.enumerated()
6666
.filter { $0.1.selected }
67-
.map { $0.0 + 1 }
67+
.map { $0.0 }
6868
itemList.selectRowIndexes(IndexSet(indices), byExtendingSelection: false)
6969
self.reflectSelectedItem()
7070
isSelectingItems = false
@@ -161,20 +161,14 @@ class DialogEditorWindowController: AbstractEditor, ResourceEditor {
161161
createItem?.title = NSLocalizedString("Create New Resource…", comment: "")
162162
}
163163

164-
@IBAction func deselectAll(_ sender: Any?) {
165-
for item in items where item.selected {
166-
item.selected = false
167-
}
168-
self.selectionDidChange()
169-
}
170-
171164
override func selectAll(_ sender: Any?) {
172-
for item in items where !item.selected {
173-
item.selected = true
174-
}
175-
self.selectionDidChange()
165+
itemList.selectAll(sender)
176166
}
177-
167+
168+
func deselectAll(_ sender: Any?) {
169+
itemList.deselectAll(sender)
170+
}
171+
178172
@IBAction func createNewItem(_ sender: Any?) {
179173
var newItems = items
180174
let newItem = DITLItemView(frame: NSRect(x: 10, y: 10, width: 80, height: 20), text: "Button", type: .button, manager: manager)
@@ -208,28 +202,18 @@ class DialogEditorWindowController: AbstractEditor, ResourceEditor {
208202

209203
extension DialogEditorWindowController: NSTableViewDelegate, NSTableViewDataSource {
210204
func numberOfRows(in tableView: NSTableView) -> Int {
211-
items.count + 1
212-
}
213-
214-
func tableView(_ tableView: NSTableView, isGroupRow row: Int) -> Bool {
215-
row == 0
216-
}
217-
218-
func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
219-
row != 0
205+
items.count
220206
}
221207

222208
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
223-
let identifier = tableColumn?.identifier ?? NSUserInterfaceItemIdentifier("name")
224-
let view = tableView.makeView(withIdentifier: identifier, owner: self) as! NSTableCellView
225-
if tableColumn?.identifier.rawValue == "num" {
209+
guard let tableColumn else { return nil }
210+
let view = tableView.makeView(withIdentifier: tableColumn.identifier, owner: self) as! NSTableCellView
211+
if tableColumn.identifier.rawValue == "num" {
226212
view.textField?.integerValue = row
227-
} else if tableColumn?.identifier.rawValue == "name" {
228-
let item = items[row - 1]
213+
} else if tableColumn.identifier.rawValue == "name" {
214+
let item = items[row]
229215
view.textField?.placeholderString = item.type.name
230216
view.textField?.stringValue = item.text
231-
} else {
232-
view.textField?.stringValue = "Items"
233217
}
234218
return view
235219
}
@@ -239,25 +223,22 @@ extension DialogEditorWindowController: NSTableViewDelegate, NSTableViewDataSour
239223
return
240224
}
241225
for (i, item) in items.enumerated() {
242-
item.selected = itemList.isRowSelected(i + 1)
226+
item.selected = itemList.isRowSelected(i)
243227
}
244228
self.reflectSelectedItem()
245229

246230
// If single item selected, scroll to it
247231
if itemList.selectedRowIndexes.count == 1 {
248-
let item = items[itemList.selectedRow - 1]
232+
let item = items[itemList.selectedRow]
249233
item.scrollToVisible(item.bounds.insetBy(dx: -4, dy: -4))
250234
}
251235
}
252236

253237
// MARK: - Drag and drop
254238

255239
func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> (any NSPasteboardWriting)? {
256-
guard row != 0 else {
257-
return nil
258-
}
259240
let item = NSPasteboardItem()
260-
item.setString("\(row - 1)", forType: .RFDialogItem)
241+
item.setString("\(row)", forType: .RFDialogItem)
261242
return item
262243
}
263244

@@ -275,7 +256,7 @@ extension DialogEditorWindowController: NSTableViewDelegate, NSTableViewDataSour
275256
let indexes = pbItems.compactMap({ $0.string(forType: .RFDialogItem) }).compactMap(Int.init)
276257

277258
var newItems = items
278-
newItems.move(fromOffsets: IndexSet(indexes), toOffset: row - 1)
259+
newItems.move(fromOffsets: IndexSet(indexes), toOffset: row)
279260
self.undoRedoItems(newItems, selectDiff: false)
280261

281262
return true

0 commit comments

Comments
 (0)