|
@@ -29,9 +29,10 @@ class ActivityView : NSView {
|
|
|
var _titleLbl : NSTextField = NSTextField()
|
|
|
let kActivityTitleHeight = 25.0
|
|
|
|
|
|
- var _activityView : NSView = NSView()
|
|
|
- var _angle : CGFloat = 0
|
|
|
- var _shapeLayer : CAShapeLayer = CAShapeLayer()
|
|
|
+ var _activityView : NSProgressIndicator = NSProgressIndicator()
|
|
|
+// var _activityView : NSView = NSView()
|
|
|
+// var _angle : CGFloat = 0
|
|
|
+// var _shapeLayer : CAShapeLayer = CAShapeLayer()
|
|
|
|
|
|
|
|
|
public override init(frame frameRect: NSRect) {
|
|
@@ -96,30 +97,50 @@ class ActivityView : NSView {
|
|
|
_titleLbl.layer?.borderColor = NSColor.lightGray.cgColor
|
|
|
|
|
|
if nil == _activityView {
|
|
|
- _activityView = NSView.init(frame: self.frame)
|
|
|
+ _activityView = NSProgressIndicator.init(frame: self.bounds)
|
|
|
}
|
|
|
+ _activityView.controlSize = .small
|
|
|
+ _activityView.style = .spinning
|
|
|
if nil == _activityView.superview {
|
|
|
self.addSubview(_activityView)
|
|
|
}
|
|
|
- let activitySize = min(width, height)
|
|
|
+ _activityView.startAnimation(self)
|
|
|
+ let activitySize = kActivityTitleHeight
|
|
|
+// min(_activityView.frame.width, _activityView.frame.height)
|
|
|
_activityView.frame = NSMakeRect((width - activitySize)/2.0,
|
|
|
(height - activitySize)/2.0,
|
|
|
activitySize,
|
|
|
activitySize)
|
|
|
-
|
|
|
- if nil == _shapeLayer {
|
|
|
- _shapeLayer = CAShapeLayer()
|
|
|
- }
|
|
|
- _shapeLayer.frame = _activityView.bounds
|
|
|
- _activityView.wantsLayer = true;
|
|
|
- _activityView.layer?.addSublayer(_shapeLayer)
|
|
|
-
|
|
|
- var mulPath = CGMutablePath()
|
|
|
- mulPath.addArc(center: CGPoint(x: activitySize/2.0, y: activitySize/2.0),
|
|
|
- radius: activitySize/2.0,
|
|
|
- startAngle: _angle+Double.pi/3.0,
|
|
|
- endAngle: _angle, clockwise: true)
|
|
|
- _shapeLayer.path = mulPath
|
|
|
+//
|
|
|
+// if nil == _shapeLayer {
|
|
|
+// _shapeLayer = CAShapeLayer()
|
|
|
+// }
|
|
|
+// _shapeLayer.frame = _activityView.bounds
|
|
|
+// _activityView.wantsLayer = true;
|
|
|
+// _activityView.layer?.addSublayer(_shapeLayer)
|
|
|
+//
|
|
|
+// var mulPath = CGMutablePath()
|
|
|
+// let inRadius = activitySize/2 - 3
|
|
|
+// let outRadius = activitySize/2
|
|
|
+// let endRage = _angle - Double.pi / 3.0
|
|
|
+// mulPath.move(to: CGPointMake(activitySize/2.0 + inRadius*sin(_angle),
|
|
|
+// activitySize/2.0 + inRadius * cos(_angle)))
|
|
|
+// mulPath.addLine(to: CGPointMake(activitySize/2.0 + outRadius*sin(_angle),
|
|
|
+// activitySize/2.0 + outRadius * cos(_angle)))
|
|
|
+// mulPath.addArc(center: CGPoint(x: activitySize/2.0, y: activitySize/2.0),
|
|
|
+// radius: outRadius,
|
|
|
+// startAngle: _angle, endAngle: endRage, clockwise: true)
|
|
|
+// mulPath.addLine(to: CGPointMake(activitySize/2 + inRadius*sin(endRage),
|
|
|
+// activitySize/2 + inRadius * cos(endRage)))
|
|
|
+// mulPath.addArc(center: CGPoint(x: activitySize/2.0, y: activitySize/2.0),
|
|
|
+// radius: inRadius,
|
|
|
+// startAngle: endRage, endAngle: _angle, clockwise: false)
|
|
|
+// _shapeLayer.path = mulPath
|
|
|
+//// _shapeLayer.lineWidth = 5;
|
|
|
+//// _shapeLayer.lineJoin = .bevel
|
|
|
+//// _shapeLayer.lineCap = .square
|
|
|
+//// _shapeLayer.fillRule = .nonZero
|
|
|
+// _shapeLayer.fillColor = NSColor.blue.cgColor
|
|
|
}
|
|
|
|
|
|
/// Update Status
|
|
@@ -139,12 +160,10 @@ class ActivityView : NSView {
|
|
|
_timer = Timer()
|
|
|
}
|
|
|
case .Process: do {
|
|
|
-
|
|
|
- _timer = Timer.init(timeInterval: 1.0/30.0, repeats: true, block: { timer in
|
|
|
- self._angle = self._angle + Double.pi/30.0
|
|
|
-
|
|
|
-
|
|
|
- })
|
|
|
+// _timer = Timer.scheduledTimer(timeInterval: 1.0/30,
|
|
|
+// target: self,
|
|
|
+// selector: #selector(updateAnge),
|
|
|
+// userInfo: nil, repeats: true)
|
|
|
}
|
|
|
case .Finished: do {
|
|
|
_titleLbl.textColor = NSColor.blue
|
|
@@ -164,6 +183,33 @@ class ActivityView : NSView {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// @objc func updateAnge() {
|
|
|
+// _angle = self._angle + Double.pi/30.0
|
|
|
+//
|
|
|
+//
|
|
|
+// let width = self.frame.width
|
|
|
+// let height = self.frame.height
|
|
|
+//
|
|
|
+// let activitySize = min(width, height)
|
|
|
+// var mulPath = CGMutablePath()
|
|
|
+// let inRadius = activitySize/2 - 3
|
|
|
+// let outRadius = activitySize/2
|
|
|
+// let endRage = self._angle - Double.pi / 3.0
|
|
|
+// mulPath.move(to: CGPointMake(activitySize/2.0 + inRadius*sin(self._angle),
|
|
|
+// activitySize/2.0 + inRadius * cos(self._angle)))
|
|
|
+// mulPath.addLine(to: CGPointMake(activitySize/2.0 + outRadius*sin(self._angle),
|
|
|
+// activitySize/2.0 + outRadius * cos(self._angle)))
|
|
|
+// mulPath.addArc(center: CGPoint(x: activitySize/2.0, y: activitySize/2.0),
|
|
|
+// radius: outRadius,
|
|
|
+// startAngle: self._angle, endAngle: endRage, clockwise: true)
|
|
|
+// mulPath.addLine(to: CGPointMake(activitySize/2 + inRadius*sin(endRage),
|
|
|
+// activitySize/2 + inRadius * cos(endRage)))
|
|
|
+// mulPath.addArc(center: CGPoint(x: activitySize/2.0, y: activitySize/2.0),
|
|
|
+// radius: inRadius,
|
|
|
+// startAngle: endRage, endAngle: self._angle, clockwise: false)
|
|
|
+// self._shapeLayer.path = mulPath
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
/// Setter & Getter
|
|
|
///
|