void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event)
{
   if (! mActive)
      return;

   if (mProfile->mCanKeyFocus)
      setFirstResponder();

   if (mProfile->mSoundButtonDown)
      SFX->playOnce(mProfile->mSoundButtonDown);
      
   mMouseDownPoint = event.mousePoint;
   mMouseDragged = false;

   if( mUseMouseEvents )
	  onMouseDown_callback();

   //lock the mouse
   mouseLock();
   mDepressed = true;

   // If we have a double click then execute the alt command.
   if ( event.mouseClickCount == 2 )
   {
      onDoubleClick_callback();
      execAltConsoleCallback();
   }

   //update
   setUpdate();
}
bool GuiTextEditCtrl::dealWithEnter( bool clearResponder )
{
   //first validate
   if (mProfile->mReturnTab)
   {
      onLoseFirstResponder();
   }

   updateHistory(&mTextBuffer, true);
   mHistoryDirty = false;

   //next exec the alt console command
   execAltConsoleCallback();

   // Notify of Return
   onReturn_callback();

   if (mProfile->mReturnTab)
   {
      GuiCanvas *root = getRoot();
      if (root)
      {
         root->tabNext();
         return true;
      }
   }
	
	if( clearResponder )
		clearFirstResponder();

   return true;
}
Exemplo n.º 3
0
void GuiSliderCtrl::_updateThumb( F32 _value, bool snap, bool onWake, bool doCallback )
{      
   if( snap && mTicks > 0 )
   {
      // If the shift key is held, snap to the nearest tick, if any are being drawn

      F32 tickStep = (mRange.y - mRange.x) / F32(mTicks + 1);

      F32 tickSteps = (_value - mRange.x) / tickStep;
      S32 actualTick = S32(tickSteps + 0.5);

      _value = actualTick * tickStep + mRange.x;
   }
   
   // Clamp the thumb to legal values.

   if( _value < mRange.x )
      _value = mRange.x;
   if( _value > mRange.y )
      _value = mRange.y;
      
   // If value hasn't changed and this isn't the initial update on
   // waking, do nothing.

   if( mValue == _value && !onWake )
      return;

   mValue = _value;

   Point2I ext = getExtent();
	ext.x -= ( mShiftExtent + mThumbSize.x ) / 2;
   // update the bounding thumb rect
   if (getWidth() >= getHeight())
   {  // HORZ thumb
      S32 mx = (S32)((F32(ext.x) * (mValue-mRange.x) / (mRange.y-mRange.x)));
      S32 my = ext.y/2;
      if(mDisplayValue)
         my = mThumbSize.y/2;

      mThumb.point.x  = mx - (mThumbSize.x/2);
      mThumb.point.y  = my - (mThumbSize.y/2);
      mThumb.extent   = mThumbSize;
   }
   else
   {  // VERT thumb
      S32 mx = ext.x/2;
      S32 my = (S32)((F32(ext.y) * (mValue-mRange.x) / (mRange.y-mRange.x)));
      mThumb.point.x  = mx - (mThumbSize.y/2);
      mThumb.point.y  = my - (mThumbSize.x/2);
      mThumb.extent.x = mThumbSize.y;
      mThumb.extent.y = mThumbSize.x;
   }
   
   setFloatVariable(mValue);
   setUpdate();

   // Use the alt console command if you want to continually update:
   if ( !onWake && doCallback )
      execAltConsoleCallback();
}
Exemplo n.º 4
0
bool GuiTextListCtrl::onKeyDown( const GuiEvent &event )
{
   //if this control is a dead end, make sure the event stops here
   if ( !mVisible || !mActive || !mAwake )
      return true;

   S32 yDelta = 0;
   switch( event.keyCode )
   {
   case KEY_RETURN:
      execAltConsoleCallback();
      break;
   case KEY_LEFT:
   case KEY_UP:
      if ( mSelectedCell.y > 0 )
      {
         mSelectedCell.y--;
         yDelta = -mCellSize.y;
   }
      break;
   case KEY_DOWN:
   case KEY_RIGHT:
      if ( mSelectedCell.y < ( mList.size() - 1 ) )
   {
         mSelectedCell.y++;
         yDelta = mCellSize.y;
   }
      break;
   case KEY_HOME:
      if ( mList.size() )
      {
         mSelectedCell.y = 0;
         yDelta = -(mCellSize.y * mList.size() + 1 );
      }
      break;
   case KEY_END:
      if ( mList.size() )
   {
         mSelectedCell.y = mList.size() - 1;
         yDelta = (mCellSize.y * mList.size() + 1 );
      }
      break;
   case KEY_DELETE:
      if ( mSelectedCell.y >= 0 && mSelectedCell.y < mList.size() )
      onDeleteKey_callback( mList[mSelectedCell.y].id );
      break;
   default:
   return( Parent::onKeyDown( event ) );
      break;
   };

   GuiScrollCtrl* parent = dynamic_cast<GuiScrollCtrl *>(getParent());
   if ( parent )
      parent->scrollDelta( 0, yDelta );

   return ( true );



}
Exemplo n.º 5
0
void GuiGradientSwatchCtrl::onMouseDown(const GuiEvent &event)
{
   if (! mActive)
      return;

   if (mProfile->mCanKeyFocus)
      setFirstResponder();
	
	//capture current bounds and mouse down position
	mOrigBounds = getBounds();
	mMouseDownPosition = event.mousePoint;

   if(mUseMouseEvents)
      onMouseDown_callback();

   //lock the mouse
   mouseLock();
   mDepressed = true;

   // If we have a double click then execute the alt command.
   if ( event.mouseClickCount == 2 )
   {
      onDoubleClick_callback();

      execAltConsoleCallback();
   }

   setUpdate();
}
Exemplo n.º 6
0
void GuiTextEditSliderCtrl::onMouseUp(const GuiEvent &event)
{
   // If we're not active then skip out.
   if ( !mActive || !mAwake || !mVisible )
   {
      Parent::onMouseUp(event);
      return;
   }

   mMulInc = 0.0f;
   mouseUnlock();

   if ( mTextAreaHit != None )
      selectAllText();

  //if we released the mouse within this control, then the parent will call
  //the mConsoleCommand other wise we have to call it.
   Parent::onMouseUp(event);

   //if we didn't release the mouse within this control, then perform the action
   // if (!cursorInControl())
   execConsoleCallback();   
   execAltConsoleCallback();

   //Set the cursor position to where the user clicked
   mCursorPos = calculateCursorPos( event.mousePoint );

   mTextAreaHit = None;
}
Exemplo n.º 7
0
//--------------------------------------------------------------------------
void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
{
   if ((mActive && mMouseDown) || (mActive && (mDisplayMode == pDropperBackground)))
   {
      // Update the picker cross position
      if (mDisplayMode != pPallet)
         setSelectorPos(globalToLocalCoord(event.mousePoint));
   }

   if( !mActionOnMove )
      execAltConsoleCallback();
}
Exemplo n.º 8
0
//--------------------------------------------------------------------------
void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
{
   //if we released the mouse within this control, perform the action
	if (mActive && mMouseDown && (mDisplayMode != pDropperBackground)) 
      mMouseDown = false;

   if (mActive && (mDisplayMode == pDropperBackground)) 
   {
      // In a dropper, the alt command executes the mouse up action (to signal stopping)
      execAltConsoleCallback();
   }
   
   mouseUnlock();
}