void aButton::update() { if ( !isShowing() ) return; long mouseX = userInput->getMouseX(); long mouseY = userInput->getMouseY(); if ( pointInside( mouseX, mouseY ) ) { long mouseDragX = userInput->getMouseDragX(); long mouseDragY = userInput->getMouseDragY(); if ( messageOnRelease && userInput->leftMouseReleased() && pointInside( mouseDragX, mouseDragY ) ) { press( false ); if ( getParent() ) getParent()->handleMessage( aMSG_LEFTMOUSEDOWN, data.ID ); if ( state != DISABLED && state != HIDDEN ) sndSystem->playDigitalSample( clickSFX ); else sndSystem->playDigitalSample( disabledSFX ); } if (userInput->isLeftClick()) { press( true ); if ( getParent() && !messageOnRelease && pointInside(userInput->getMouseDragX(), userInput->getMouseDragY() ) ) getParent()->handleMessage( aMSG_LEFTMOUSEDOWN, data.ID ); if ( state != DISABLED ) sndSystem->playDigitalSample( clickSFX ); else sndSystem->playDigitalSample( disabledSFX ); } else if ( userInput->getMouseLeftHeld() > holdTime && !messageOnRelease && pointInside(userInput->getMouseDragX(), userInput->getMouseDragY()) ) handleMessage( aMSG_LEFTMOUSEHELD, data.ID ); else { if ( state != HIGHLIGHT && state != DISABLED && state != HIDDEN ) sndSystem->playDigitalSample( highlightSFX ); state = HIGHLIGHT; makeUVs( location, state, data ); } } else if ( state == PRESSED && messageOnRelease ) state = ENABLED; aObject::update(); }
void LogisticsPilotListBoxItem::update() { bool isInside = pointInside(userInput->getMouseX(), userInput->getMouseY()); for(size_t i = 0; i < 3; i++) animations[i].update(); if(state == aListItem::SELECTED) { if(animations[0].getState() != aAnimGroup::PRESSED) { for(size_t i = 0; i < 3; i++) animations[i].setState(aAnimGroup::PRESSED); } if(userInput->isLeftDoubleClick() && isInside) { PilotReadyScreen::instance()->setPilot(pPilot); PilotReadyScreen::instance()->addSelectedPilot(); } if(userInput->isLeftClick() && isInside) PilotReadyScreen::instance()->setPilot(pPilot); if(userInput->isLeftDrag() && isInside && pointInside(userInput->getMouseDragX(), userInput->getMouseDragY())) { PilotReadyScreen::instance()->beginDrag(pPilot); icon.setColor(0x7f000000); } else if(!userInput->isLeftDrag()) { icon.setColor(0xffffffff); } } else if(state == aListItem::HIGHLITE) { if(animations[0].getState() != aAnimGroup::HIGHLIGHT) { for(size_t i = 0; i < 3; i++) animations[i].setState(aAnimGroup::HIGHLIGHT); } } else { if(animations[0].getState() != aAnimGroup::NORMAL) { for(size_t i = 0; i < 3; i++) animations[i].setState(aAnimGroup::NORMAL); } } aObject::update(); }
bool VoxelProjectedPolygon::occludes(const VoxelProjectedPolygon& occludee, bool checkAllInView) const { // if we are completely out of view, then we definitely don't occlude! // if the occludee is completely out of view, then we also don't occlude it // // this is true, but unfortunately, we're not quite handling projects in the // case when SOME points are in view and others are not. So, we will not consider // occlusion for any shadows that are partially in view. if (checkAllInView && (!getAllInView() || !occludee.getAllInView())) { return false; } // first check the bounding boxes, the occludee must be fully within the boounding box of this shadow if ((occludee.getMaxX() > getMaxX()) || (occludee.getMaxY() > getMaxY()) || (occludee.getMinX() < getMinX()) || (occludee.getMinY() < getMinY())) { return false; } // if we got this far, then check each vertex of the occludee, if all those points // are inside our polygon, then the tested occludee is fully occluded for(int i = 0; i < occludee.getVertexCount(); i++) { if (!pointInside(occludee.getVertex(i))) { return false; } } // if we got this far, then indeed the occludee is fully occluded by us return true; }
void Foam::surfaceToPoint::combine(topoSet& set, const bool add) const { cpuTime timer; triSurface surf(surfName_); Info<< " Read surface from " << surfName_ << " in = "<< timer.cpuTimeIncrement() << " s" << endl << endl; // Construct search engine on surface triSurfaceSearch querySurf(surf); if (includeInside_ || includeOutside_) { boolList pointInside(querySurf.calcInside(mesh_.points())); forAll(pointInside, pointI) { bool isInside = pointInside[pointI]; if ((isInside && includeInside_) || (!isInside && includeOutside_)) { addOrDelete(set, pointI, add); } }
void AttributeMeter::update() { int32_t mouseX = userInput->getMouseX(); int32_t mouseY = userInput->getMouseY(); if(pointInside(mouseX, mouseY)) ::helpTextID = helpID; }
// can be optimized with new pointInside() bool OctreeProjectedPolygon::occludes(const OctreeProjectedPolygon& occludee, bool checkAllInView) const { OctreeProjectedPolygon::occludes_calls++; // if we are completely out of view, then we definitely don't occlude! // if the occludee is completely out of view, then we also don't occlude it // // this is true, but unfortunately, we're not quite handling projects in the // case when SOME points are in view and others are not. So, we will not consider // occlusion for any shadows that are partially in view. if (checkAllInView && (!getAllInView() || !occludee.getAllInView())) { return false; } // first check the bounding boxes, the occludee must be fully within the boounding box of this shadow if ((occludee.getMaxX() > getMaxX()) || (occludee.getMaxY() > getMaxY()) || (occludee.getMinX() < getMinX()) || (occludee.getMinY() < getMinY())) { return false; } // we need to test for identity as well, because in the case of identity, none of the points // will be "inside" but we don't want to bail early on the first non-inside point bool potentialIdenity = false; if ((occludee.getVertexCount() == getVertexCount()) && (getBoundingBox().contains(occludee.getBoundingBox())) ) { potentialIdenity = true; } // if we got this far, then check each vertex of the occludee, if all those points // are inside our polygon, then the tested occludee is fully occluded int pointsInside = 0; for(int i = 0; i < occludee.getVertexCount(); i++) { bool vertexMatched = false; if (!pointInside(occludee.getVertex(i), &vertexMatched)) { // so the point we just tested isn't inside, but it might have matched a vertex // if it didn't match a vertext, then we bail because we can't be an identity // or if we're not expecting identity, then we also bail early, no matter what if (!potentialIdenity || !vertexMatched) { return false; } } else { pointsInside++; } } // we're only here if all points are inside matched and/or we had a potentialIdentity we need to check if (pointsInside == occludee.getVertexCount()) { return true; } // If we have the potential for identity, then test to see if we match, if we match, we occlude if (potentialIdenity) { return matches(occludee); } return false; // if we got this far, then we're not occluded }
void aObject::update() { int32_t x = userInput->getMouseX(); int32_t y = userInput->getMouseY(); if (pointInside(x, y) && helpID && isShowing()) { helpTextID = helpID; } // call update for the children for (size_t i = 0; i < nNumberOfChildren; i++) pChildren[i]->update(); }
bool Aspring::handleEvent(Aevent* evt) { if(evt->Type == MOUSE_PRESS_EVENT) { Vec3f localPoint = globalToLocal(evt->mousePos); if( pointInside( localPoint )){ if(COLLIDER->mEditor != NULL) COLLIDER->mEditor->registerSpring(this); return true; } } return false; }
void NodeControl::onDrag(APoint m_pos, AVec d_pos) { APoint p_m_pos = m_pos + pos; if(valid(Mouse::getButtonStates() & NODEGRAPH_MOVE_NODES_BTN)) { ngd_parent->moveSelectedNodes(d_pos);//ngd_parent->absoluteToVirtualVec(d_pos)); //move(transformVec(d_pos, TSpace::O_VIRTUAL, TSpace::O_PARENT)); } else if(pointInside(p_m_pos)) { ngd_parent->onControlDrag(this, p_m_pos); } }
//------------------------------------------------------------------------------ bool Rect::boundLine (Point& p1, Point& p2) const { if (pointInside (p1) && pointInside (p2)) return true; double u1 = 0.0; double u2 = 1.0; double dx = p2.h - p1.h; double dy; if (boundLineClipTest (-dx, p1.h - left, &u1, &u2)) { if (boundLineClipTest (dx, right - p1.h, &u1, &u2)) { dy = p2.v - p1.v; if (boundLineClipTest (-dy, p1.v - top, &u1, &u2)) { if (boundLineClipTest (dy, bottom - p1.v, &u1, &u2)) { if (u2 < 1.0) { p2.h = p1.h + (UCoord)(u2 * dx); p2.v = p1.v + (UCoord)(u2 * dy); } if (u1 > 0.0) { p1.h += (UCoord)(u1 * dx); p1.v += (UCoord)(u1 * dy); } return true; } } } } return false; }
aObject* aObject::findObject(int32_t xPos, int32_t yPos) { aObject* target; if (showWindow) { for (size_t i = nNumberOfChildren; i > 0; i--) { target = pChildren[i - 1]->findObject(xPos, yPos); if (target) return target; } } if (showWindow && pointInside(xPos, yPos)) return (this); return nullptr; }
void MenuBar::onMouseDown(APoint m_pos, MouseButton b, bool direct) { if(direct) { closeAllMenus(); } else if(pointInside(m_pos)) { for(auto mb : menuButtons) if(mb->pointInside(m_pos)) return; //If not over any of the buttons, close menus closeAllMenus(); } }
void aDropList::update() { if ( showWindow ) { aObject::update(); if (userInput->isLeftClick()) { int cx = userInput->getMouseX(); int cy = userInput->getMouseY(); if (expandButton.pointInside(cx, cy)) { handleMessage(aMSG_BUTTONCLICKED, (unsigned long)(&expandButton)); } // lose focus if appropriate if ( ListBox().isShowing() && ( !pointInside( userInput->getMouseX(), userInput->getMouseY() ) || ( ListBox().pointInside(userInput->getMouseX(), userInput->getMouseY() ) && !ListBox().pointInScrollBar(userInput->getMouseX(), userInput->getMouseY() ) ) ) ) { listBox.showGUIWindow(false); rects[2].showGUIWindow(false); } } if (0 <= ListBox().GetSelectedItem()) { selectionIndex = ListBox().GetSelectedItem(); if (listBox.isShowing()) { IsExpanded(false); } ListBox().SelectItem(-1); } else if (listBox.isShowing()) { if (userInput->getKeyDown( KEY_RETURN ) ) { listBox.showGUIWindow(false); rects[2].showGUIWindow(false); } } } ListBox().setHelpID( helpID ); }
void SpecialtyListItem::update() { normalAnim.update(); unsigned long color = normalAnim.getColor(); if ( PilotReviewScreen::s_curPromotion ) { aListBox* skillListBox = PilotReviewScreen::s_curPromotion->getSkillListBox(); if ( skillListBox && skillListBox->pointInside(userInput->getMouseX(), userInput->getMouseY() ) ) aObject::update(); if ( userInput->isLeftClick() && pointInside( userInput->getMouseX(), userInput->getMouseY() ) && ( skillListBox && skillListBox->pointInside(userInput->getMouseX(), userInput->getMouseY() ) ) ) { state = SELECTED; if ( !radioButton.isPressed() ) radioButton.press( true ); pressedAnim.begin(); } } // set the texts and colors appropriately if ( state == SELECTED ) { if ( !radioButton.isPressed() ) radioButton.press( true ); if ( !pressedAnim.isAnimating() ) pressedAnim.begin(); pressedAnim.update(); color = pressedAnim.getColor(); } else if ( state == HIGHLITE ) { if ( !highlightAnim.isAnimating() ) highlightAnim.begin(); highlightAnim.update(); color = highlightAnim.getColor(); } setColor( color, true ); // make sure the background stays black setColor( 0xff000000, 0 ); }
void NodeConnectionControl::onDrag(APoint m_pos, AVec d_pos) { if(fromNode && toNode) { APoint m_pos_grid = m_pos + pos; float dist = distToLine(m_pos); //std::cout << dist << "\n"; //std::cout << "(" << pTo.x << ", " << pTo.y << "), (" << pFrom.x << ", " << pFrom.y << "), (" << m_pos.x << ", " << m_pos.y << ")\n"; //std::cout << dist << " (" << disconnectRadius << ")\n"; if(dist > disconnectRadius || !pointInside(m_pos)) { AVec d_pos_from = pFrom - m_pos, d_pos_to = pTo - m_pos; float to_dist_2 = d_pos_to.x*d_pos_to.x + d_pos_to.y*d_pos_to.y, from_dist_2 = d_pos_from.x*d_pos_from.x + d_pos_from.y*d_pos_from.y; AStatus status = fromNc->disconnect(toNc); if(!statusGood(status)) { std::cout << status << "\n"; return; } if(to_dist_2 < from_dist_2) { toNode = nullptr; toNc = nullptr; ngd_parent->restartConnectingNodes(this, fromNode, fromNc->getId()); } else { fromNode = nullptr; fromNc = nullptr; ngd_parent->restartConnectingNodes(this, toNode, toNc->getId()); } setHangingPos(m_pos); } } }
bool BoundingCircle::intersects2D(const BoundingObject2D& bounding_obj) const { switch (bounding_obj.getObjectType()) { case BOX: { Point p; p.setU( minimum ( maximum( position.getU(projectAxis), bounding_obj.minU() ), bounding_obj.maxU() ), projectAxis ); p.setV( minimum ( maximum( position.getV(projectAxis), bounding_obj.minV() ), bounding_obj.maxV() ), projectAxis ); return pointInside(p); } case CIRCLE: return ( (position.distance(bounding_obj.centroid())- ((const BoundingCircle&)bounding_obj).getRadius()) <= radius ); case TRIANGLE: //NOT IMPLEMENTED return false; case PLANE: //NOT IMPLEMENTED return false; case CONVEX_HULL: //NOT IMPLEMENTED return false; default: break; } return bounding_obj.intersects2D(*this); }
bool InputEvent::pointInside(float x,float y,float& ox,float &oy) { if (!getEnabled()) { ox=-1; oy=-1; return false; } if (!getObject()) { ox=x; oy=y; return true; } auto trans = getObject()->getTransInWorld(); if (trans) { return trans->pointInside(x, y,ox,oy); } ox=-1; oy=-1; return false; }
bool Afileexplorer::handleEvent(Aevent* evt) { if(evt->Type == MOUSE_PRESS_EVENT ) { Vec3f localPoint = globalToLocal(evt->mousePos); if( pointInside( localPoint )) { //! Not threaded... try { std::string p = getOpenFilePath( CMN->rootResourcePath ); if( ! p.empty() ) { // an empty string means the user canceled FilePath->makeTexture( p ); } } catch( ... ) { console() << "Afileexplorer experienced an event error" << std::endl; return false; } return true; } } return false; }
void NodeGraphDisplay::onMouseUp(APoint m_pos, MouseButton b) { if(pointInside(m_pos)) { if(draggedNode)// && valid(b & NODEGRAPH_CONNECT_NODES_BTN)) { std::cout << "NODE CONNECTING WAS INTERRUPTED!\n"; //Except not really... draggedNode = nullptr; draggedConnector = 0; removeConnection(connectionIndex); connectionIndex = -1; } else if(selectionRect.space != TSpace::INVALID && valid(b & NODEGRAPH_SELECT_NODES_BTN)) { /* if(selectedControls.size() > 0) { //Choose which selected control is in focus //selectedControls[selectedControls.size() - 1]->setFocus(true); if(propDisp) propDisp->setActiveNode(chooseActiveNode()); } else if(propDisp) { //No selected controls propDisp->setActiveNode(nullptr); } */ setActiveNode(chooseActiveNode()); selectionRect.space = TSpace::INVALID; } } }
void aListBox::update() { if ( showWindow ) { /* if the listbox is invisible, then we probably don't want to update it either */ if ( scrollBar ) scrollBar->update(); int prevCheck = GetCheckedItem(); int newCheck = -1; int iSel = -1; int iHighlight = -1; long mouseX = userInput->getMouseX(); long mouseY = userInput->getMouseY(); bool bInside = pointInside( mouseX, mouseY ); if ( bInside && helpID ) { ::helpTextID = helpID; } for ( int i = 0; i < itemCount; i++ ) { if ( bInside && items[i]->pointInside(mouseX, mouseY) && items[i]->isShowing() && items[i]->getState() != aListItem::DISABLED ) { if ( userInput->isLeftClick() ) { iSel = i; if ( items[i]->getState() != aListItem::SELECTED ) g_soundSystem->playDigitalSample( clickSFX ); } else { iHighlight = i; } } if ( items[i]->globalBottom() > globalTop() && items[i]->globalTop() < globalBottom() ) { items[i]->showGUIWindow( 1 ); } else { items[i]->showGUIWindow( 0 ); } } for ( i = 0; i < itemCount; i++ ) { if ( iSel == i ) { items[i]->setState( aListItem::SELECTED ); itemSelected = i; } else if ( iHighlight == i && items[i]->getState() != aListItem::SELECTED ) { if ( items[i]->getState() != aListItem::HIGHLITE ) g_soundSystem->playDigitalSample( highlightSFX ); items[i]->setState( aListItem::HIGHLITE ); } else if ( (iSel != -1 || items[i]->getState() != aListItem::SELECTED) && items[i]->getState() != aListItem::DISABLED ) items[i]->setState( aListItem::ENABLED ); items[i]->update(); } for ( i = 0; i < itemCount; i++ ) { if ( items[i]->isChecked() && i != prevCheck ) { newCheck = i; } } if ( singleCheck && newCheck != -1 && prevCheck != -1) { items[prevCheck]->setCheck( 0 ); } } }
void aComboBox::update() { if ( showWindow ) { aObject::update(); if (userInput->isLeftClick()) { int cx = userInput->getMouseX(); int cy = userInput->getMouseY(); if (expandButton.pointInside(cx, cy)) { handleMessage(aMSG_BUTTONCLICKED, (unsigned long)(&expandButton)); } // lose focus if appropriate else if ( ListBox().isShowing() && ( !pointInside( userInput->getMouseX(), userInput->getMouseY() ) || ( ListBox().pointInside(userInput->getMouseX(), userInput->getMouseY() ) ) && !ListBox().pointInScrollBar(userInput->getMouseX(), userInput->getMouseY()) ) ) { listBox.showGUIWindow(false); rects[2].showGUIWindow(false); } } if (0 <= ListBox().GetSelectedItem()) { selectionIndex = ListBox().GetSelectedItem(); aListItem *pListItem = ListBox().GetItem(selectionIndex); aTextListItem *pTextListItem = dynamic_cast<aTextListItem *>(pListItem); if (0 != pTextListItem) { entry.setEntry(pTextListItem->getText()); } if ( pListItem ) { if (listBox.isShowing()) { listBox.showGUIWindow(false); rects[2].showGUIWindow(false); } if ( getParent() ) getParent()->handleMessage( aMSG_SELCHANGED, ID ); } ListBox().SelectItem(-1); } else if (listBox.isShowing()) { if (userInput->getKeyDown( KEY_RETURN ) ) { listBox.showGUIWindow(false); rects[2].showGUIWindow(false); } } } ListBox().setHelpID( helpID ); }
void ComponentListItem::update() { int32_t bCanAdd = MechLabScreen::instance()->canAddComponent(pComponent); for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) { animations[i].update(); } bool isInside = pointInside(userInput->getMouseX(), userInput->getMouseY()); if(state == aListItem::SELECTED) { if((userInput->isLeftClick() && isInside) || (animations[0].getState() != aAnimGroup::PRESSED) && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) { setComponent(); if(bCanAdd) { soundSystem->playDigitalSample(LOG_WRONGBUTTON); } ::helpTextID = IDS_HELP_COMP0 + pComponent->getID(); } if(!bCanAdd) { if(animations[0].getState() != aAnimGroup::PRESSED) { for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) { animations[i].setState(aAnimGroup::PRESSED); } } if(isInside && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) { ::helpTextID = IDS_HELP_COMP0 + pComponent->getID(); } disabledText.setText(""); } else { for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) animations[i].setState(aAnimGroup::DISABLED); if(COMPONENT_TOO_HOT == bCanAdd) { disabledText.setText(IDS_MC_COMPONENT_TOO_HOT); } else if(NO_MORE_ARMOR == bCanAdd) { disabledText.setText(IDS_MC_COMPONENT_TOO_MUCH_ARMOR); } else disabledText.setText(""); } if(!bCanAdd) { if(userInput->isLeftDrag() && isInside && pointInside(userInput->getMouseDragX(), userInput->getMouseDragY()) && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) startDrag(); } } else if(isInside && !bCanAdd && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) { if(animations[0].getState() != aAnimGroup::HIGHLIGHT) { for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) { animations[i].setState(aAnimGroup::HIGHLIGHT); } soundSystem->playDigitalSample(LOG_HIGHLIGHTBUTTONS); } state = aListItem::HIGHLITE; ::helpTextID = IDS_HELP_COMP0 + pComponent->getID(); } else if(!bCanAdd) { state = aListItem::ENABLED; for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) animations[i].setState(aAnimGroup::NORMAL); disabledText.setText(""); } else { state = DISABLED; if(isInside && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) ::helpTextID = IDS_HELP_COMP0 + pComponent->getID(); if((userInput->isLeftClick() && isInside && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY()))) { setComponent(); soundSystem->playDigitalSample(LOG_WRONGBUTTON); } for(size_t i = 0; i < COMP_ANIMATION_COUNT; i++) animations[i].setState(aAnimGroup::DISABLED); if(COMPONENT_TOO_HOT == bCanAdd) { disabledText.setText(IDS_MC_COMPONENT_TOO_HOT); } else if(NO_MORE_ARMOR == bCanAdd) { disabledText.setText(IDS_MC_COMPONENT_TOO_MUCH_ARMOR); } else disabledText.setText(""); } if(userInput->isLeftDoubleClick() && isInside && ComponentIconListBox::s_instance->pointInside(userInput->getMouseX(), userInput->getMouseY())) doAdd(); aObject::update(); }
void ScrollX::update() { long mouseX = userInput->getMouseX(); long mouseY = userInput->getMouseY(); if ( userInput->isLeftDrag() && lastX ) // dragging the little tab { float delta = (float)mouseX - (buttons[0]->globalX() + buttons[0]->width() ); // figure out what this translates to float physicalRange = width() - buttons[0]->width() - buttons[1]->width() - buttons[2]->width(); float RealRange = scrollMax; if ( !physicalRange ) physicalRange = RealRange; float newScrollPos = .5 + (delta)*RealRange/physicalRange; if ( newScrollPos < 0 ) newScrollPos = 0; if ( newScrollPos > scrollMax ) newScrollPos = scrollMax; getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos ); SetScrollPos( newScrollPos ); } else if ( pointInside( mouseX, mouseY ) ) { if ( userInput->isLeftClick() || gos_GetKeyStatus(KEY_LMOUSE) == KEY_HELD ) { lastX = 0; if ( buttons[2]->pointInside( mouseX, mouseY ) && buttons[2]->pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) ) lastX = mouseX; else if ( getParent() ) { buttons[2]->press( 0 ); if ( !buttons[0]->pointInside( mouseX, mouseY ) && !buttons[1]->pointInside( mouseX, mouseY ) && pointInside(userInput->getMouseDragX(), userInput->getMouseDragY()) ) { float physicalRange = width() - buttons[0]->width() - buttons[1]->width() - buttons[2]->width(); float RealRange = scrollMax; float delta = (float)mouseX - (buttons[0]->globalX() + buttons[0]->width()); // if above the thumb, page up, otherwise page down if ( mouseY < buttons[2]->top() ) { float newScrollPos = (delta)*RealRange/physicalRange; if ( scrollPos - newScrollPos > pageInc ) { newScrollPos = scrollPos - pageInc; } getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos ); SetScrollPos( newScrollPos ); } else { float newScrollPos = (delta)*RealRange/physicalRange; if ( newScrollPos - scrollPos > pageInc ) { newScrollPos = scrollPos + pageInc; } getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos ); SetScrollPos( newScrollPos ); } } } } else buttons[2]->press( 0 ); } else buttons[2]->press( 0 ); if ( userInput->leftMouseReleased() ) lastX = 0; aObject::update(); }
bool Shape::pointInside(const lalge::R2Vector& point) const { return pointInside(point.x(0), point.x(1)); }
void NodeControl::onMouseUp(APoint m_pos, MouseButton b) { if(pointInside(m_pos))// && valid(b & NODEGRAPH_CONNECT_NODES_BTN)) ngd_parent->finishConnectingNodes(this); }
//------------------------------------------------------------------------------ bool Rect::lineInside (const Point& p1, const Point& p2) const { return pointInside (p1) && pointInside (p2); }
bool Shape::mouseDownInside() const { return pointInside(InputManager::instance()->mouseDownX(), InputManager::instance()->mouseDownY()); }
void NodeConnectorControl::onMouseUp(APoint m_pos, MouseButton b) { //TODO: Choose between which connector to connect (right click menu) if(pointInside(m_pos)) ngd->finishConnectingNodes(nc_parent); }
void NodeConnectorControl::onDrag(APoint m_pos, AVec d_pos) { if(pointInside(m_pos)) ngd->onControlDrag(nc_parent, nc_parent->virtualToAbsolutePoint(m_pos) + nc_parent->getPos()); }
void aScrollBar::update() { long mouseX = userInput->getMouseX(); long mouseY = userInput->getMouseY(); if ( userInput->isLeftDrag() && lastY ) // dragging the little tab { int tmpLastY = mouseY; tmpLastY -= userInput->getMouseDragY(); tmpLastY += lastY; float finalPos = (float)tmpLastY; // figure out what this translates to float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height() - 2.f; float RealRange = scrollMax; if ( !physicalRange ) physicalRange = RealRange; //Check for what if both of the above are zero. Probably nothing to scroll to, eh? if ((fabs(physicalRange) > Stuff::SMALL) && (fabs(RealRange) > Stuff::SMALL)) { float newScrollPos = .5 + (finalPos)*RealRange/physicalRange; if ( newScrollPos < 0 ) newScrollPos = 0; if ( newScrollPos > scrollMax ) newScrollPos = scrollMax; SetScroll( newScrollPos ); scrollTab.press( true ); } } else if ( pointInside( mouseX, mouseY ) ) { if ( userInput->isLeftClick() || gos_GetKeyStatus(KEY_LMOUSE) == KEY_HELD || userInput->leftMouseReleased() ) { lastY = 0; if ( scrollTab.pointInside( mouseX, mouseY ) && !userInput->leftMouseReleased() ) lastY = scrollTab.top() - topButton.bottom(); else if ( getParent() ) { if ( !topButton.pointInside( mouseX, mouseY ) && !bottomButton.pointInside( mouseX, mouseY ) && !topButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) && !bottomButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) && mouseY > topButton.globalBottom() && mouseY < bottomButton.globalY() && pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) && !scrollTab.pointInside( mouseX, mouseY ) && ( userInput->leftMouseReleased() || userInput->getMouseLeftHeld() > .5 ) ) { // float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height(); // float RealRange = scrollMax; // float delta = (float)mouseY - (topButton.globalY() + topButton.height()); float newScrollPos = scrollPos; // if above the thumb, page up, otherwise page down if ( mouseY < scrollTab.globalY() ) { newScrollPos = scrollPos - pageInc; } else if ( mouseY > scrollTab.globalBottom() ) { newScrollPos = scrollPos + pageInc; } if( newScrollPos < 0 ) newScrollPos = 0; if( newScrollPos > scrollMax ) newScrollPos = scrollMax; getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos ); SetScrollPos( newScrollPos ); } scrollTab.press( 0 ); } } } if ( userInput->leftMouseReleased() ) lastY = 0; aObject::update(); }