enable track point for onscreen widget edit mode

This commit is contained in:
True Zhuanjia committed 2026-03-04 13:06:22 +08:00
1 parent 8cd366d2cd
commit acc89dba39
2 files changed
+32 -19

No files matched your search

+16 -16
View File
@@ -1898,6 +1898,12 @@ import SVGKit
OnScreenWidgetView.updateStreamViewGuidelines(for: self)
}
}
}
// here is in edit mode:
else{
self.handleButtonDown()
NotificationCenter.default.post(name: Notification.Name("OnScreenWidgetViewSelected"),object: self) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification
}
if self.hasTrackPoint, OnScreenWidgetView.trackPointEnabled {
CATransaction.begin()
@@ -1909,12 +1915,6 @@ import SVGKit
CATransaction.commit()
}
}
// here is in edit mode:
else{
self.handleButtonDown()
NotificationCenter.default.post(name: Notification.Name("OnScreenWidgetViewSelected"),object: self) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification
}
}
private func moveByTouch(touch: UITouch){
let currentLocation: CGPoint
@@ -2108,6 +2108,16 @@ import SVGKit
self.moveByTouch(touch: touch)
}
}
}
// Move the widgetView based on touch movement in relocation mode
if OnScreenWidgetView.editMode {
if let touch = touches.first {
self.moveByTouch(touch: touch)
}
self.lrudIndicatorBall.removeFromSuperlayer()
self.crossMarkLayer.removeFromSuperlayer()
}
if self.hasTrackPoint, OnScreenWidgetView.trackPointEnabled {
if let touch = touches.first {
@@ -2122,16 +2132,6 @@ import SVGKit
}
}
// Move the widgetView based on touch movement in relocation mode
if OnScreenWidgetView.editMode {
if let touch = touches.first {
self.moveByTouch(touch: touch)
}
self.lrudIndicatorBall.removeFromSuperlayer()
self.crossMarkLayer.removeFromSuperlayer()
}
}
func isAdjacentPoints(_ currentPoint: CGPoint, from originalPoint: CGPoint, tolerance: CGFloat) -> Bool {
let distance = hypot(originalPoint.x - currentPoint.x, originalPoint.y - currentPoint.y)
let threshold = hypot(tolerance, tolerance)
@@ -56,6 +56,7 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
bool widgetViewSelected;
bool controllerLayerSelected;
bool viewWillBeResized;
bool originalTrackPointEnabled;
__weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPhone;
__weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPad;
UIColor* trashCanStoryBoardColor;
@@ -150,6 +151,12 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
// _activeCustomOscButtonPositionDict will be updated every time when the osc profile is reloaded
OSCProfile *oscProfile = [self->profilesManager getSelectedProfile]; //returns the currently selected OSCProfile
NSLog(@"reloadOnScreenWidgets %lu", oscProfile.buttonStatesEncoded.count);
if(!_quickSwitchEnabled){
self->originalTrackPointEnabled = OnScreenWidgetView.trackPointEnabled;
OnScreenWidgetView.trackPointEnabled = true;
}
bool hasLegacyWidget = false;
for (NSData *buttonStateEncoded in oscProfile.buttonStatesEncoded) {
// OnScreenButtonState* buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
@@ -566,7 +573,9 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
- (IBAction) closeTapped:(id)sender {
[self clearSickInput];
[self dismissViewControllerAnimated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:^{
OnScreenWidgetView.trackPointEnabled = self->originalTrackPointEnabled;
}];
}
- (IBAction) trashCanTapped:(id)sender {
@@ -1717,7 +1726,11 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
}
- (void)handleProfileTablViewDismiss{
if(_quickSwitchEnabled) [self dismissViewControllerAnimated:NO completion:nil];
if(_quickSwitchEnabled){
[self clearOnScreenWidgets];
[self dismissViewControllerAnimated:NO completion:^{
}];
}
else [self setupWidgetPanel];
// setup: current profile lable, button width slider, button height slider & button alpha slider
}
@@ -1772,7 +1785,7 @@ typedef NS_ENUM(NSUInteger, DecelerationRateSliderMode) {
__weak typeof(self) weakSelf = self;
_oscProfilesTableViewController.needToUpdateOscLayoutTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC ofile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the proffile and then hide/show and move each OSC button to their appropriate position
if(!pickProfile || true) [weakSelf reloadOnScreenWidgetViews];
if(!pickProfile) [weakSelf reloadOnScreenWidgetViews];
};
self.widgetPanelStack.hidden = YES;