void ComponentOverlay::mouseDrag (const MouseEvent& e) { if (e.eventComponent != resizer) { bool multipleSelection = false; if (!e.mods.isPopupMenu()) { for ( ComponentOverlay* child : layoutEditor->getLassoSelection() ) { const int gridSize = 2; const int selectedCompsPosX = ((int (child->getProperties().getWithDefault ("originalX", 1)) + e.getDistanceFromDragStartX() ) / gridSize) * gridSize; const int selectedCompsPosY = ((int (child->getProperties().getWithDefault ("originalY", 1)) + e.getDistanceFromDragStartY() ) / gridSize) * gridSize; child->setTopLeftPosition (selectedCompsPosX, selectedCompsPosY); child->applyToTarget(); multipleSelection = true; } if (multipleSelection == false) { dragger.dragComponent (this, e, constrainer); applyToTarget (); } } } }
void ChildAlias::mouseDrag (const MouseEvent& e) { if (e.mods.isLeftButtonDown()){ if (e.eventComponent == resizer) { } else { if (!e.mouseWasClicked ()) { constrainer->setMinimumOnscreenAmounts(getHeight(), getWidth(), getHeight(), getWidth()); dragger.dragComponent (this,e, constrainer); applyToTarget (""); if(type.containsIgnoreCase("juce::GroupComponent")|| type.containsIgnoreCase("CabbageImage")) toBack(); } } if(type.containsIgnoreCase("juce::GroupComponent")|| type.containsIgnoreCase("CabbageImage")) toBack(); else toFront(true); }//end of left click check }
void ChildAlias::mouseUp (const MouseEvent& e) { ((CabbageMainPanel*)(getTarget()->getParentComponent()))->setMouseState("up"); if (e.eventComponent == resizer) { } else { //add this to reset MainComponent to have keyboard focus so that keyboard shortcuts (eg. lock/unlock) still work / intercept the messages getTopLevelComponent()->getChildComponent(0)->grabKeyboardFocus(); } if (userAdjusting) userStoppedChangingBounds (); userAdjusting = false; int offX = getProperties().getWithDefault(var::identifier("plantX"), 0); int offY = getProperties().getWithDefault(var::identifier("plantY"), 0); //update dimensions ((CabbageMainPanel*)(getTarget()->getParentComponent()))->currentBounds.setBounds(getPosition().getX()-offX, getPosition().getY()-offY, getWidth(), getHeight()); applyToTarget(""); ((CabbageMainPanel*)(getTarget()->getParentComponent()))->sendActionMessage("Message sent from CabbageMainPanel:Up"); if(type.containsIgnoreCase("CabbageGroupbox")|| type.containsIgnoreCase("CabbageImage")) toBack(); else toFront(true); }
void ChildAlias::resized () { resizer->setBounds (0,0,getWidth(),getHeight()); if (resizer->isMouseButtonDown ()) { applyToTarget (); } }
void ComponentOverlay::resized () { setWantsKeyboardFocus (true); resizer->setBounds (0, 0, getWidth(), getHeight()); if (resizer->isMouseButtonDown ()) { applyToTarget (); } }
bool ExtraLifeModifier::applyToTarget(RoundState& state, GameObject &target) { if (target.type() == GAME_OBJECT_PADDLE) { Paddle& paddle = static_cast<Paddle&>(target); return applyToTarget(state, paddle.player()); } if (target.type() != GAME_OBJECT_PLAYER) return false; Player& player = static_cast<Player&>(target); player.adjustLives(1); player.incrementModifierCount(modifierType()); kill(); return true; }
void ChildAlias::mouseDrag (const MouseEvent& e) { if (e.eventComponent == resizer) { } else { if (!e.mouseWasClicked ()) { dragger.dragComponent (this,e); applyToTarget (); } } }
//================================================================================================================== bool ComponentOverlay::keyPressed (const KeyPress& key, Component* originatingComponent) { bool multipleSelection = false; const int gridSize = 2; for (ComponentOverlay* child : layoutEditor->getLassoSelection()) { if (key == KeyPress::leftKey || key == KeyPress::rightKey) child->setTopLeftPosition (child->getPosition().getX() + (key == KeyPress::leftKey ? -gridSize : gridSize), child->getPosition().getY()); else if (key == KeyPress::upKey || key == KeyPress::downKey) child->setTopLeftPosition (child->getPosition().getX(), child->getPosition().getY() + (key == KeyPress::upKey ? -gridSize : gridSize)); else if (key == KeyPress (KeyPress::leftKey, ModifierKeys::shiftModifier, 0)) child->setTopLeftPosition (child->getPosition().getX() - gridSize * 4, child->getPosition().getY()); else if (key == KeyPress (KeyPress::rightKey, ModifierKeys::shiftModifier, 0)) child->setTopLeftPosition (child->getPosition().getX() + gridSize * 4, child->getPosition().getY()); else if (key == KeyPress (KeyPress::upKey, ModifierKeys::shiftModifier, 0)) child->setTopLeftPosition (child->getPosition().getX(), child->getPosition().getY() - gridSize * 4); else if (key == KeyPress (KeyPress::downKey, ModifierKeys::shiftModifier, 0)) child->setTopLeftPosition (child->getPosition().getX(), child->getPosition().getY() + gridSize * 4); child->applyToTarget(); multipleSelection = true; layoutEditor->updateSelectedComponentBounds(); } if (multipleSelection == false) { setTopLeftPosition (getPosition().getX() - gridSize, getPosition().getY()); applyToTarget(); } updateBoundsDataForTarget(); layoutEditor->updateCodeEditor(); return false; }