fix: widget layout tool disfunction after display orientation change
This commit is contained in:
@@ -22,8 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property NSMutableArray <OSCProfile *> *currentProfiles;
|
||||
|
||||
|
||||
+ (OSCProfilesManager *) sharedManager:(CGRect)viewBounds;
|
||||
+ (void) setOnScreenWidgetViewsSet:(NSMutableSet* )set;
|
||||
+ (OSCProfilesManager *)sharedManager:(CGRect)viewBounds;
|
||||
+ (void)setOnScreenWidgetViewsSet:(NSMutableSet* )set;
|
||||
+ (void)setLayoutViewBounds:(CGRect)bounds;
|
||||
|
||||
|
||||
#pragma mark - Getters
|
||||
/**
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
@implementation OSCProfilesManager
|
||||
|
||||
static NSMutableSet *OnScreenWidgetViews;
|
||||
static CGRect streamViewBounds;
|
||||
static CGRect layoutViewBounds;
|
||||
|
||||
#pragma mark - Initializer
|
||||
|
||||
+ (OSCProfilesManager *) sharedManager:(CGRect)viewBounds {
|
||||
static OSCProfilesManager *_sharedManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
streamViewBounds = viewBounds;
|
||||
NSLog(@"bounds width: %f, height: %f", streamViewBounds.size.width, streamViewBounds.size.height);
|
||||
layoutViewBounds = viewBounds;
|
||||
NSLog(@"bounds width: %f, height: %f", layoutViewBounds.size.width, layoutViewBounds.size.height);
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedManager = [[self alloc] init];
|
||||
});
|
||||
@@ -38,10 +38,14 @@ static CGRect streamViewBounds;
|
||||
#pragma mark - Class Helper Methods
|
||||
|
||||
|
||||
+ (void) setOnScreenWidgetViewsSet:(NSMutableSet* )set{
|
||||
+ (void)setOnScreenWidgetViewsSet:(NSMutableSet* )set{
|
||||
OnScreenWidgetViews = set;
|
||||
}
|
||||
|
||||
+ (void)setLayoutViewBounds:(CGRect)bounds{
|
||||
layoutViewBounds = bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile whose 'name' property has a value that is equal to the 'name' passed into the method
|
||||
*/
|
||||
@@ -297,17 +301,21 @@ static CGRect streamViewBounds;
|
||||
}
|
||||
|
||||
- (CGPoint)normalizeWidgetPosition:(CGPoint)position {
|
||||
CGPoint newPosition = position;
|
||||
if(position.x > 1.0 && position.y >1.0){
|
||||
position.x = position.x / streamViewBounds.size.width;
|
||||
position.y = position.y / streamViewBounds.size.height;
|
||||
position.x = position.x / layoutViewBounds.size.width;
|
||||
position.y = position.y / layoutViewBounds.size.height;
|
||||
}
|
||||
// asdfsda;
|
||||
NSLog(@"sef.view bounds: %f, %f", layoutViewBounds.size.width, layoutViewBounds.size.height);
|
||||
NSLog(@"position: %f, %f, denormalized position: %f, %f", position.x, position.y, newPosition.x, newPosition.y);
|
||||
return position;
|
||||
}
|
||||
|
||||
- (CGPoint)denormalizeWidgetPosition:(CGPoint)position {
|
||||
if(position.x < 1.0 && position.y < 1.0){
|
||||
position.x = position.x * streamViewBounds.size.width;
|
||||
position.y = position.y * streamViewBounds.size.height;
|
||||
position.x = position.x * layoutViewBounds.size.width;
|
||||
position.y = position.y * layoutViewBounds.size.height;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
+13
-4
@@ -31,6 +31,7 @@
|
||||
CGRect controllerLoadedBounds;
|
||||
bool widgetViewSelected;
|
||||
bool controllerLayerSelected;
|
||||
bool viewWillBeResized;
|
||||
__weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPhone;
|
||||
__weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPad;
|
||||
UIColor* trashCanStoryBoardColor;
|
||||
@@ -71,11 +72,13 @@
|
||||
}
|
||||
|
||||
- (CGPoint)denormalizeWidgetPosition:(CGPoint)position {
|
||||
// NSLog(@"position: %f, %f", position.x, position.y);
|
||||
CGPoint newPosition = position;
|
||||
if(position.x < 1.0 && position.y < 1.0){
|
||||
position.x = position.x * self.view.bounds.size.width;
|
||||
position.y = position.y * self.view.bounds.size.height;
|
||||
newPosition.x = position.x * self.view.bounds.size.width;
|
||||
newPosition.y = position.y * self.view.bounds.size.height;
|
||||
}
|
||||
return position;
|
||||
return newPosition;
|
||||
}
|
||||
|
||||
- (void)reloadLegacyOnScreenControls{
|
||||
@@ -140,6 +143,7 @@
|
||||
|
||||
//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
|
||||
_quickSwitchEnabled = false;
|
||||
viewWillBeResized = false;
|
||||
|
||||
/* add curve to bottom of chevron tab view */
|
||||
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.chevronView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
|
||||
@@ -268,14 +272,18 @@
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
|
||||
viewWillBeResized = true;
|
||||
//if(CGSizeEqualToSize(size, self.view.frame.size)) return;
|
||||
[self saveTapped:nil];
|
||||
}
|
||||
|
||||
- (void)deviceOrientationDidChange{
|
||||
[self performSelector:@selector(handleOrientationChangeForOnScreenWidgets) withObject:self afterDelay:1];
|
||||
[self performSelector:@selector(handleOrientationChangeForOnScreenWidgets) withObject:self afterDelay:0.05];
|
||||
}
|
||||
|
||||
- (void)handleOrientationChangeForOnScreenWidgets{
|
||||
if(!viewWillBeResized) return;
|
||||
viewWillBeResized = false;
|
||||
_oscProfilesTableViewController.layoutViewBounds = self.view.bounds;
|
||||
[OSCProfilesManager setOnScreenWidgetViewsSet:self.onScreenWidgetViews]; // pass the keyboard button dict to profiles manager
|
||||
[self reloadOnScreenWidgetViews];
|
||||
@@ -641,6 +649,7 @@
|
||||
|
||||
/* show pop up notification that lets users choose to save the current OSC layout configuration as a profile they can load when they want. User can also choose to cancel out of this pop up */
|
||||
- (IBAction) saveTapped:(id)sender {
|
||||
[OSCProfilesManager setLayoutViewBounds:self.view.bounds];
|
||||
|
||||
if([self->profilesManager updateSelectedProfile:self.layoutOSC.OSCButtonLayers]){
|
||||
UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [LocalizationHelper localizedStringForKey:@"Current profile updated successfully"] preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
@@ -1518,21 +1518,6 @@ BOOL isCustomResolution(CGSize res) {
|
||||
[self.enableOswForNativeTouchSwitch addTarget:self action:@selector(enableOswForNativeTouchSwitchFlipped:) forControlEvents:UIControlEventValueChanged];
|
||||
[self enableOswForNativeTouchSwitchFlipped:self.enableOswForNativeTouchSwitch];
|
||||
|
||||
|
||||
// init CustomOSC stuff
|
||||
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
|
||||
// self.layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init];
|
||||
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
|
||||
if (isIPhone) {
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
|
||||
self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
|
||||
}
|
||||
else {
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
|
||||
self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
|
||||
self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
}
|
||||
|
||||
[self.externalDisplayModeSelector setSelectedSegmentIndex:currentSettings.externalDisplayMode.integerValue];
|
||||
[self.localMousePointerModeSelector setSelectedSegmentIndex:currentSettings.localMousePointerMode.integerValue];
|
||||
|
||||
@@ -1638,6 +1623,20 @@ BOOL isCustomResolution(CGSize res) {
|
||||
}
|
||||
|
||||
- (void)invokeOscLayout{
|
||||
// init CustomOSC stuff
|
||||
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
|
||||
// self.layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init];
|
||||
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
|
||||
if (isIPhone) {
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
|
||||
self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
|
||||
}
|
||||
else {
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
|
||||
self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"];
|
||||
self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
}
|
||||
|
||||
self.layoutOnScreenControlsVC.view.backgroundColor = [UIColor colorWithWhite:0.55 alpha:1.0];
|
||||
[self presentViewController:self.layoutOnScreenControlsVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
UIScrollView *_scrollView;
|
||||
BOOL _userIsInteracting;
|
||||
bool viewJustLoaded;
|
||||
bool viewIsBeingResized;
|
||||
CGSize _keyboardSize;
|
||||
UIWindow *_extWindow;
|
||||
UIView *_streamVideoRenderView;
|
||||
@@ -314,7 +315,8 @@
|
||||
|
||||
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
|
||||
overlayLevel = _settings.statsOverlayLevel.intValue;
|
||||
[self configOscLayoutTool];
|
||||
if(viewIsBeingResized) viewIsBeingResized = false;
|
||||
else [self configOscLayoutTool];
|
||||
[self updateToolboxSpecialEntries];
|
||||
[self configGestures];
|
||||
[self configZoomGestureAndAddStreamView];
|
||||
@@ -491,6 +493,7 @@
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
viewJustLoaded = true;
|
||||
viewIsBeingResized = false;
|
||||
[super viewDidLoad];
|
||||
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
@@ -869,6 +872,7 @@
|
||||
}
|
||||
|
||||
- (void) handleViewResize{
|
||||
viewIsBeingResized = true;
|
||||
_streamView.bounds = _deviceWindow.bounds;
|
||||
_streamView.frame = _deviceWindow.frame;
|
||||
if(![self isAirPlaying]){
|
||||
|
||||
Reference in New Issue
Block a user