2015-12-30 18:47:13 -08:00
|
|
|
//
|
|
|
|
|
// HeaderView.swift
|
|
|
|
|
// XIONControlPanel
|
|
|
|
|
//
|
|
|
|
|
// Created by Charles Magahern on 12/30/15.
|
|
|
|
|
// Copyright © 2015 XION. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Darwin
|
|
|
|
|
import Foundation
|
|
|
|
|
import UIKit
|
|
|
|
|
|
2016-07-24 00:14:04 -07:00
|
|
|
class HeaderView: UIView
|
|
|
|
|
{
|
2015-12-31 10:55:54 -08:00
|
|
|
var xionLogoView: XIONLogoView = XIONLogoView()
|
|
|
|
|
var connectionStatusView: ConnectionStatusView = ConnectionStatusView()
|
|
|
|
|
|
2017-05-13 00:40:03 -07:00
|
|
|
fileprivate var _xionTitleLabel: UILabel = UILabel()
|
|
|
|
|
fileprivate var _xionJapaneseLabel: UILabel = UILabel()
|
2015-12-30 18:47:13 -08:00
|
|
|
|
|
|
|
|
override init(frame: CGRect)
|
|
|
|
|
{
|
|
|
|
|
super.init(frame: frame)
|
|
|
|
|
|
2017-05-13 00:40:03 -07:00
|
|
|
self.backgroundColor = UIColor.black
|
2015-12-31 10:55:54 -08:00
|
|
|
self.addSubview(self.xionLogoView)
|
2015-12-30 18:47:13 -08:00
|
|
|
|
|
|
|
|
_xionTitleLabel.font = UIFont(name: "Orbitron-Medium", size: 16.0)
|
|
|
|
|
_xionTitleLabel.text = "XION arcade system control panel"
|
2017-05-13 00:40:03 -07:00
|
|
|
_xionTitleLabel.textColor = UIColor.white
|
2015-12-30 18:47:13 -08:00
|
|
|
self.addSubview(_xionTitleLabel)
|
|
|
|
|
|
|
|
|
|
_xionJapaneseLabel.font = UIFont(name: "Orbitron-Medium", size: 12.0)
|
|
|
|
|
_xionJapaneseLabel.text = "ザイーオンゲームセンターのシステム制御プログラム"
|
2017-05-13 00:40:03 -07:00
|
|
|
_xionJapaneseLabel.textColor = UIColor.white
|
2015-12-30 18:47:13 -08:00
|
|
|
self.addSubview(_xionJapaneseLabel)
|
2015-12-31 10:55:54 -08:00
|
|
|
|
|
|
|
|
self.addSubview(self.connectionStatusView)
|
2015-12-30 18:47:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder)
|
|
|
|
|
{
|
|
|
|
|
fatalError("unsupported")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func layoutSubviews()
|
|
|
|
|
{
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
|
|
let bounds = self.bounds
|
|
|
|
|
let hpadding = CGFloat(10.0)
|
|
|
|
|
|
|
|
|
|
let logoDimensions = rint(bounds.size.height / 1.2)
|
|
|
|
|
let logoFrame = CGRect(
|
|
|
|
|
x: hpadding,
|
|
|
|
|
y: rint(bounds.size.height / 2.0 - logoDimensions / 2.0),
|
|
|
|
|
width: logoDimensions,
|
|
|
|
|
height: logoDimensions
|
|
|
|
|
)
|
2015-12-31 10:55:54 -08:00
|
|
|
self.xionLogoView.frame = logoFrame
|
2015-12-30 18:47:13 -08:00
|
|
|
|
2017-05-13 00:40:03 -07:00
|
|
|
if (self.traitCollection.horizontalSizeClass == .compact) {
|
|
|
|
|
_xionTitleLabel.isHidden = true
|
|
|
|
|
_xionJapaneseLabel.isHidden = true
|
2016-07-24 00:14:04 -07:00
|
|
|
} else {
|
2017-05-13 00:40:03 -07:00
|
|
|
_xionTitleLabel.isHidden = false
|
|
|
|
|
_xionJapaneseLabel.isHidden = false
|
2015-12-30 18:47:13 -08:00
|
|
|
|
2016-07-24 00:14:04 -07:00
|
|
|
let titleJPVerticalMargin: CGFloat = 5.0
|
|
|
|
|
let titleLabelSize = _xionTitleLabel.sizeThatFits(bounds.size)
|
|
|
|
|
let jpLabelSize = _xionJapaneseLabel.sizeThatFits(bounds.size)
|
|
|
|
|
let totalLabelsHeight = titleLabelSize.height + titleJPVerticalMargin + jpLabelSize.height
|
|
|
|
|
|
|
|
|
|
let titleFrame = CGRect(
|
2017-05-13 00:40:03 -07:00
|
|
|
x: logoFrame.maxX + hpadding * 2.0,
|
2016-07-24 00:14:04 -07:00
|
|
|
y: rint(bounds.size.height / 2.0 - totalLabelsHeight / 2.0),
|
|
|
|
|
width: titleLabelSize.width,
|
|
|
|
|
height: titleLabelSize.height
|
|
|
|
|
)
|
|
|
|
|
_xionTitleLabel.frame = titleFrame
|
|
|
|
|
|
|
|
|
|
let jpTitleFrame = CGRect(
|
|
|
|
|
x: titleFrame.origin.x,
|
2017-05-13 00:40:03 -07:00
|
|
|
y: titleFrame.maxY + titleJPVerticalMargin,
|
2016-07-24 00:14:04 -07:00
|
|
|
width: jpLabelSize.width,
|
|
|
|
|
height: jpLabelSize.height + 2.0
|
|
|
|
|
)
|
|
|
|
|
_xionJapaneseLabel.frame = jpTitleFrame
|
|
|
|
|
}
|
2015-12-31 10:55:54 -08:00
|
|
|
|
2016-07-24 00:14:04 -07:00
|
|
|
let connectionStatusDimensions = self.connectionStatusView.sizeThatFits(bounds.size)
|
2015-12-31 10:55:54 -08:00
|
|
|
let connectionStatusFrame = CGRect(
|
2016-07-24 00:14:04 -07:00
|
|
|
x: bounds.size.width - connectionStatusDimensions.width - hpadding,
|
|
|
|
|
y: rint(bounds.size.height / 2.0 - connectionStatusDimensions.height / 2.0),
|
2015-12-31 10:55:54 -08:00
|
|
|
width: connectionStatusDimensions.width,
|
|
|
|
|
height: connectionStatusDimensions.height
|
|
|
|
|
)
|
|
|
|
|
self.connectionStatusView.frame = connectionStatusFrame
|
2015-12-30 18:47:13 -08:00
|
|
|
}
|
|
|
|
|
}
|