Beispiel #1
0
void Graph::setXAxisScale(double min, double max, bool keepRatio)
{
  setAxisScale(xBottom,min,max);
  setAxisScale(xTop,min,max);
  if (keepRatio)
  {
    double dx = getXEnd() - getXStart();
    double dy = getYEnd() - getYStart();
    double ratio = dy / dx;
    dx = max - min;
    dy = dx * ratio / 2;
    double y = (getYEnd() + getYStart()) / 2;
    setXAxisScale(y - dy, y + dy, false);
  }
} 
bool ItemListSelectUserInterface::processMenuSpecificKeys(InputCode inputCode)
{
   string inputString = InputCodeManager::inputCodeToPrintableChar(inputCode);

   if(inputString == "")
      return false;
   
   mNameSoFar.append(inputString);

   string mNameSoFarLc = lcase(mNameSoFar);

   if(stringContainsAllTheSameCharacter(mNameSoFarLc))
   {
      mSelectedIndex = getIndexOfNext(mNameSoFarLc.substr(0, 1));

      if(mNameSoFar.size() > 1 && lcase(getMenuItem(mSelectedIndex)->getValue()).substr(0, mNameSoFar.length()) != mNameSoFarLc)
         mNameSoFar = mNameSoFar.substr(0, mNameSoFar.length() - 1);    // Remove final char, the one we just added above
   }
   else
      mSelectedIndex = getIndexOfNext(mNameSoFarLc);


   mStillTypingNameTimer.reset();
   mItemSelectedWithMouse = false;

   // Move the mouse to the new selection to make things "feel better"
   MenuItemSize size = getMenuItem(mFirstVisibleItem)->getSize();
   S32 y = getYStart();

   for(S32 j = mFirstVisibleItem; j < mSelectedIndex; j++)
   {
      size = getMenuItem(j)->getSize();
      y += getTextSize(size) + getGap(size);
   }

   y += getTextSize(size) / 2;

   // WarpMouse fires a mouse event, which will cause the cursor to become visible, which we don't want.  Therefore,
   // we must resort to the kind of gimicky/hacky method of setting a flag, telling us that we should ignore the
   // next mouse event that comes our way.  It might be better to handle this at the Event level, by creating a custom
   // method called WarpMouse that adds the suppression.  At this point, however, the only place we care about this
   // is here so...  well... this works.
   SDL_WarpMouseInWindow(DisplayManager::getScreenInfo()->sdlWindow, (S32)DisplayManager::getScreenInfo()->getMousePos()->x, y);

   Cursor::disableCursor();
   mIgnoreNextMouseEvent = true;
   playBoop();

   return true;
}
Beispiel #3
0
void Graph::setYAxisScale(double min, double max, bool keepRatio)
{
  setAxisScale(yLeft,min,max);
  setAxisScale(yRight,min,max);
  if (keepRatio)
  {
    double dx = getXEnd() - getXStart();
    double dy = getYEnd() - getYStart();
    double ratio = dy / dx;
    dy = max - min;
    dx = dy / ratio / 2;
    double x = (getXEnd() + getXStart()) / 2;
    setXAxisScale(x - dx, x + dx, false);
  }
}