/* PUBLIC MEMBER FUNCTIONS */ bool ControlPoint::contains(const FingerEventArgs &e) const { Point2f p = e.getPosition(); assert(modelview != NULL); modelview->unTranslatePoint(p); modelview->unScalePoint(p); float distance = sqrt((p.getX() * p.getX()) + (p.getY() * p.getY())); return distance <= (width * BOUNDING_SPHERE); }
/* PUBLIC MEMBER FUNCTIONS */ bool SplineControl::contains(const FingerEventArgs &e) const { assert(modelview != NULL); Point2f p = e.getPosition(); modelview->unTranslatePoint(p); float legendDim = (height * LEGEND_DIM) * modelview->getYScale(); return p.getX() >= 0.0f && p.getX() <= (width * modelview->getXScale()) && p.getY() >= legendDim && p.getY() <= (height * modelview->getYScale()) - legendDim; }
bool SplineControl::controlPointContains(const FingerEventArgs &e) const { assert(modelview != NULL); Point2f p = e.getPosition(); modelview->unTranslatePoint(p); // use legend dim on left and right as a buffer to prevent deletion near edge float legendDim = (height * LEGEND_DIM) * modelview->getYScale(); return p.getX() >= -legendDim && p.getX() <= (width * modelview->getXScale()) + legendDim && p.getY() >= 0.0f && p.getY() <= height * modelview->getYScale(); }
bool SplineControl::isClose(const Point2f &p) { float val = getValue(p.getX()); float distance = fabs((p.getY() / height) - (1.0f - val)); return distance < (1.0f * FINGER_RANGE_FACTOR); }
void WMTouchEventSource::touchUp(TOUCHINPUT *ti) { assert(ti); if(eventCallback != NULL) { Point2f p = convert(ti); eventCallback(ti->dwID, p.getX(),p.getY(), FingerEventArgs::EventType::FINGER_REMOVED); } }
void PressAndHold::updateFingerPosition(const Point2f &newPosition) { float dx = position.getX() - newPosition.getX(); float dy = position.getY() - newPosition.getY(); float d = sqrt((dx * dx) + (dy * dy)); if(d >= THRESHOLD) { markedForDelete = true; } }
void Point2f::setPosition(const Point2f &position) { this->x = position.getX(); this->y = position.getY(); }
Point2f::Point2f(const Point2f &position) { this->x = position.getX(); this->y = position.getY(); }
void ScrollMenu::update(void) { assert(modelview != NULL); if(!selected && fingerDown && !moved) { Point2f p = down; modelview->unTranslatePoint(p); modelview->unScalePoint(p); selected = true; selectedIndex = (scrollDirection == VERTICAL) ? (unsigned int)((p.getY() / height) * (float)displayCount) : (unsigned int)((p.getX() / width) * (float)displayCount); dirty = true; } else if(selected && moved) { selected = false; dirty = true; } }