improve widget alignment
This commit is contained in:
@@ -138,11 +138,14 @@
|
||||
*/
|
||||
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor]; // change horizontal guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
OnScreenWidgetView.isHorizontallyAligned = false;
|
||||
for (CALayer *button in self.OSCButtonLayerPool) { // horizontal guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((horizontalGuideline.center.y < button.position.y + 1) &&
|
||||
(horizontalGuideline.center.y > button.position.y - 1)) {
|
||||
if ((horizontalGuideline.center.y < button.position.y + 2) &&
|
||||
(horizontalGuideline.center.y > button.position.y - 2)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
OnScreenWidgetView.isHorizontallyAligned = true;
|
||||
OnScreenWidgetView.alignedY = button.position.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -151,32 +154,38 @@
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]] && view != widget) {
|
||||
OnScreenWidgetView* otherWidget = (OnScreenWidgetView *) view;
|
||||
if(widget.isFolder && widget.bulkMoveEnabled && [widget.sequenceSet containsObject:@(otherWidget.sequence)]) break;
|
||||
if((horizontalGuideline.center.y < view.center.y + 1) && (horizontalGuideline.center.y > view.center.y - 1)) {
|
||||
if((horizontalGuideline.center.y < view.center.y + 2) && (horizontalGuideline.center.y > view.center.y - 2)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
OnScreenWidgetView.isHorizontallyAligned = true;
|
||||
OnScreenWidgetView.alignedY = view.center.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor]; // change vertical guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
OnScreenWidgetView.isVerticallyAligned = false;
|
||||
for (CALayer *button in self.OSCButtonLayerPool) { // vertical guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((verticalGuideline.center.x < button.position.x + 1) &&
|
||||
(verticalGuideline.center.x > button.position.x - 1)) {
|
||||
if ((verticalGuideline.center.x < button.position.x + 2) &&
|
||||
(verticalGuideline.center.x > button.position.x - 2)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
OnScreenWidgetView.isVerticallyAligned = true;
|
||||
OnScreenWidgetView.alignedX = button.position.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(UIView* view in self.layoutToolVC.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]] && view != widget) {
|
||||
if ((verticalGuideline.center.x < view.center.x + 1) && (verticalGuideline.center.x > view.center.x - 1)) {
|
||||
if ((verticalGuideline.center.x < view.center.x + 2) && (verticalGuideline.center.x > view.center.x - 2)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
OnScreenWidgetView.isVerticallyAligned = true;
|
||||
OnScreenWidgetView.alignedX = view.center.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void) updateGuidelinesForLegacyOnScreenControls{
|
||||
|
||||
@@ -3248,6 +3248,14 @@ import ObjectiveC.runtime
|
||||
}
|
||||
}
|
||||
|
||||
if OnScreenWidgetView.isVerticallyAligned {
|
||||
self.center = CGPoint(x:OnScreenWidgetView.alignedX, y:self.center.y)
|
||||
OnScreenWidgetView.isVerticallyAligned = false
|
||||
}
|
||||
if OnScreenWidgetView.isHorizontallyAligned {
|
||||
self.center = CGPoint(x:self.center.x, y:OnScreenWidgetView.alignedY)
|
||||
OnScreenWidgetView.isHorizontallyAligned = false
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func setAutoTapIntervalByText(str: String){
|
||||
@@ -4039,7 +4047,11 @@ import ObjectiveC.runtime
|
||||
v.layer.shadowRadius = 2
|
||||
return v
|
||||
}()
|
||||
|
||||
@objc static var isHorizontallyAligned:Bool = false
|
||||
@objc static var alignedX:CGFloat = 0
|
||||
@objc static var isVerticallyAligned:Bool = false
|
||||
@objc static var alignedY:CGFloat = 0
|
||||
|
||||
private static func updateStreamViewGuidelines(for widget:OnScreenWidgetView){
|
||||
if !widget.moveableButtonLongPressed() {return}
|
||||
if horizontalGuideline.superview == nil {
|
||||
@@ -4055,9 +4067,15 @@ import ObjectiveC.runtime
|
||||
var verticallyAligned = false
|
||||
widget.forEachWidget{ otherWidget in
|
||||
guard otherWidget != widget else {return}
|
||||
|
||||
if widget.isFolder, widget.bulkMoveEnabled, widget.sequenceSet.contains(otherWidget.sequence) {return}
|
||||
verticallyAligned = verticallyAligned ? verticallyAligned : widget.center.x > otherWidget.center.x-1 && widget.center.x < otherWidget.center.x+1
|
||||
horizontallyAligned = horizontallyAligned ? horizontallyAligned : widget.center.y > otherWidget.center.y-1 && widget.center.y < otherWidget.center.y+1
|
||||
verticallyAligned = verticallyAligned ? verticallyAligned : widget.center.x > otherWidget.center.x-2 && widget.center.x < otherWidget.center.x+2
|
||||
OnScreenWidgetView.isVerticallyAligned = verticallyAligned;
|
||||
if verticallyAligned {OnScreenWidgetView.alignedX = otherWidget.center.x}
|
||||
|
||||
horizontallyAligned = horizontallyAligned ? horizontallyAligned : widget.center.y > otherWidget.center.y-2 && widget.center.y < otherWidget.center.y+2
|
||||
OnScreenWidgetView.isHorizontallyAligned = horizontallyAligned;
|
||||
if horizontallyAligned {OnScreenWidgetView.alignedY = otherWidget.center.y}
|
||||
}
|
||||
horizontalGuideline.backgroundColor = horizontallyAligned ? .yellow : .blue
|
||||
verticalGuideline.backgroundColor = verticallyAligned ? .yellow : .blue
|
||||
|
||||
Reference in New Issue
Block a user