void ui::UIScrollBar::OnDraggingEnd(HWND hWnd, WPARAM wParam, LPARAM lParam, UI2Points clientDragRect, UIDelta delta,
                                    ULONGLONG timestampInMilliSeconds, OUT bool *eaten) {
#ifdef DEBUG_UISCROLLBAR
  LOG_ENTER(SEVERITY_LEVEL_DEBUG);
#endif
  UNREFERENCED_PARAMETER(hWnd);
  UNREFERENCED_PARAMETER(wParam);
  UNREFERENCED_PARAMETER(lParam);
  UNREFERENCED_PARAMETER(delta);
  UNREFERENCED_PARAMETER(timestampInMilliSeconds);
  UNREFERENCED_PARAMETER(eaten);
  if (m_dragging && m_bar->HitTest(clientDragRect.end.x, clientDragRect.end.y)) {
    if (m_direction == SCROLLBAR_DIRECTION_HORIZONTAL) {
      FLOAT sx = (clientDragRect.end.x - m_dragPosInBar.x) - GetSlideAreaOffset();
      FLOAT x = (m_maxValue - m_minValue) / (GetSlideAreaLength() - GetBarLength()) * sx;
      SetBarPosition(x);
#ifdef DEBUG_UISCROLLBAR
      LOG(SEVERITY_LEVEL_DEBUG) << L"sx = " << sx << L", x = " << x;
#endif
    } else {
      FLOAT sy = (clientDragRect.end.y - m_dragPosInBar.y) - GetSlideAreaOffset();
      FLOAT y = (m_maxValue - m_minValue) / (GetSlideAreaLength() - GetBarLength()) * sy;
      SetBarPosition(y);
#ifdef DEBUG_UISCROLLBAR
      LOG(SEVERITY_LEVEL_DEBUG) << L"sy = " << sy << L", y = " << y;
#endif
    }
  }
  m_dragging = false;
#ifdef DEBUG_UISCROLLBAR
  LOG_LEAVE(SEVERITY_LEVEL_DEBUG);
#endif
}
Beispiel #2
0
void CIFScrollBar::PrepareControl( int id )
{
	
	m_bgBar->PrepareControl( id+1 );
	m_upBtn->PrepareControl( id+2 );
	m_dnBtn->PrepareControl( id+5 );
	m_bar->PrepareControl( id+8 );

	
	if( m_barType == 0 )
	{
		m_barOriginalPos = g_ifMng->m_iPos[ m_bar->m_info[0].ID ].clientY;
		m_barSize = m_bgBar->m_info[0].sizeY - ( m_upBtn->m_info[0].sizeY + m_dnBtn->m_info[0].sizeY + m_bar->m_info[0].sizeY );
	}
	
	else
	{
		m_barOriginalPos = g_ifMng->m_iPos[ m_bar->m_info[0].ID ].clientX;
		m_barSize = m_bgBar->m_info[0].sizeX - ( m_upBtn->m_info[0].sizeX + m_dnBtn->m_info[0].sizeX + m_bar->m_info[0].sizeX );
	}
	
	SetBarPosition( m_max, m_current );

	m_bar->UpdateControl();
}
void WidgetSliderInput::SetValue(float value)
{
	float num_steps = (value - min_value) / step;
	float new_value = min_value + Rocket::Core::Math::Round(num_steps) * step;

	SetBarPosition(SetValueInternal(new_value));
}
Beispiel #4
0
void CIFScrollBar::SetBarPositionMax()
{
	SetBarPosition( m_max, m_max );
}
Beispiel #5
0
void CIFScrollBar::SetBarPositionCurrent( int cur )
{
	SetBarPosition( m_max, cur );
}
Beispiel #6
0
int CIFScrollBar::ProcessScrollBar()
{
	
	if( m_max > 0 )
	{
		if( m_upBtn->ProcessButton() == IF_CTL_SELECT )
		{
			
			if( m_current > 0 )
			{
				m_current--;
				
				SetBarPosition( m_max, m_current );
			}

			return IF_CTL_SELECT;
		}
		
		if( m_dnBtn->ProcessButton() == IF_CTL_SELECT )
		{
			
			if( m_current < m_max )
			{
				m_current++;

				SetBarPosition( m_max, m_current );
			}

			return IF_CTL_SELECT;
		}

		
		if( m_bar->Selection() == IF_LBDN )
		{
			m_scrollBarDragFlag = true;
		}

		if( g_input->GetLBNone() ) m_scrollBarDragFlag = false;

		if( m_scrollBarDragFlag )
		{
			int mousePos, mousePosIdx = -1;
			int scrollSize;
			float scrollUnitSize;
			int numScrollMsg;

			
			if( m_barType == 0 )
				scrollSize = m_bgBar->GetYSize() - ( m_upBtn->GetYSize() + m_dnBtn->GetYSize() + m_bar->GetYSize() );
			
			else
				scrollSize = m_bgBar->GetXSize() - ( m_upBtn->GetXSize() + m_dnBtn->GetXSize() + m_bar->GetXSize() );

			numScrollMsg = m_max;
			if( numScrollMsg <= 0 ) return IF_CTL_NONE;
			
			scrollUnitSize = (float)scrollSize / (float)numScrollMsg;

			
			if( m_barType == 0 )
			{
				mousePos = g_input->GetPosY();
				mousePos -= m_bgBar->GetYPos() + m_upBtn->GetYSize() + m_bar->GetYSize() / 2;

				for( int i=0; i<=numScrollMsg; i++ )
				{
					if( mousePos >= ( i * scrollUnitSize - m_bar->GetYSize() / 2 ) && mousePos <= ( i * scrollUnitSize + m_bar->GetYSize() / 2 ) )
						mousePosIdx = i;
				}
			}
			
			else
			{
				mousePos = g_input->GetPosX();
				mousePos -= m_bgBar->GetXPos() + m_upBtn->GetXSize() + m_bar->GetXSize() / 2;

				for( int i=0; i<=numScrollMsg; i++ )
				{
					if( mousePos >= ( i * scrollUnitSize - m_bar->GetXSize() / 2 ) && mousePos <= ( i * scrollUnitSize + m_bar->GetXSize() / 2 ) )
						mousePosIdx = i;
				}
			}

			if( mousePosIdx == -1 ) 
				return IF_CTL_NONE;

			m_current = mousePosIdx;

			if( m_current < 0 )
				m_current = 0;

			SetBarPosition( m_max, m_current );

			return( IF_CTL_SELECT );
		}
	}	

	return( IF_CTL_NONE );
}
/*******************************************************
*   If we are being resized. Fix the stuff we need to fix
*******************************************************/
void SplitPane::FrameResized(float width, float height){
   SetBarPosition(((align == B_VERTICAL) ? Bounds().Width() : Bounds().Height()) - last_pos);

   Update();
   Invalidate();
}