Exemplo n.º 1
0
bool
TouchBlockState::UpdateSlopState(const MultiTouchInput& aInput,
                                 bool aApzcCanConsumeEvents)
{
  if (aInput.mType == MultiTouchInput::MULTITOUCH_START) {
    // this is by definition the first event in this block. If it's the first
    // touch, then we enter a slop state.
    mInSlop = (aInput.mTouches.Length() == 1);
    if (mInSlop) {
      mSlopOrigin = aInput.mTouches[0].mScreenPoint;
      TBS_LOG("%p entering slop with origin %s\n", this, Stringify(mSlopOrigin).c_str());
    }
    return false;
  }
  if (mInSlop) {
    ScreenCoord threshold = aApzcCanConsumeEvents
        ? AsyncPanZoomController::GetTouchStartTolerance()
        : ScreenCoord(gfxPrefs::APZTouchMoveTolerance() * APZCTreeManager::GetDPI());
    bool stayInSlop = (aInput.mType == MultiTouchInput::MULTITOUCH_MOVE) &&
        (aInput.mTouches.Length() == 1) &&
        ((aInput.mTouches[0].mScreenPoint - mSlopOrigin).Length() < threshold);
    if (!stayInSlop) {
      // we're out of the slop zone, and will stay out for the remainder of
      // this block
      TBS_LOG("%p exiting slop\n", this);
      mInSlop = false;
    }
  }
  return mInSlop;
}
Exemplo n.º 2
0
void Button::setPosition(u16 x, u16 y)
{
  Clickable::setPosition(x, y);
  /* update label position if it was present */
  //TODO: verify offset fomula which is not precise
  if (labelGfx.isPresent())
    labelGfx->position = ScreenCoord(x + gfx.normal->sw()/2, y + gfx.normal->sh()/2 - labelGfx->font->sh()/2);
}
Exemplo n.º 3
0
ScreenCoord Viewport::screenCoordsForTile(const LocalPlayer* player, Position p)
{
  if (!isOutsideViewport(player, p.x, p.y))
  {
    const Position v = player->getViewport();
    s16 dx = p.x - (v.x - viewportW/2);
    s16 dy = p.y - (v.y - viewportH/2);
    
    return ScreenCoord(baseX + dx*tileWidth, baseY + dy*tileHeight);
  }
  
  return ScreenCoord::INVALID;
}