- make dPad, select, start OSC button on-screen widgets rectangle
- on screen control & widget size factor up to 800% - configurable borderWidth for on-screen widget views stage manager version
This commit is contained in:
1 parent
ca04c62ecd
commit
4d4ab333f4
13 files changed
+161
-39
No files matched your search
@@ -74,6 +74,14 @@ import UIKit
|
||||
"OSCL2" : 0,
|
||||
"OSCR2" : 0]
|
||||
|
||||
@objc public static let oscRectangleButtonCmds: [String] = [
|
||||
"OSCUP",
|
||||
"OSCDOWN",
|
||||
"OSCLEFT",
|
||||
"OSCRIGHT",
|
||||
"OSCSTART",
|
||||
"OSCSELECT"]
|
||||
|
||||
@objc public static let touchPadCmds: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD", "MOUSEPAD", "DPAD", "WASDPAD", "ARROWPAD"]
|
||||
@objc public static let stickTouchPads: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD"]
|
||||
@objc public static let nonVectorStickPads: [String] = ["LSPAD", "RSPAD"]
|
||||
|
||||
@@ -290,6 +290,7 @@ static NSMutableDictionary *OnScreenWidgetViewsDict;
|
||||
buttonState.widthFactor = widgetView.widthFactor;
|
||||
buttonState.heightFactor = widgetView.heightFactor;
|
||||
buttonState.backgroundAlpha = widgetView.backgroundAlpha;
|
||||
buttonState.borderWidth = widgetView.borderWidth;
|
||||
buttonState.sensitivityFactor = widgetView.sensitivityFactor;
|
||||
buttonState.stickIndicatorXOffset = widgetView.stickIndicatorXOffset;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, assign) NSTimeInterval timestamp;
|
||||
@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat borderWidth; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat sensitivityFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat stickIndicatorXOffset; // for OnScreenWidgetView
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
[encoder encodeFloat:self.stickIndicatorXOffset forKey:@"stickIndicatorOffset"];
|
||||
[encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"];
|
||||
[encoder encodeFloat:self.backgroundAlpha forKey:@"backgroundAlpha"];
|
||||
[encoder encodeFloat:self.borderWidth forKey:@"borderWidth"];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder*)decoder {
|
||||
@@ -55,6 +56,7 @@
|
||||
self.stickIndicatorXOffset = [decoder decodeFloatForKey:@"stickIndicatorOffset"];
|
||||
self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"];
|
||||
self.backgroundAlpha = [decoder decodeFloatForKey:@"backgroundAlpha"];
|
||||
self.borderWidth = [decoder decodeFloatForKey:@"borderWidth"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -1894,9 +1894,9 @@ static float L3_Y;
|
||||
// CALayer* superLayer = layer.superlayer;
|
||||
// if(layerBeingDragged.name == @"")
|
||||
CGFloat targetAlpha;
|
||||
|
||||
targetAlpha = alpha;
|
||||
if(alpha < 0.23) targetAlpha = 0.23;
|
||||
if(alpha == 0.0 || alpha == 1.0) targetAlpha = 5.0f/6.0f; // invalid alpha value
|
||||
else targetAlpha = alpha;
|
||||
|
||||
NSLog(@"alphas: %f",targetAlpha);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import UIKit
|
||||
@objc public var pressed: Bool
|
||||
@objc public var widthFactor: CGFloat = 1.0
|
||||
@objc public var heightFactor: CGFloat = 1.0
|
||||
@objc public var borderWidth: CGFloat = 0.0
|
||||
@objc public var backgroundAlpha: CGFloat = 0.5
|
||||
@objc public var latestTouchLocation: CGPoint
|
||||
@objc public var selfViewOnTheRight: Bool = false
|
||||
@@ -153,16 +154,24 @@ import UIKit
|
||||
OnScreenWidgetView.editMode = enabled
|
||||
}
|
||||
|
||||
@objc public func adjustButtonTransparency(alpha: CGFloat){
|
||||
@objc public func adjustTransparency(alpha: CGFloat){
|
||||
if alpha != 0 {
|
||||
self.backgroundAlpha = alpha
|
||||
}
|
||||
else{
|
||||
self.backgroundAlpha = 0.5
|
||||
// self.backgroundAlpha = 0.5
|
||||
self.backgroundAlpha = alpha
|
||||
}
|
||||
self.tweakAlpha()
|
||||
}
|
||||
|
||||
@objc public func adjustBorder(width: CGFloat){
|
||||
self.borderWidth = width
|
||||
// self.layer.borderWidth = borderWidth
|
||||
// if CommandManager.touchPadCmds.contains(self.keyString) && width == 0 {self.layer.borderWidth = 1}
|
||||
setupView()
|
||||
}
|
||||
|
||||
@objc public func resizeWidgetView(){
|
||||
guard let superview = superview else { return }
|
||||
|
||||
@@ -173,7 +182,6 @@ import UIKit
|
||||
// To resize the button, we must set this to false temporarily
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
|
||||
// replace invalid factor values
|
||||
if self.widthFactor == 0 {self.widthFactor = 1.0}
|
||||
if self.heightFactor == 0 {self.heightFactor = 1.0}
|
||||
@@ -207,7 +215,7 @@ import UIKit
|
||||
}
|
||||
|
||||
private func changeAndActivateContraints(){
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString){ // we'll make custom osc buttons round & smaller
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString) && !CommandManager.oscRectangleButtonCmds.contains(self.keyString){ // we'll make custom osc buttons round & smaller
|
||||
NSLayoutConstraint.activate([
|
||||
self.widthAnchor.constraint(equalToConstant: 60 * self.widthFactor),
|
||||
self.heightAnchor.constraint(equalToConstant: 60 * self.heightFactor),])
|
||||
@@ -244,19 +252,21 @@ import UIKit
|
||||
|
||||
self.translatesAutoresizingMaskIntoConstraints = true // this is mandatory to prevent unexpected key view location change
|
||||
|
||||
self.layer.cornerRadius = 20
|
||||
self.layer.borderWidth = 1
|
||||
self.layer.cornerRadius = 16
|
||||
self.layer.borderWidth = self.borderWidth
|
||||
|
||||
self.tweakAlpha()
|
||||
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString){ //make oscButtons round and no border
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString) && !CommandManager.oscRectangleButtonCmds.contains(self.keyString){ //make oscButtons round and no border
|
||||
self.layer.cornerRadius = self.frame.width/2
|
||||
self.layer.borderWidth = 0
|
||||
// self.layer.borderWidth = self.borderWidth
|
||||
label.minimumScaleFactor = 0.15 // Adjust the scale factor for oscButtons
|
||||
label.font = UIFont.boldSystemFont(ofSize: 22)
|
||||
}
|
||||
|
||||
if CommandManager.touchPadCmds.contains(self.keyString){
|
||||
if(self.borderWidth < 1) {self.layer.borderWidth = 1}
|
||||
else {self.layer.borderWidth = self.borderWidth}
|
||||
label.text = "" // make touchPad display no text
|
||||
if OnScreenWidgetView.editMode { //display label in edit mode to make the pad more visible
|
||||
label.text = self.keyString
|
||||
@@ -634,7 +644,7 @@ import UIKit
|
||||
|
||||
private func setupButtonDownVisualEffectLayer() {
|
||||
self.buttonDownVisualEffectWidth = 8.6
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString) {self.buttonDownVisualEffectWidth = 15.3} // wider visual effect for osc buttons
|
||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString) && !CommandManager.oscRectangleButtonCmds.contains(self.keyString) {self.buttonDownVisualEffectWidth = 15.3} // wider visual effect for osc buttons
|
||||
|
||||
// Set the frame to be larger than the view to expand outward
|
||||
buttonDownVisualEffectLayer.borderWidth = 0 // set this 0 to hide the visual effect first
|
||||
|
||||
@@ -401,13 +401,15 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
|
||||
widgetView.widthFactor = buttonState.widthFactor;
|
||||
widgetView.heightFactor = buttonState.heightFactor;
|
||||
widgetView.borderWidth = buttonState.borderWidth;
|
||||
widgetView.sensitivityFactor = buttonState.sensitivityFactor;
|
||||
widgetView.stickIndicatorXOffset = buttonState.stickIndicatorXOffset;
|
||||
// Add the widgetView to the view controller's view
|
||||
[self->streamFrameTopLayerView addSubview:widgetView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
|
||||
[widgetView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
|
||||
[widgetView resizeWidgetView]; // resize must be called after relocation
|
||||
[widgetView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha];
|
||||
[widgetView adjustTransparencyWithAlpha:buttonState.backgroundAlpha];
|
||||
[widgetView adjustBorderWithWidth:buttonState.borderWidth];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user