Skip to content

Commit bafe8a0

Browse files
committed
iOS improvements: implement FS listener, improved touch behaviour, fix more file permission issues
1 parent 9f1444e commit bafe8a0

23 files changed

Lines changed: 276 additions & 35 deletions

Source/Canvas.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,6 +2720,7 @@ bool Canvas::panningModifierDown() const
27202720
#if JUCE_IOS
27212721
return OSUtils::ScrollTracker::isScrolling();
27222722
#endif
2723+
27232724
auto const& commandManager = editor->commandManager;
27242725
// check the command manager for the keycode that is assigned to pan drag key
27252726
auto const panDragKeycode = commandManager.getKeyMappings()->getKeyPressesAssignedToCommand(CommandIDs::PanDragKey).getFirst().getKeyCode();

Source/CanvasViewport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class CanvasViewport final : public Viewport
596596
}
597597

598598
void mouseWheelMove(MouseEvent const& e, MouseWheelDetails const& wheel) override
599-
{
599+
{
600600
// Check event time to filter out duplicate events
601601
// This is a workaround for a bug in JUCE that can cause mouse events to be duplicated when an object has a MouseListener on its parent
602602
if (e.eventTime == lastScrollTime)

Source/Components/BouncingViewport.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,24 @@ class BouncingViewportAttachment final : public MouseListener
1818
}
1919

2020
~BouncingViewportAttachment() override = default;
21+
22+
#if JUCE_IOS
23+
void mouseDrag(MouseEvent const& e) override
24+
{
25+
if(e.getDistanceFromDragStart() > 8) {
26+
OSUtils::ScrollTracker::setAllowOneFingerScroll(true);
27+
}
28+
}
29+
#endif
2130

2231
void mouseWheelMove(MouseEvent const& e, MouseWheelDetails const& wheel) override
2332
{
2433
if (!isBounceable)
2534
return;
26-
2735
// Protect against receiving the same even twice
2836
if (e.eventTime == lastScrollTime)
2937
return;
30-
38+
3139
lastScrollTime = e.eventTime;
3240

3341
auto const deltaY = rescaleMouseWheelDistance(wheel.deltaY);

Source/Components/PropertiesPanel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ void PropertiesPanel::BoolComponent::mouseExit(MouseEvent const& e)
405405

406406
void PropertiesPanel::BoolComponent::mouseUp(MouseEvent const& e)
407407
{
408+
if(!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
409+
return;
410+
408411
toggleStateValue.setValue(!getValue<bool>(toggleStateValue));
409412
repaint();
410413
}

Source/Components/WelcomePanel.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class WelcomePanel final : public Component
7474

7575
void mouseUp(MouseEvent const& e) override
7676
{
77+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
78+
return;
79+
7780
if (clearButtonBounds.contains(e.getPosition())) {
7881
auto const settingsTree = SettingsFile::getInstance()->getValueTree();
7982
settingsTree.getChildWithName("RecentlyOpened").removeAllChildren(nullptr);
@@ -219,8 +222,8 @@ class WelcomePanel final : public Component
219222
{
220223
if (!getScreenBounds().reduced(12).contains(e.getScreenPosition()))
221224
return;
222-
223-
if (!e.mods.isLeftButtonDown())
225+
226+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
224227
return;
225228

226229
onClick();
@@ -633,7 +636,7 @@ class WelcomePanel final : public Component
633636

634637
void mouseUp(MouseEvent const& e) override
635638
{
636-
if (!e.mods.isLeftButtonDown())
639+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
637640
return;
638641

639642
// If the cursor is no longer over the tile, don't trigger the tile

Source/Dialogs/Dialogs.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,16 @@ void Dialogs::showOpenDialog(std::function<void(URL)> const& callback, bool cons
873873
fileChooser->launchAsync(openChooserFlags,
874874
[callback, lastFileId](FileChooser const& fileChooser) {
875875
auto const result = fileChooser.getResult();
876-
876+
auto const resultURL = fileChooser.getURLResult();
877+
877878
auto const lastDir = result.isDirectory() ? result : result.getParentDirectory();
878879
if (result.exists()) {
880+
#if JUCE_IOS
881+
// Create an input stream to access the security scoped resource
882+
auto scopedAccessStream = resultURL.createInputStream(URL::InputStreamOptions(URL::ParameterHandling::inAddress));
883+
#endif
879884
SettingsFile::getInstance()->setLastBrowserPathForId(lastFileId, lastDir);
880-
callback(fileChooser.getURLResult());
885+
callback(resultURL);
881886
}
882887
Dialogs::fileChooser = nullptr;
883888
});

Source/Dialogs/PatchStore.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,11 @@ class PatchDisplay final : public Component {
529529
repaint();
530530
}
531531

532-
void mouseDown(MouseEvent const& e) override
532+
void mouseUp(MouseEvent const& e) override
533533
{
534+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
535+
return;
536+
534537
callback(info);
535538
}
536539

Source/Dialogs/PathsSettingsPanel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class ActionButton final : public Component {
5555

5656
void mouseUp(MouseEvent const& e) override
5757
{
58+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
59+
return;
60+
5861
onClick();
5962
}
6063

Source/Dialogs/SnapSettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ class SnapSettings final : public Component {
194194

195195
void mouseUp(MouseEvent const& e) override
196196
{
197+
if (!ModifierKeys::getCurrentModifiers().isLeftButtonDown())
198+
return;
199+
197200
for (auto* group : buttonGroups) {
198201
group->dragToggledInteraction = false;
199202
group->repaint();

0 commit comments

Comments
 (0)