MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ButtonClicked

Method ButtonClicked

Source/SampleBrowser.cpp:105–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void SampleBrowser::ButtonClicked(ClickButton* button, double time)
106{
107 if (button == mBackButton)
108 ShowPage(mCurrentPage - 1);
109 if (button == mForwardButton)
110 ShowPage(mCurrentPage + 1);
111 for (int i = 0; i < (int)mButtons.size(); ++i)
112 {
113 if (button == mButtons[i] || button == mPlayButtons[i])
114 {
115 int offset = mCurrentPage * (int)mButtons.size();
116 int entryIndex = offset + i;
117 if (entryIndex < (int)mDirectoryListing.size())
118 {
119 String clicked = mDirectoryListing[entryIndex];
120 if (button == mButtons[i])
121 {
122 if (clicked == "..")
123 {
124 File dir(mCurrentDirectory);
125 if (dir.getParentDirectory().getFullPathName() != dir.getFullPathName())
126 SetDirectory(File(mCurrentDirectory).getParentDirectory().getFullPathName());
127 else
128 SetDirectory("");
129 }
130 else if (File(clicked).isDirectory())
131 {
132 SetDirectory(clicked);
133 }
134 else
135 {
136 TheSynth->GrabSample(clicked.toStdString());
137 }
138 }
139 if (button == mPlayButtons[i])
140 {
141 if (IsSamplePlaying(i))
142 {
143 mPlayingSample.Reset();
144 }
145 else
146 {
147 if (File(clicked).existsAsFile())
148 {
149 mSampleMutex.lock();
150 mPlayingSample.SetName(clicked.toStdString().c_str());
151 mPlayingSample.Read(clicked.toStdString().c_str());
152 mPlayingSample.Play(NextBufferTime(false), 1, 0);
153 mSampleMutex.unlock();
154 }
155 }
156 }
157 }
158 }
159 }
160}
161
162void SampleBrowser::Process(double time)

Callers

nothing calls this directly

Calls 7

NextBufferTimeFunction · 0.85
sizeMethod · 0.80
GrabSampleMethod · 0.45
ResetMethod · 0.45
SetNameMethod · 0.45
ReadMethod · 0.45
PlayMethod · 0.45

Tested by

no test coverage detected