Skip to content

Commit 930fd4c

Browse files
committed
Remove buggy button, and delay the random selection
1 parent a161286 commit 930fd4c

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ When used several times, I get a chain
2222

2323
## Activation
2424

25-
Copy the released extension to you Bitwig extensions folder.
25+
Copy the released extension to your Bitwig extensions folder.
2626

2727
Activate it in the settings.
2828

@@ -36,15 +36,13 @@ https://user-images.githubusercontent.com/720491/177211070-ae224401-6a15-41cb-9f
3636
This extension allows users to select a random item from the browser.
3737
It could be any browser related item type, like device, plugin, wave file, preset, modulator…
3838

39-
Currently, it has tree buttons:
39+
Currently, it has two buttons:
4040
- `Select random item` opens a browser if none is already opened and selects a random item from the current opened browser.
4141

4242
- `Add current item` adds the current selected item.
4343
This is the same as `OK` in the browser.
4444
For me, it is convenient as it is close to the random button.
4545

46-
- `Surprise me!` is the same as the two others chained: opens the browser if none opened, selects a random item and adds it.
47-
4846

4947
https://user-images.githubusercontent.com/720491/177211086-69c7c208-c25e-4787-9dcc-3000ff70adce.mp4
5048

src/main/java/com/kernicpanel/browserRandomizerExtension.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,31 @@ public void init() {
2626
BrowserResultsItemBank resultsItemBank = popupBrowser.resultsColumn().createItemBank(100000);
2727

2828
documentState
29-
.getSignalSetting("Select", "browser", "Select random item")
29+
.getSignalSetting("Select", "Randomize browser selection", "Select random item")
3030
.addSignalObserver(
31-
selectRandomItem(host, popupBrowser, cursorTrack, resultsItemBank, rand, false));
31+
selectRandomItem(host, popupBrowser, cursorTrack, resultsItemBank, rand));
3232
documentState
33-
.getSignalSetting("Add", "browser", "Add current item")
33+
.getSignalSetting("Add", "Randomize browser selection", "Add current item")
3434
.addSignalObserver(popupBrowser::commit);
35-
documentState
36-
.getSignalSetting("Random", "browser", "Surprise me!")
37-
.addSignalObserver(
38-
selectRandomItem(host, popupBrowser, cursorTrack, resultsItemBank, rand, true));
3935
}
4036

4137
private NoArgsCallback selectRandomItem(
4238
ControllerHost host,
4339
PopupBrowser popupBrowser,
4440
CursorTrack cursorTrack,
4541
BrowserResultsItemBank resultsItemBank,
46-
Random rand,
47-
Boolean commit) {
42+
Random rand) {
4843
return () -> {
4944
if (!popupBrowser.exists().getAsBoolean()) {
5045
cursorTrack.endOfDeviceChainInsertionPoint().browse();
5146
}
52-
resultsItemBank
53-
.getItemAt(rand.nextInt(popupBrowser.resultsColumn().entryCount().get()))
54-
.isSelected()
55-
.set(true);
5647

57-
if (commit) {
58-
host.scheduleTask(popupBrowser::commit, 300);
59-
}
48+
host.scheduleTask(
49+
() -> {
50+
Integer random = rand.nextInt(popupBrowser.resultsColumn().entryCount().get());
51+
resultsItemBank.getItemAt(random).isSelected().set(true);
52+
},
53+
300);
6054
};
6155
}
6256

0 commit comments

Comments
 (0)