Ejemplo n.º 1
0
	void UISlider::MouseOverHandler(UIDialog const & /*sender*/, uint32_t /*buttons*/, int2 const & pt)
	{
		if (pressed_)
		{
			this->SetValueInternal(ValueFromPos(x_ + pt.x() + drag_offset_));
		}
	}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Name : Dragged() 
//-----------------------------------------------------------------------------
bool CSliderUI::Dragged( POINT pt)
{
	if( m_bPressed )
	{
		SetValueInternal( ValueFromPos( m_x + pt.x + m_nDragOffset ), true );
		return true;
	}
	return false;
}
//--------------------------------------------------------------------------------------
bool CProgressBarVertical::OnMouseMove ( CVector pos )
{
	if ( m_bPressed )
	{
		SetValue ( ValueFromPos ( pos.m_nY - m_rProgress.m_pos.m_nY) );
		return true;
	}

	return false;
}
Ejemplo n.º 4
0
void CUISlider::OnMouseMove(POINT pt)
{
	if(IsPressed())
	{
		screenToClient(pt);
		pt.x+=m_ptDragOffset.x;
		pt.y+=m_ptDragOffset.y;
		SetValueInternal(ValueFromPos(pt));
	}
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------------------
bool CProgressBarHorizontal::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam )
{
	if ( !CanHaveFocus () )
		return false;

	switch ( uMsg )
	{
		case WM_MOUSEMOVE:
		{
			if ( m_bPressed )
			{
				SetValue ( ValueFromPos ( pos.GetX () - m_rProgress.pos.GetX () ) );
				return true;
			}
			break;
		}

		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		{
			if ( m_rBoundingBox.InControlArea ( pos ) )
			{
				// Pressed while inside the control
				m_bPressed = true;

				if ( m_pParent )
					m_pParent->RequestControlFocus ( this );

				m_timer.Start ( PROGRESSBAR_ARROWCLICK_START );

				if ( pos.GetX () > m_rProgress.pos.GetX () + m_rProgress.size.cx )
				{
					SetValue ( m_fValue + m_fStep );
					return true;
				}

				if ( pos.GetX () < m_rProgress.pos.GetX () + m_rProgress.size.cx )
				{
					SetValue ( m_fValue - m_fStep );
					return true;
				}

				return true;
			}
			break;
		}

		case WM_LBUTTONUP:
		{
			if ( m_bPressed )
			{
				m_bPressed = false;

				if ( m_pParent )
					m_pParent->ClearControlFocus ();

				return true;
			}
			break;
		}
	}
	return false;
}
Ejemplo n.º 6
0
//--------------------------------------------------------------------------------------
bool CTrackBarVertical::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam )
{
	if ( !CanHaveFocus () )
		return false;

	switch ( uMsg )
	{
		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		{
			if ( m_rThumb.InControlArea ( pos ) )
			{
				// Pressed while inside the control
				m_bPressed = true;

				m_nDragOffset = pos.GetY () - m_rThumb.pos.GetY ();

				if ( m_pParent && !m_bHasFocus )
					m_pParent->RequestControlFocus ( this );

				return true;
			}

			if ( m_rBoundingBox.InControlArea ( pos ) )
			{
				m_nDragOffset = 0;

				// Pressed while inside the control
				m_bPressed = true;

				if ( m_pParent && !m_bHasFocus )
					m_pParent->RequestControlFocus ( this );

				if ( pos.GetY () > m_rThumb.pos.GetY () )
				{
					SetValue ( m_nValue + 1 );
					return true;
				}

				if ( pos.GetY () < m_rThumb.pos.GetY () )
				{
					SetValue ( m_nValue - 1 );
					return true;
				}
			}

			break;
		}

		case WM_LBUTTONUP:
		{
			if ( m_bPressed )
			{
				m_bPressed = false;
				SendEvent ( EVENT_CONTROL_SELECT, m_nValue );

				if ( m_pParent )
					m_pParent->ClearControlFocus ();

				return true;
			}
			break;
		}

		case WM_MOUSEMOVE:
		{
			if ( m_bPressed )
			{
				SetValue ( ValueFromPos ( pos.GetY () - m_rBoundingBox.pos.GetY () - m_nDragOffset ) );
				return true;
			}
			break;
		}

		case WM_MOUSEWHEEL:
		{
			int nScrollAmount = int ( ( short ) HIWORD ( wParam ) ) / WHEEL_DELTA;
			SetValue ( m_nValue - nScrollAmount );
			return true;
		}
	};

	return false;
}
Ejemplo n.º 7
0
bool CGM_Slider::HandleMouseInput( CGM_InputData& input )
{
    if( !IsEnabled() || !IsVisible() )
        return false;

	SPoint pt = input.pos;
//	switch( input.code )
	switch( GetInputCode(input) )
	{
	case CGM_Input::MOUSE_BUTTON_L:
        if( input.type == CGM_InputData::TYPE_PRESSED )
		{
            if( m_ButtonRect.ContainsPoint( pt ) )
            {
                // Pressed while inside the control
                m_bPressed = true;
//				SetCapture( DXUTGetHWND() );

				m_iDragX = pt.x;
//				m_iDragY = pt.y;
				m_iDragOffset = m_iButtonX - m_iDragX;

				// m_nDragValue = m_nValue;

                if( !HasFocus() )
                    m_pDialog->RequestFocus( this );

                return true;
            }

			if( m_BoundingBox.ContainsPoint( pt ) )
			{
				// pressed inside the slider control
				if( m_iButtonX + m_BoundingBox.left < pt.x )
				{
					SetValueInternal( m_iValue + 1, true );
					return true;
				}

				if( pt.x < m_BoundingBox.left + m_iButtonX )
				{
					SetValueInternal( m_iValue - 1, true );
					return true;
				}
			}

			break;
		}

		else if( input.type == CGM_InputData::TYPE_RELEASED )
		{
			if( IsPressed() )
			{
				m_bPressed = false;
//				ReleaseCapture();

//				m_pDialog->ClearFocus();
				m_pDialog->SendEvent( CGM_Event::SLIDER_VALUE_CHANGED, true, this );

				return true;
			}
		}
		break;

	case CGM_Input::MOUSE_AXIS_X:
	case CGM_Input::MOUSE_AXIS_Y:
		if( IsPressed() )
		{
			SetValueInternal( ValueFromPos( m_BoundingBox.left + pt.x + m_iDragOffset ), true );
			return true;
		}
		break;

	default:
		break;
	}

	return false;
}