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

Method GetModuleAt

Source/ModuleContainer.cpp:206–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206IDrawableModule* ModuleContainer::GetModuleAt(float x, float y)
207{
208 if (mOwner != nullptr)
209 {
210 float ownerX, ownerY;
211 mOwner->GetPosition(ownerX, ownerY);
212 x -= ownerX;
213 y -= ownerY;
214 }
215
216 const auto& modalItems = TheSynth->GetModalFocusItemStack();
217 for (int i = (int)modalItems.size() - 1; i >= 0; --i)
218 {
219 if (modalItems[i]->GetOwningContainer() == this && modalItems[i]->TestClick(x, y, false, true))
220 return modalItems[i];
221 }
222
223 for (int i = 0; i < mModules.size(); ++i)
224 {
225 if (mModules[i]->AlwaysOnTop() && mModules[i]->TestClick(x, y, false, true))
226 {
227 ModuleContainer* subcontainer = mModules[i]->GetContainer();
228 if (subcontainer)
229 {
230 IDrawableModule* contained = subcontainer->GetModuleAt(x - subcontainer->GetOwnerPosition().x, y - subcontainer->GetOwnerPosition().y);
231 if (contained)
232 {
233 return contained;
234 }
235 }
236 return mModules[i];
237 }
238 }
239 for (int i = 0; i < mModules.size(); ++i)
240 {
241 if (!mModules[i]->AlwaysOnTop() && mModules[i]->TestClick(x, y, false, true))
242 {
243 ModuleContainer* subcontainer = mModules[i]->GetContainer();
244 if (subcontainer)
245 {
246 IDrawableModule* contained = subcontainer->GetModuleAt(x, y);
247 if (contained)
248 {
249 return contained;
250 }
251 }
252 return mModules[i];
253 }
254 }
255 return nullptr;
256}
257
258ofVec2f ModuleContainer::GetDrawOffset()
259{

Callers 3

GetModuleAtCursorMethod · 0.80
TestHoverMethod · 0.80
GetDropTargetMethod · 0.80

Calls 8

sizeMethod · 0.80
GetOwningContainerMethod · 0.80
GetOwnerPositionMethod · 0.80
GetPositionMethod · 0.45
TestClickMethod · 0.45
AlwaysOnTopMethod · 0.45
GetContainerMethod · 0.45

Tested by 1

TestHoverMethod · 0.64