| 204 | } |
| 205 | |
| 206 | IDrawableModule* 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 | |
| 258 | ofVec2f ModuleContainer::GetDrawOffset() |
| 259 | { |