Skip to content

Commit c2e73a2

Browse files
committed
passcode
1 parent a27b2db commit c2e73a2

File tree

13 files changed

+171
-47
lines changed

13 files changed

+171
-47
lines changed

TGUIKit/TGUIKit/ScrollView.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ public enum ScrollDirection {
1414
case none;
1515
}
1616

17-
private class Scroller : NSScroller {
18-
fileprivate override func sendAction(on mask: NSEventMask) -> Int {
19-
return super.sendAction(on: mask)
20-
}
21-
}
17+
2218

2319
public struct ScrollPosition : Equatable {
2420
public private(set) var rect:NSRect
@@ -37,7 +33,6 @@ public func ==(lhs:ScrollPosition, rhs:ScrollPosition) -> Bool {
3733
open class ScrollView: NSScrollView, CALayerDelegate{
3834
private var currentpos:ScrollPosition = ScrollPosition()
3935
public var deltaCorner:Int64 = 60
40-
private var scroller:Scroller?
4136

4237
public var scrollPosition:ScrollPosition {
4338

@@ -99,7 +94,6 @@ open class ScrollView: NSScrollView, CALayerDelegate{
9994
override public init(frame frameRect: NSRect) {
10095
super.init(frame: frameRect)
10196

102-
scroller = Scroller(frame: self.bounds)
10397
self.wantsLayer = true;
10498

10599
self.layer?.delegate = self
@@ -118,6 +112,9 @@ open class ScrollView: NSScrollView, CALayerDelegate{
118112

119113

120114

115+
self.horizontalScroller?.scrollerStyle = .overlay
116+
self.verticalScroller?.scrollerStyle = .overlay
117+
121118
// verticalScrollElasticity = .automatic
122119
//allowsMagnification = true
123120
//self.hasVerticalScroller = false
@@ -126,6 +123,15 @@ open class ScrollView: NSScrollView, CALayerDelegate{
126123

127124
}
128125

126+
open override var scrollerStyle: NSScrollerStyle {
127+
set {
128+
super.scrollerStyle = .overlay
129+
}
130+
get {
131+
return .overlay
132+
}
133+
}
134+
129135

130136
//
131137
// open override var hasVerticalScroller: Bool {

TGUIKit/TGUIKit/SearchView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public class SearchView: OverlayControl, NSTextViewDelegate {
304304
progressIndicator.stopAnimation(self)
305305
progressIndicator.removeFromSuperview()
306306
progressIndicator.isHidden = true
307-
clear.isHidden = self.state == .Focus && (self.input.string ?? "").length == 0
307+
clear.isHidden = self.state == .None
308308
}
309309
}
310310

TGUIKit/TGUIKit/TableView.swift

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,52 +1233,68 @@ open class TableView: ScrollView, NSTableViewDelegate,NSTableViewDataSource,Sele
12331233

12341234
let s = self.frame.size
12351235

1236-
if animated {
1236+
if animated && !tableView.isFlipped {
12371237

12381238

12391239
//if !tableView.isFlipped {
12401240

1241-
let y = (s.height - size.height)
1242-
1243-
CATransaction.begin()
1244-
1245-
// if y < 0 {
1246-
1247-
var presentBounds:NSRect = self.layer?.bounds ?? self.bounds
1248-
var presentation = self.layer?.presentation()
1249-
if let presentation = presentation, self.layer?.animation(forKey:"bounds") != nil {
1241+
1242+
1243+
CATransaction.begin()
1244+
1245+
// if y < 0 {
1246+
1247+
var presentBounds:NSRect = self.layer?.bounds ?? self.bounds
1248+
var presentation = self.layer?.presentation()
1249+
if let presentation = presentation, self.layer?.animation(forKey:"bounds") != nil {
1250+
presentBounds = presentation.bounds
1251+
}
1252+
1253+
self.layer?.animateBounds(from: presentBounds, to: NSMakeRect(0, self.bounds.minY, size.width, size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
1254+
1255+
1256+
var y = (size.height - presentBounds.height)
1257+
1258+
// if (y > 0) {
1259+
presentBounds = contentView.layer?.bounds ?? contentView.bounds
1260+
if let presentation = contentView.layer?.presentation(), contentView.layer?.animation(forKey:"bounds") != nil {
12501261
presentBounds = presentation.bounds
12511262
}
12521263

1253-
self.layer?.animateBounds(from: presentBounds, to: NSMakeRect(0, self.bounds.minY, size.width, size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
1254-
1255-
1256-
1257-
if (y > 0) {
1258-
var presentBounds:NSRect = contentView.layer?.bounds ?? contentView.bounds
1259-
presentation = contentView.layer?.presentation()
1260-
if let presentation = presentation, contentView.layer?.animation(forKey:"bounds") != nil {
1261-
presentBounds = presentation.bounds
1262-
}
1264+
if y > 0 {
1265+
presentBounds.origin.y -= y
12631266
presentBounds.size.height += y
1264-
contentView.layer?.animateBounds(from: presentBounds, to: NSMakeRect(0, contentView.bounds.minY, size.width, size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
1265-
1267+
} else {
1268+
presentBounds.origin.y += y
1269+
presentBounds.size.height -= y
12661270
}
1267-
// }
1268-
if !tableView.isFlipped {
1269-
var currentY:CGFloat = 0
12701271

1271-
presentation = contentView.layer?.presentation()
1272-
if let presentation = presentation, contentView.layer?.animation(forKey:"position") != nil {
1273-
currentY = presentation.position.y
1274-
}
1272+
contentView.layer?.animateBounds(from: presentBounds, to: NSMakeRect(0, contentView.bounds.minY, size.width, size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
12751273

1276-
let pos = contentView.layer?.position ?? NSZeroPoint
1277-
contentView.layer?.animatePosition(from: NSMakePoint(0,currentY + (y > 0 ? -y : y)), to: pos, duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
1278-
}
1274+
// }
1275+
// else if !tableView.isFlipped {
1276+
// var currentY:CGFloat = 0
1277+
//
1278+
// presentation = contentView.layer?.presentation()
1279+
// if let presentation = presentation, contentView.layer?.animation(forKey:"position") != nil {
1280+
// currentY = presentation.position.y
1281+
// }
1282+
//
1283+
// //let realY = abs(size.height - )
1284+
//
1285+
// let pos = contentView.layer?.position ?? NSZeroPoint
1286+
//
1287+
// NSLog("\(currentY) y: \(y)")
1288+
// // if currentY == 0 {
1289+
// // currentY
1290+
// // } else {
1291+
// //
1292+
// // }
1293+
// contentView.layer?.animatePosition(from: NSMakePoint(0, -y), to: pos, duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseOut)
1294+
// }
12791295

12801296

1281-
CATransaction.commit()
1297+
CATransaction.commit()
12821298

12831299
// }
12841300
}

0 commit comments

Comments
 (0)