adjustable onScreenButtonView alpha(transparency)

This commit is contained in:
TrueZhuangjia committed 2024-10-14 15:10:53 +08:00
1 parent 113aaa1b81
commit 8999fd625d
11 files changed
+136 -33

No files matched your search

+11 -4
View File
@@ -838,18 +838,24 @@ ICAgICAgICAgICAgICA
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="100" minValue="60" maxValue="390" id="Efn-Si-TPp" userLabel="Button Size Slider"> <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="Efn-Si-TPp" userLabel="Button Size Slider">
<rect key="frame" x="205" y="172" width="420" height="31"/> <rect key="frame" x="205" y="172" width="420" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/> <color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider> </slider>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="100" minValue="60" maxValue="390" id="ZOF-sL-e7p" userLabel="Button Height Slider"> <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="ZOF-sL-e7p" userLabel="Button Height Slider">
<rect key="frame" x="205" y="211" width="420" height="31"/> <rect key="frame" x="205" y="211" width="420" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/> <color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider> </slider>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.001" maxValue="1" id="ZLL-pE-iZh" userLabel="Button Alpha Slider">
<rect key="frame" x="207" y="249" width="420" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
</subviews> </subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
@@ -861,6 +867,7 @@ ICAgICAgICAgICAgICA
<toolbarItems/> <toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/> <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections> <connections>
<outlet property="buttonAndControllerAlphaSlider" destination="ZLL-pE-iZh" id="5OX-P6-YKt"/>
<outlet property="buttonAndControllerHeightSlider" destination="ZOF-sL-e7p" id="OHK-5i-3RY"/> <outlet property="buttonAndControllerHeightSlider" destination="ZOF-sL-e7p" id="OHK-5i-3RY"/>
<outlet property="buttonAndControllerSizeSlider" destination="Efn-Si-TPp" id="CgK-cC-Yo0"/> <outlet property="buttonAndControllerSizeSlider" destination="Efn-Si-TPp" id="CgK-cC-Yo0"/>
<outlet property="chevronImageView" destination="iVZ-Fd-dY7" id="403-Nj-wRx"/> <outlet property="chevronImageView" destination="iVZ-Fd-dY7" id="403-Nj-wRx"/>
@@ -951,13 +958,13 @@ ICAgICAgICAgICAgICA
<image name="SquaresArrowUp" width="40" height="40"/> <image name="SquaresArrowUp" width="40" height="40"/>
<image name="Trash" width="40" height="40"/> <image name="Trash" width="40" height="40"/>
<systemColor name="secondaryLabelColor"> <systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="systemBackgroundColor"> <systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor> </systemColor>
<systemColor name="tintColor"> <systemColor name="tintColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="viewFlipsideBackgroundColor"> <systemColor name="viewFlipsideBackgroundColor">
<color red="0.12156862745098039" green="0.12941176470588237" blue="0.14117647058823529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.12156862745098039" green="0.12941176470588237" blue="0.14117647058823529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -286,6 +286,7 @@ static NSMutableDictionary *onScreenButtonViewsDict;
buttonState.timestamp = buttonView.timestamp; buttonState.timestamp = buttonView.timestamp;
buttonState.widthFactor = buttonView.widthFactor; buttonState.widthFactor = buttonView.widthFactor;
buttonState.heightFactor = buttonView.heightFactor; buttonState.heightFactor = buttonView.heightFactor;
buttonState.backgroundAlpha = buttonView.backgroundAlpha;
NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil]; NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil];
[buttonStatesEncoded addObject: buttonStateEncoded]; [buttonStatesEncoded addObject: buttonStateEncoded];
}]; }];
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenButtonView @property (nonatomic, assign) CGFloat widthFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenButtonView @property (nonatomic, assign) CGFloat heightFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer @property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer
@property (nonatomic, assign) CGFloat backgroundAlpha; // for OnScreenController CALayer
// @property (nonatomic, assign) BOOL hasValidPosition; // @property (nonatomic, assign) BOOL hasValidPosition;
@@ -36,6 +36,7 @@
[encoder encodeFloat:self.widthFactor forKey:@"widthFactor"]; [encoder encodeFloat:self.widthFactor forKey:@"widthFactor"];
[encoder encodeFloat:self.heightFactor forKey:@"heightFactor"]; [encoder encodeFloat:self.heightFactor forKey:@"heightFactor"];
[encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"]; [encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"];
[encoder encodeFloat:self.backgroundAlpha forKey:@"backgroundAlpha"];
} }
- (id) initWithCoder:(NSCoder*)decoder { - (id) initWithCoder:(NSCoder*)decoder {
@@ -49,6 +50,7 @@
self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"]; self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"];
self.heightFactor = [decoder decodeFloatForKey:@"heightFactor"]; self.heightFactor = [decoder decodeFloatForKey:@"heightFactor"];
self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"]; self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"];
self.backgroundAlpha = [decoder decodeFloatForKey:@"backgroundAlpha"];
} }
return self; return self;
} }
+31 -5
View File
@@ -18,21 +18,24 @@ import UIKit
@objc public var pressed: Bool @objc public var pressed: Bool
@objc public var widthFactor: CGFloat @objc public var widthFactor: CGFloat
@objc public var heightFactor: CGFloat @objc public var heightFactor: CGFloat
@objc public var backgroundAlpha: CGFloat
private let label: UILabel private let label: UILabel
private let originalBackgroundColor: UIColor // private let originalBackgroundColor: UIColor
private var storedLocation: CGPoint = .zero private var storedLocation: CGPoint = .zero
private let minimumBorderAlpha: CGFloat = 0.19
@objc init(keyString: String, keyLabel: String) { @objc init(keyString: String, keyLabel: String) {
self.keyString = keyString self.keyString = keyString
self.keyLabel = keyLabel self.keyLabel = keyLabel
self.label = UILabel() self.label = UILabel()
self.originalBackgroundColor = UIColor(white: 0.2, alpha: 0.7) // self.originalBackgroundColor = UIColor(white: 0.2, alpha: 0.7)
self.timestamp = 0 self.timestamp = 0
self.pressed = false self.pressed = false
self.widthFactor = 1.0 self.widthFactor = 1.0
self.heightFactor = 1.0 self.heightFactor = 1.0
self.backgroundAlpha = 0.5
super.init(frame: .zero) super.init(frame: .zero)
setupView() setupView()
} }
@@ -52,6 +55,23 @@ import UIKit
OnScreenButtonView.editMode = enabled OnScreenButtonView.editMode = enabled
} }
@objc public func adjustButtonTransparency(alpha: CGFloat){
if(alpha != 0){
self.backgroundAlpha = alpha
}
else{
self.backgroundAlpha = 0.5
}
var borderAlpha = 1.5 * self.backgroundAlpha
if(borderAlpha < minimumBorderAlpha){
borderAlpha = minimumBorderAlpha
}
self.backgroundColor = UIColor(white: 0.2, alpha: self.backgroundAlpha)
self.layer.borderColor = UIColor(white: 0.2, alpha: borderAlpha).cgColor
}
@objc public func resizeButtonView(){ @objc public func resizeButtonView(){
guard let superview = superview else { return } guard let superview = superview else { return }
@@ -83,6 +103,8 @@ import UIKit
setupView() setupView()
} }
@objc public func setupView() { @objc public func setupView() {
label.text = self.keyLabel label.text = self.keyLabel
label.font = UIFont.boldSystemFont(ofSize: 19) label.font = UIFont.boldSystemFont(ofSize: 19)
@@ -97,17 +119,21 @@ import UIKit
label.translatesAutoresizingMaskIntoConstraints = false // enable auto alignment for the label label.translatesAutoresizingMaskIntoConstraints = false // enable auto alignment for the label
self.translatesAutoresizingMaskIntoConstraints = true // this is mandatory to prevent unexpected key view location change self.translatesAutoresizingMaskIntoConstraints = true // this is mandatory to prevent unexpected key view location change
self.layer.borderColor = UIColor(white: 0.2, alpha: 0.86).cgColor var borderAlpha = 1.5 * self.backgroundAlpha
if(borderAlpha < minimumBorderAlpha){
borderAlpha = minimumBorderAlpha
}
// if(self.backgroundAlpha * )
self.layer.borderColor = UIColor(white: 0.2, alpha: borderAlpha).cgColor
self.layer.borderWidth = 1 self.layer.borderWidth = 1
self.layer.cornerRadius = 20 self.layer.cornerRadius = 20
self.backgroundColor = UIColor(white: 0.2, alpha: 0.57) self.backgroundColor = UIColor(white: 0.2, alpha: self.backgroundAlpha)
self.layer.shadowColor = UIColor.clear.cgColor self.layer.shadowColor = UIColor.clear.cgColor
self.layer.shadowRadius = 8 self.layer.shadowRadius = 8
self.layer.shadowOpacity = 0.5 self.layer.shadowOpacity = 0.5
addSubview(label) addSubview(label)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
//self.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width * 0.088), //self.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width * 0.088),
//self.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height * 0.1), //self.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height * 0.1),
+1 -1
View File
@@ -39,7 +39,7 @@
- (void) reloadOnScreenControlsWith:(ControllerSupport*)controllerSupport - (void) reloadOnScreenControlsWith:(ControllerSupport*)controllerSupport
andConfig:(StreamConfiguration*)streamConfig; andConfig:(StreamConfiguration*)streamConfig;
- (void) clearOnScreenKeyboardButtons; - (void) clearOnScreenKeyboardButtons;
- (void) reloadOnScreenKeyboardButtons; - (void) reloadOnScreenButtonViews;
- (CGSize) getVideoAreaSize; - (CGSize) getVideoAreaSize;
- (CGPoint) adjustCoordinatesForVideoArea:(CGPoint)point; - (CGPoint) adjustCoordinatesForVideoArea:(CGPoint)point;
+2 -1
View File
@@ -363,7 +363,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
} }
- (void) reloadOnScreenKeyboardButtons{ - (void) reloadOnScreenButtonViews{
NSLog(@"reload on screen keyboard buttons here"); NSLog(@"reload on screen keyboard buttons here");
@@ -389,6 +389,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self->streamFrameTopLayerView addSubview:buttonView]; // add keyboard button to the stream frame view. must add it to the target view before setting location. [self->streamFrameTopLayerView addSubview:buttonView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
[buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y]; [buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
[buttonView resizeButtonView]; // resize must be called after relocation [buttonView resizeButtonView]; // resize must be called after relocation
[buttonView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha];
} }
} }
} }
@@ -237,6 +237,29 @@
} }
} }
}, },
"Button Alpha" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "按键透明度"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "按键透明度"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "按键透明度"
}
}
}
},
"Button Height" : { "Button Height" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@interface LayoutOnScreenControlsViewController : UIViewController @interface LayoutOnScreenControlsViewController : UIViewController
- (void)profileRefresh; - (void)profileRefresh;
- (void)reloadOnScreenKeyboardButtons; - (void)reloadOnScreenButtonViews;
@property LayoutOnScreenControls *layoutOSC; // object that contains a view which contains the on screen controller buttons that allows the user to drag and positions each button on the screen using touch @property LayoutOnScreenControls *layoutOSC; // object that contains a view which contains the on screen controller buttons that allows the user to drag and positions each button on the screen using touch
@property (nonatomic) NSMutableDictionary* onScreenButtonViewsDict; @property (nonatomic) NSMutableDictionary* onScreenButtonViewsDict;
@@ -39,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) IBOutlet UILabel *currentProfileLabel; @property (strong, nonatomic) IBOutlet UILabel *currentProfileLabel;
@property (strong, nonatomic) IBOutlet UISlider *buttonAndControllerSizeSlider; @property (strong, nonatomic) IBOutlet UISlider *buttonAndControllerSizeSlider;
@property (strong, nonatomic) IBOutlet UISlider *buttonAndControllerHeightSlider; @property (strong, nonatomic) IBOutlet UISlider *buttonAndControllerHeightSlider;
@property (strong, nonatomic) IBOutlet UISlider *buttonAndControllerAlphaSlider;
@end @end
@@ -31,6 +31,7 @@
__weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPad; __weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPad;
UILabel *buttonSizeSliderLabel; UILabel *buttonSizeSliderLabel;
UILabel *buttonHeightSliderLabel; UILabel *buttonHeightSliderLabel;
UILabel *buttonAlphaSliderLabel;
} }
@@ -48,7 +49,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"OscLayoutCloseNotification" object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:@"OscLayoutCloseNotification" object:self];
} }
- (void) reloadOnScreenKeyboardButtons { - (void) reloadOnScreenButtonViews {
for (UIView *subview in self.view.subviews) { for (UIView *subview in self.view.subviews) {
// 检查子视图是否是特定类型的实例 // 检查子视图是否是特定类型的实例
if ([subview isKindOfClass:[OnScreenButtonView class]]) { if ([subview isKindOfClass:[OnScreenButtonView class]]) {
@@ -71,10 +72,12 @@
buttonView.timestamp = buttonState.timestamp; // will be set as key in in the dict. buttonView.timestamp = buttonState.timestamp; // will be set as key in in the dict.
buttonView.widthFactor = buttonState.widthFactor; buttonView.widthFactor = buttonState.widthFactor;
buttonView.heightFactor = buttonState.heightFactor; buttonView.heightFactor = buttonState.heightFactor;
// buttonView.backgroundAlpha = buttonState.backgroundAlpha;
// Add the buttonView to the view controller's view // Add the buttonView to the view controller's view
[self.view addSubview:buttonView]; [self.view addSubview:buttonView];
[buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y]; [buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
[buttonView resizeButtonView]; // resize must be called after relocation [buttonView resizeButtonView]; // resize must be called after relocation
[buttonView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha];
[self.onScreenButtonViewsDict setObject:buttonView forKey:@(buttonView.timestamp)]; [self.onScreenButtonViewsDict setObject:buttonView forKey:@(buttonView.timestamp)];
} }
} }
@@ -89,6 +92,10 @@
isToolbarHidden = NO; // keeps track if the toolbar is hidden up above the screen so that we know whether to hide or show it when the user taps the toolbar's hide/show button isToolbarHidden = NO; // keeps track if the toolbar is hidden up above the screen so that we know whether to hide or show it when the user taps the toolbar's hide/show button
buttonSizeSliderLabel = [[UILabel alloc] init];
buttonHeightSliderLabel = [[UILabel alloc] init];
buttonAlphaSliderLabel = [[UILabel alloc] init];
/* add curve to bottom of chevron tab view */ /* add curve to bottom of chevron tab view */
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.chevronView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.chevronView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
@@ -126,17 +133,17 @@
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadOnScreenKeyboardButtons) selector:@selector(reloadOnScreenButtonViews)
name:@"OscLayoutProfileSelctedInTableView" // This is a special notification for reloading the on screen keyboard buttons. which can't be executed by _oscProfilesTableViewController.needToUpdateOscLayoutTVC code block, and has to be triggered by a notification name:@"OscLayoutProfileSelctedInTableView" // This is a special notification for reloading the on screen keyboard buttons. which can't be executed by _oscProfilesTableViewController.needToUpdateOscLayoutTVC code block, and has to be triggered by a notification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setButtonViewSizeSliderValues:) selector:@selector(setButtonViewSliderValues:)
name:@"OnScreenButtonViewSelected" name:@"OnScreenButtonViewSelected"
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setControllerCALayerSizeSliderValues:) selector:@selector(setControllerCALayerSliderValues:)
name:@"ControllerCALayerSelected" name:@"ControllerCALayerSelected"
object:nil]; object:nil];
@@ -365,18 +372,19 @@
} }
} }
- (void)setButtonViewSizeSliderValues: (NSNotification *)notification{ - (void)setButtonViewSliderValues: (NSNotification *)notification{
// receive the selected buttonView obj passed from the notification // receive the selected buttonView obj passed from the notification
OnScreenButtonView* buttonView = (OnScreenButtonView* )notification.object; OnScreenButtonView* buttonView = (OnScreenButtonView* )notification.object;
self->buttonViewSelected = true; self->buttonViewSelected = true;
self->controllerLayerSelected = false; self->controllerLayerSelected = false;
self->selectedButtonView = buttonView; self->selectedButtonView = buttonView;
// setup slider values // setup slider values
[self.buttonAndControllerSizeSlider setValue:100 * self->selectedButtonView.widthFactor]; [self.buttonAndControllerSizeSlider setValue: self->selectedButtonView.widthFactor];
[self.buttonAndControllerHeightSlider setValue:100 * self->selectedButtonView.heightFactor]; [self.buttonAndControllerHeightSlider setValue: self->selectedButtonView.heightFactor];
[self.buttonAndControllerAlphaSlider setValue: self->selectedButtonView.backgroundAlpha];
} }
- (void)setControllerCALayerSizeSliderValues: (NSNotification *)notification{ - (void)setControllerCALayerSliderValues: (NSNotification *)notification{
// receive the selected buttonView obj passed from the notification // receive the selected buttonView obj passed from the notification
CALayer* controllerLayer = (CALayer* )notification.object; CALayer* controllerLayer = (CALayer* )notification.object;
self->buttonViewSelected = false; self->buttonViewSelected = false;
@@ -386,21 +394,22 @@
CGFloat sizeFactor = [OnScreenControls getControllerLayerSizeFactor:controllerLayer]; // calculated sizeFactor from loaded layer bounds. CGFloat sizeFactor = [OnScreenControls getControllerLayerSizeFactor:controllerLayer]; // calculated sizeFactor from loaded layer bounds.
// setup slider values // setup slider values
[self.buttonAndControllerSizeSlider setValue:100 * sizeFactor]; [self.buttonAndControllerSizeSlider setValue: sizeFactor];
} }
- (void)buttonAndControllerWidthSliderMoved{ - (void)buttonAndControllerWidthSliderMoved{
if(self->selectedButtonView != nil && self->buttonViewSelected){ if(self->selectedButtonView != nil && self->buttonViewSelected){
self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change
// when adjusting width, the buttonView height will be syncronized // when adjusting width, the buttonView height will be syncronized
self->selectedButtonView.widthFactor = self->selectedButtonView.heightFactor = self.buttonAndControllerSizeSlider.value / 100; self->selectedButtonView.widthFactor = self->selectedButtonView.heightFactor = self.buttonAndControllerSizeSlider.value;
[self.buttonAndControllerHeightSlider setValue: self.buttonAndControllerSizeSlider.value]; [self.buttonAndControllerHeightSlider setValue: self.buttonAndControllerSizeSlider.value];
[self->selectedButtonView resizeButtonView]; [self->selectedButtonView resizeButtonView];
} }
if(self->selectedControllerLayer != nil && self->controllerLayerSelected){ if(self->selectedControllerLayer != nil && self->controllerLayerSelected){
[self.layoutOSC resizeControllerLayerWith:self->selectedControllerLayer and:self.buttonAndControllerSizeSlider.value/100]; [self.layoutOSC resizeControllerLayerWith:self->selectedControllerLayer and:self.buttonAndControllerSizeSlider.value];
return; return;
CALayer* superLayer = self->selectedControllerLayer.superlayer; CALayer* superLayer = self->selectedControllerLayer.superlayer;
@@ -414,7 +423,7 @@
[self->selectedControllerLayer.name isEqualToString:@"xButton"] || [self->selectedControllerLayer.name isEqualToString:@"xButton"] ||
[self->selectedControllerLayer.name isEqualToString:@"yButton"]){ [self->selectedControllerLayer.name isEqualToString:@"yButton"]){
[self->selectedControllerLayer removeFromSuperlayer]; [self->selectedControllerLayer removeFromSuperlayer];
self->selectedControllerLayer.bounds = CGRectMake(0, 0, self.layoutOSC.standardRoundButtonBounds.size.width * self.buttonAndControllerSizeSlider.value/100, self.layoutOSC.standardRoundButtonBounds.size.height * self.buttonAndControllerSizeSlider.value/100); self->selectedControllerLayer.bounds = CGRectMake(0, 0, self.layoutOSC.standardRoundButtonBounds.size.width * self.buttonAndControllerSizeSlider.value, self.layoutOSC.standardRoundButtonBounds.size.height * self.buttonAndControllerSizeSlider.value);
[superLayer addSublayer:self->selectedControllerLayer]; [superLayer addSublayer:self->selectedControllerLayer];
} }
} }
@@ -424,11 +433,17 @@
- (void)buttonAndControllerHeightSliderMoved{ - (void)buttonAndControllerHeightSliderMoved{
if(self->selectedButtonView != nil && self->buttonViewSelected){ if(self->selectedButtonView != nil && self->buttonViewSelected){
self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change
self->selectedButtonView.heightFactor = self.buttonAndControllerHeightSlider.value / 100; self->selectedButtonView.heightFactor = self.buttonAndControllerHeightSlider.value;
[self->selectedButtonView resizeButtonView]; [self->selectedButtonView resizeButtonView];
} }
} }
- (void)buttonAndControllerAlphaSliderMoved{
if(self->selectedButtonView != nil && self->buttonViewSelected){
[self->selectedButtonView adjustButtonTransparencyWithAlpha:self.buttonAndControllerAlphaSlider.value];
}
return;
}
- (void)setupProfileLableAndSliders{ - (void)setupProfileLableAndSliders{
CGFloat xPosition = (self.view.bounds.size.width - self.currentProfileLabel.frame.size.width) / 2; CGFloat xPosition = (self.view.bounds.size.width - self.currentProfileLabel.frame.size.width) / 2;
@@ -441,11 +456,10 @@
self.buttonAndControllerSizeSlider.hidden = NO; self.buttonAndControllerSizeSlider.hidden = NO;
self.buttonAndControllerSizeSlider.frame = CGRectMake(xPosition, self.buttonAndControllerSizeSlider.frame.origin.y, self.buttonAndControllerSizeSlider.frame.size.width, self.buttonAndControllerSizeSlider.frame.size.height); self.buttonAndControllerSizeSlider.frame = CGRectMake(xPosition, self.buttonAndControllerSizeSlider.frame.origin.y, self.buttonAndControllerSizeSlider.frame.size.width, self.buttonAndControllerSizeSlider.frame.size.height);
[self.buttonAndControllerSizeSlider addTarget:self action:@selector(buttonAndControllerWidthSliderMoved) forControlEvents:(UIControlEventValueChanged)]; [self.buttonAndControllerSizeSlider addTarget:self action:@selector(buttonAndControllerWidthSliderMoved) forControlEvents:(UIControlEventValueChanged)];
buttonSizeSliderLabel = [[UILabel alloc] init];
buttonSizeSliderLabel.text = [LocalizationHelper localizedStringForKey:@"Button Size"]; buttonSizeSliderLabel.text = [LocalizationHelper localizedStringForKey:@"Button Size"];
buttonSizeSliderLabel.font = [UIFont systemFontOfSize:23]; buttonSizeSliderLabel.font = [UIFont systemFontOfSize:23];
buttonSizeSliderLabel.textColor = [UIColor whiteColor]; buttonSizeSliderLabel.textColor = [UIColor whiteColor];
buttonSizeSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2]; buttonSizeSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
buttonSizeSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout buttonSizeSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout
// Add slider and label to the view // Add slider and label to the view
[self.view addSubview:buttonSizeSliderLabel]; [self.view addSubview:buttonSizeSliderLabel];
@@ -456,18 +470,17 @@
// Align vertically with the slider // Align vertically with the slider
[buttonSizeSliderLabel.centerYAnchor constraintEqualToAnchor:self.buttonAndControllerSizeSlider.centerYAnchor] [buttonSizeSliderLabel.centerYAnchor constraintEqualToAnchor:self.buttonAndControllerSizeSlider.centerYAnchor]
]]; ]];
buttonSizeSliderLabel.hidden = NO;
// button height sliders // button height sliders
self.buttonAndControllerHeightSlider.hidden = NO; self.buttonAndControllerHeightSlider.hidden = NO;
self.buttonAndControllerHeightSlider.frame = CGRectMake(xPosition, self.buttonAndControllerHeightSlider.frame.origin.y, self.buttonAndControllerHeightSlider.frame.size.width, self.buttonAndControllerHeightSlider.frame.size.height); self.buttonAndControllerHeightSlider.frame = CGRectMake(xPosition, self.buttonAndControllerHeightSlider.frame.origin.y, self.buttonAndControllerHeightSlider.frame.size.width, self.buttonAndControllerHeightSlider.frame.size.height);
[self.buttonAndControllerHeightSlider addTarget:self action:@selector(buttonAndControllerHeightSliderMoved) forControlEvents:(UIControlEventValueChanged)]; [self.buttonAndControllerHeightSlider addTarget:self action:@selector(buttonAndControllerHeightSliderMoved) forControlEvents:(UIControlEventValueChanged)];
// button height label // button height label
buttonHeightSliderLabel = [[UILabel alloc] init];
buttonHeightSliderLabel.text = [LocalizationHelper localizedStringForKey:@"Button Height"]; buttonHeightSliderLabel.text = [LocalizationHelper localizedStringForKey:@"Button Height"];
buttonHeightSliderLabel.font = [UIFont systemFontOfSize:23]; buttonHeightSliderLabel.font = [UIFont systemFontOfSize:23];
buttonHeightSliderLabel.textColor = [UIColor whiteColor]; buttonHeightSliderLabel.textColor = [UIColor whiteColor];
buttonHeightSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2]; buttonHeightSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
buttonHeightSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout buttonHeightSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout
// Add slider and label to the view // Add slider and label to the view
[self.view addSubview:buttonHeightSliderLabel]; [self.view addSubview:buttonHeightSliderLabel];
@@ -478,6 +491,30 @@
// Align vertically with the slider // Align vertically with the slider
[buttonHeightSliderLabel.centerYAnchor constraintEqualToAnchor:self.buttonAndControllerHeightSlider.centerYAnchor] [buttonHeightSliderLabel.centerYAnchor constraintEqualToAnchor:self.buttonAndControllerHeightSlider.centerYAnchor]
]]; ]];
buttonHeightSliderLabel.hidden = NO;
self.buttonAndControllerAlphaSlider.hidden = NO;
self.buttonAndControllerAlphaSlider.frame = CGRectMake(xPosition, self.buttonAndControllerAlphaSlider.frame.origin.y, self.buttonAndControllerAlphaSlider.frame.size.width, self.buttonAndControllerAlphaSlider.frame.size.height);
[self.buttonAndControllerAlphaSlider addTarget:self action:@selector(buttonAndControllerAlphaSliderMoved) forControlEvents:(UIControlEventValueChanged)];
// button alpha label
buttonAlphaSliderLabel.text = [LocalizationHelper localizedStringForKey:@"Button Alpha"];
buttonAlphaSliderLabel.font = [UIFont systemFontOfSize:23];
buttonAlphaSliderLabel.textColor = [UIColor whiteColor];
buttonAlphaSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
buttonAlphaSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout
// Add slider and label to the view
[self.view addSubview:buttonAlphaSliderLabel];
// Use Auto Layout to position the label relative to the slider
[NSLayoutConstraint activateConstraints:@[
// Position the label to the left of the slider
[buttonAlphaSliderLabel.trailingAnchor constraintEqualToAnchor:self.buttonAndControllerAlphaSlider.leadingAnchor constant:-10],
// Align vertically with the slider
[buttonAlphaSliderLabel.centerYAnchor constraintEqualToAnchor:self.buttonAndControllerAlphaSlider.centerYAnchor]
]];
buttonAlphaSliderLabel.hidden = NO;
} }
@@ -510,7 +547,7 @@
}; };
[self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache. [self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache.
[self reloadOnScreenKeyboardButtons]; [self reloadOnScreenButtonViews];
// [self presentViewController:vc animated:YES completion:nil]; // [self presentViewController:vc animated:YES completion:nil];
} }
@@ -541,6 +578,10 @@
self.currentProfileLabel.hidden = YES; // Hide Current Profile display before entering the profile table view self.currentProfileLabel.hidden = YES; // Hide Current Profile display before entering the profile table view
self.buttonAndControllerSizeSlider.hidden = YES; self.buttonAndControllerSizeSlider.hidden = YES;
self.buttonAndControllerHeightSlider.hidden = YES; self.buttonAndControllerHeightSlider.hidden = YES;
self.buttonAndControllerAlphaSlider.hidden = YES;
buttonSizeSliderLabel.hidden = YES;
buttonHeightSliderLabel.hidden = YES;
buttonAlphaSliderLabel.hidden = YES;
_oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; _oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers;
[self presentViewController:_oscProfilesTableViewController animated:YES completion:nil]; [self presentViewController:_oscProfilesTableViewController animated:YES completion:nil];
} }
@@ -161,7 +161,7 @@
// we got self.view passed to streamView class as the topLayerView, will be useful in many cases // we got self.view passed to streamView class as the topLayerView, will be useful in many cases
[self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport [self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport
andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here. andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here.
[self->_streamView reloadOnScreenKeyboardButtons]; //reload keyboard buttons here. the keyboard button view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering [self->_streamView reloadOnScreenButtonViews]; //reload keyboard buttons here. the keyboard button view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering
//reconfig statsOverlay //reconfig statsOverlay
self->_statsUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f self->_statsUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:self target:self
@@ -338,7 +338,7 @@
[self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport [self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport
andConfig:(StreamConfiguration*)_streamConfig]; andConfig:(StreamConfiguration*)_streamConfig];
[self->_streamView showOnScreenControls]; [self->_streamView showOnScreenControls];
[self->_streamView reloadOnScreenKeyboardButtons]; //update keyboard buttons here [self->_streamView reloadOnScreenButtonViews]; //update keyboard buttons here
} }