Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding file/folder drop support #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025

Conversation

jmelovich
Copy link
Contributor

I wanted a good first issue to acquaint myself with this project, and since one of the frustrating parts of the build/install process was figuring out how to load presets, I figured adding good drag & drop support would be useful (as per issue #84).

SDL provides the drop event, so the implementation was fairly straightforward. The user can either drag & drop a preset file (or collection of preset files), or a folder containing presets. Preset files are files that end with '.milk' or '.prjm' (haven't seen or used prjm files but they are listed as supported in the projectM code). Dragging a file will immediately enqueue it on the next spot in the playlist, and dragging a folder will enqueue all presets in the folder (searched recursively).

I also added two configuration options to give more control to the user (split into a separate commit, as I had to add an additional include on the RenderLoop to access the configuration settings). There are now two additional UI/CLI settings:

skipToDropped (default: true)
When enabled, any dropped presets will be immediately skipped to. (They are always enqueued next after the current preset at the moment, but when this is true it will automatically skip to this next preset. This also accounts for shuffle being enabled, and will always make sure that the preset you dropped is immediately switched to.)
droppedFolderOverride (default: false)
When enabled, and a folder is dropped onto the window, the current playlist will be cleared and replaced with the contents of the folder. So if you have a playlist going and you drop a folder onto the window, the visualizer will switch and only iterate through the presets in that folder (recursively).

Resolves #84
(This issue mentions that behavior should be different depending on if the playlist editor is open or not, but unless I'm missing something I couldn't find a GUI playlist editor, so I instead added the configuration options to determine the behavior for now).

@kblaschke
Copy link
Member

Looks like a great addition! Can surely reuse this for the playlist editor, as it's probably easy enough to check whether the cursor is within the playlist editor window or not and change the behavior accordingly. ImGui only supports a basic drag & drop of items between UI elements, so this requires additional code anyways.

As with the other PR, I'll review this thoroughly when I'm back home in about ten days from now.

@kblaschke
Copy link
Member

Ignore the failing build test on macOS right now, this is due to a bug in POCO (pocoproject/poco#4798) - we have to wait for brew to update the library to 1.14.1 for this to go away.

@kblaschke kblaschke added the enhancement New feature or request label Feb 28, 2025
- dragging a preset file loads that preset into your current playlist and skips to it
- dragging a directory of presets will load all of them into the current playlist and skip to the first
- added two new settings: 'skipToDropped' & 'droppedFolderOverride' to provide more user control over the drag & drop functionality.
@kblaschke
Copy link
Member

Reviewed and tested, works pretty well, thanks!

I've squashed the last commit with the first and applied code formatting to both remaining commits and also signed them off.

@kblaschke kblaschke merged commit 9d93ead into projectM-visualizer:master Feb 28, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add file drop support
2 participants