highlight touchpad widget border during resizing

This commit is contained in:
True Zhuanjia
2026-05-12 16:20:53 +08:00
parent 57dac128e2
commit 023cc0b583
3 changed files with 64 additions and 23 deletions
+10 -10
View File
@@ -2522,7 +2522,7 @@
<viewControllerLayoutGuide type="bottom" id="eaS-aj-VtA"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Acw-S4-f8a">
<rect key="frame" x="0.0" y="0.0" width="1300" height="1500"/>
<rect key="frame" x="0.0" y="0.0" width="1300" height="3000"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fZU-G0-fgM" userLabel="Toolbar Root View" customClass="ToolBarContainerView">
@@ -3483,16 +3483,16 @@
<rect key="frame" x="0.0" y="0.0" width="330" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lar-2o-R7c">
<rect key="frame" x="0.0" y="0.0" width="35" height="31"/>
<rect key="frame" x="0.0" y="0.0" width="10" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="Uly-QK-Ss9"/>
<constraint firstAttribute="width" constant="10" id="Uly-QK-Ss9"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2TR-Kd-ro4">
<rect key="frame" x="35" y="0.0" width="90" height="31"/>
<rect key="frame" x="10" y="0.0" width="90" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="QKh-al-ndE"/>
</constraints>
@@ -3525,7 +3525,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BlQ-y7-iDS">
<rect key="frame" x="125" y="0.0" width="5" height="31"/>
<rect key="frame" x="100" y="0.0" width="5" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="5" id="WKZ-kW-aww"/>
</constraints>
@@ -3534,7 +3534,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cyH-Fh-vW6">
<rect key="frame" x="130" y="0.0" width="90" height="31"/>
<rect key="frame" x="105" y="0.0" width="90" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="UeY-vl-Bq1"/>
</constraints>
@@ -3567,7 +3567,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ocb-R1-UYc">
<rect key="frame" x="220" y="0.0" width="5" height="31"/>
<rect key="frame" x="195" y="0.0" width="5" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="5" id="xI6-7Y-omo"/>
</constraints>
@@ -3576,9 +3576,9 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aGh-QR-gBW">
<rect key="frame" x="225" y="0.0" width="100" height="31"/>
<rect key="frame" x="200" y="0.0" width="125" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="Osk-FF-3gf"/>
<constraint firstAttribute="width" constant="120" id="Osk-FF-3gf"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Button">
@@ -3662,7 +3662,7 @@
</view>
<toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<size key="freeformSize" width="1300" height="1500"/>
<size key="freeformSize" width="1300" height="3000"/>
<connections>
<outlet property="addButton" destination="fKN-ja-TRi" id="R2n-QF-aSj"/>
<outlet property="anchorModeSelector" destination="PSA-W8-aR5" id="8Et-5Y-7oF"/>
+41 -9
View File
@@ -105,8 +105,33 @@ import ObjectiveC.runtime
private var comboKeyTimeIntervalMs: UInt32 = 0
@objc public var logicallyDown: Bool = false
@objc public var widthFactor: CGFloat = 1.0
@objc public var heightFactor: CGFloat = 1.0
@objc public var isBeingResized: Bool = false
@objc public var widthFactor: CGFloat = 1.0 {
didSet{
isBeingResized = true
self.resizeWidgetView()
if OnScreenWidgetView.editMode {self.highlightBorderDuringResizing()}
}
}
@objc public var heightFactor: CGFloat = 1.0 {
didSet{
isBeingResized = true
self.resizeWidgetView()
if OnScreenWidgetView.editMode {self.highlightBorderDuringResizing()}
}
}
private func highlightBorderDuringResizing() {
if widgetType == .touchPad {
self.highlightBorder(highlighted: true, color: standardHighlightColor.cgColor)
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
if !self.isBeingResized {
self.highlightBorder(highlighted: false)
}
}
}
}
@objc public var componentSizeFactor: CGFloat = 2.88 {
didSet{
if self.isStickWheel {
@@ -751,8 +776,8 @@ import ObjectiveC.runtime
translatesAutoresizingMaskIntoConstraints = false
// replace invalid factor values
if self.widthFactor == 0 {self.widthFactor = 1.0}
if self.heightFactor == 0 {self.heightFactor = 1.0}
// if self.widthFactor == 0 {self.widthFactor = 1.0}
// if self.heightFactor == 0 {self.heightFactor = 1.0}
/*
NSLayoutConstraint.activate([
@@ -3522,9 +3547,11 @@ import ObjectiveC.runtime
widget.isUserInteractionEnabled = false
if ((folder.buttonMode != .slideAndHold && widget.widgetType == .touchPad)
|| abs(widget.backgroundAlpha) < 0.1){
widget.highlightBorder(highlighted: true, color: UIColor.systemBlue.cgColor)
widget.highlightBorder(highlighted: folder.animatesTransition, color: UIColor.systemBlue.cgColor)
}
let duration = OnScreenWidgetView.enableFolderAnimation ? (folder.buttonMode == .slideAndHold ? 0.05 : widget.standardFoldingInterval) : 0
let duration = (OnScreenWidgetView.enableFolderAnimation && folder.animatesTransition)
? (folder.buttonMode == .slideAndHold ? 0.05 : widget.standardFoldingInterval)
: 0
UIView.animate(withDuration: duration, animations: {
widget.center = folder.center
},completion: { finished in
@@ -3549,9 +3576,12 @@ import ObjectiveC.runtime
widget.isHidden = false
if ((folder.buttonMode != .slideAndHold && widget.widgetType == .touchPad)
|| abs(widget.backgroundAlpha) < 0.1){
widget.highlightBorder(highlighted: true, color: UIColor.systemBlue.cgColor)
widget.highlightBorder(highlighted: folder.animatesTransition, color: UIColor.systemBlue.cgColor)
}
UIView.animate(withDuration: OnScreenWidgetView.enableFolderAnimation ? (folder.buttonMode == .slideAndHold ? 0.05 : widget.standardFoldingInterval) : 0, animations: {
UIView.animate(withDuration: (OnScreenWidgetView.enableFolderAnimation && folder.animatesTransition)
? (folder.buttonMode == .slideAndHold ? 0.05 : widget.standardFoldingInterval)
: 0
, animations: {
widget.center = widget.storedCenter
},completion: { finished in
widget.capturedTouches.removeAllObjects()
@@ -3560,7 +3590,9 @@ import ObjectiveC.runtime
widget.isHidden = folder.folded
if ((folder.buttonMode != .slideAndHold && widget.widgetType == .touchPad)
|| abs(widget.backgroundAlpha) < 0.1){
widget.highlightBorder(highlighted: false)
DispatchQueue.main.asyncAfter(deadline: .now() + (widget.widgetType == .touchPad ? 0.15 : 0)) {
widget.highlightBorder(highlighted: false)
}
}
if widget.hasNonEditableLabel {widget.setupAtrributedText()}
})
@@ -971,7 +971,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
mouseDownButtonStack.isHidden = !widgetView.isMousePadWithButtonActions
mouseButtonDownSelector.selectedSegmentIndex = Int(widgetView.mouseButtonAction.rawValue)
animatedStack.isHidden = !widgetView.isMagnifier
animatedStack.isHidden = !(widgetView.isMagnifier || widgetView.isFolder)
animatedSelector.selectedSegmentIndex = widgetView.animatesTransition ? 1 : 0
autoDockTimerStack.isHidden = !(widgetView.isFolder && widgetView.parentSequence == -1);
@@ -1722,11 +1722,15 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
}
widgetSizeSlider.addTarget(self, action: #selector(widgetSizeSliderMoved(_:)), for: .valueChanged)
widgetSizeSlider.addTarget(self, action: #selector(widgetSizeSliderTouchUp(_:)), for: [.touchUpInside, .touchUpOutside])
widgetSizeLabel.text = LocalizationHelper.localizedString(forKey: "Size")
widgetSizeStack.isHidden = true
widgetHeightSlider.addTarget(self, action: #selector(widgetHeightSliderMoved(_:)), for: .valueChanged)
widgetHeightSlider.addTarget(self, action: #selector(widgetSizeSliderTouchUp(_:)), for: [.touchUpInside, .touchUpOutside])
widgetHeightLabel.text = LocalizationHelper.localizedString(forKey: "Height")
widgetHeightStack.isHidden = true
componentSizeSlider.addTarget(self, action: #selector(componentSizeSliderMoved(_:)), for: .valueChanged)
componentSizeLabel.text = LocalizationHelper.localizedString(forKey: "Component size")
componentSizeStack.isHidden = true
@@ -1922,12 +1926,19 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
selectedWidgetView.translatesAutoresizingMaskIntoConstraints = true
selectedWidgetView.widthFactor = CGFloat(sender.value)
selectedWidgetView.heightFactor = CGFloat(sender.value)
selectedWidgetView.resizeWidgetView()
}
if let selectedControllerLayer, controllerLayerSelected {
layoutOSC.resizeControllerLayer(with: selectedControllerLayer, and: CGFloat(sender.value))
}
}
@objc private func widgetSizeSliderTouchUp(_ sender: UISlider) {
if let selectedWidgetView, widgetViewSelected {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
selectedWidgetView.isBeingResized = false
}
}
}
@objc private func widgetHeightSliderMoved(_ sender: UISlider) {
widgetHeightLabel.text = LocalizationHelper.localizedString(forKey: "Height: %.2f", sender.value)
@@ -1935,7 +1946,6 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
selectedWidgetView.translatesAutoresizingMaskIntoConstraints = true
if selectedWidgetView.shape == "round" { return }
selectedWidgetView.heightFactor = CGFloat(sender.value)
selectedWidgetView.resizeWidgetView()
}
}
@@ -1944,7 +1954,6 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
if let selectedWidgetView, widgetViewSelected {
selectedWidgetView.translatesAutoresizingMaskIntoConstraints = true
selectedWidgetView.componentSizeFactor = CGFloat(sender.value)
// selectedWidgetView.resizeWidgetView()
}
}