mirror of
https://github.com/libretro/RetroArch
synced 2025-02-22 03:40:43 +00:00
* Fetch translations from Crowdin * Support for showing and hiding indicator and navigation bar * Refactored to use a view model * Support defining helper bar items and support showing/hiding keyboard * reorganized source files into separate logical files * Moved mouse support to swift (except for delegate implementation), added support for enabling touch mouse in helper bar; reorganized swift source files * Reorganized keyboard files; added the touch mouse messages to the RA localization files; use the RA notification system * change keyboard letters to uppercase for clarity Co-authored-by: github-actions <github-actions@github.com>
54 lines
1.7 KiB
Swift
54 lines
1.7 KiB
Swift
//
|
|
// KeyboardButton.swift
|
|
// RetroArchiOS
|
|
//
|
|
// Created by Yoshi Sugawara on 3/3/22.
|
|
// Copyright © 2022 RetroArch. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class EmulatorKeyboardButton: UIButton {
|
|
let key: KeyCoded
|
|
var toggleState = false
|
|
|
|
// MARK: - Functions
|
|
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
let newArea = CGRect(
|
|
x: self.bounds.origin.x - 5.0,
|
|
y: self.bounds.origin.y - 5.0,
|
|
width: self.bounds.size.width + 20.0,
|
|
height: self.bounds.size.height + 20.0
|
|
)
|
|
return newArea.contains(point)
|
|
}
|
|
|
|
private func updateColors() {
|
|
backgroundColor = isHighlighted ? EmulatorKeyboardView.keyPressedBackgroundColor : isSelected ? EmulatorKeyboardView.keySelectedBackgroundColor : EmulatorKeyboardView.keyNormalBackgroundColor
|
|
layer.borderColor = (isHighlighted ? EmulatorKeyboardView.keyPressedBorderColor : isSelected ? EmulatorKeyboardView.keySelectedBorderColor : EmulatorKeyboardView.keyNormalBorderColor).cgColor
|
|
titleLabel?.textColor = isHighlighted ? EmulatorKeyboardView.keyPressedTextColor : isSelected ? EmulatorKeyboardView.keySelectedTextColor : EmulatorKeyboardView.keyNormalTextColor
|
|
titleLabel?.tintColor = titleLabel?.textColor
|
|
}
|
|
|
|
override open var isHighlighted: Bool {
|
|
didSet {
|
|
updateColors()
|
|
}
|
|
}
|
|
|
|
override open var isSelected: Bool {
|
|
didSet {
|
|
updateColors()
|
|
}
|
|
}
|
|
|
|
required init(key: KeyCoded) {
|
|
self.key = key
|
|
super.init(frame: .zero)
|
|
updateColors()
|
|
}
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|