Example #1
0
void IRCTextCtrl::postAddMessage()
{
	// eventsCtrl->ShowPosition in alcune circostanze non funziona
	ScrollIntoView(GetLastPosition(), WXK_DOWN);

	limitLines();
}
void CHexEdit::Move(int x, int y)
{
	switch(m_currentMode)
	{
	case EDIT_NONE:
		return;
	case EDIT_HIGH:
		if(x != 0)
			m_currentMode = EDIT_LOW;
		if(x == -1)
			m_currentAddress --;
		m_currentAddress += y* m_bpr;
		break;
	case EDIT_LOW:
		if(x != 0)
			m_currentMode = EDIT_HIGH;
		if(x == 1)
			m_currentAddress++;
		m_currentAddress += y* m_bpr;
		break;
	case EDIT_ASCII:
		{
			m_currentAddress += x;
			m_currentAddress += y*m_bpr;
		}
		break;
	}
	if(m_currentAddress < 0)
		m_currentAddress = 0;
	
	if(m_currentAddress >= m_length)
	{
		m_currentAddress -= x;
		m_currentAddress -= y*m_bpr;
	}
	m_bNoAddressChange = TRUE;
	if(m_currentAddress < m_topindex)
		OnVScroll(SB_LINEUP, 0, NULL);
	if(m_currentAddress >= m_topindex + m_lpp*m_bpr)
		OnVScroll(SB_LINEDOWN, 0, NULL);
	m_bNoAddressChange = FALSE;
	ScrollIntoView(m_currentAddress);
	
	RepositionCaret(m_currentAddress);
}
void STableViewBase::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
	CachedGeometry = AllottedGeometry;

	if (ItemsPanel.IsValid())
	{
		FGeometry PanelGeometry = FindChildGeometry( AllottedGeometry, ItemsPanel.ToSharedRef() );
		if ( bItemsNeedRefresh || PanelGeometryLastTick.Size != PanelGeometry.Size)
		{
			PanelGeometryLastTick = PanelGeometry;

			// We never create the ItemsPanel if the user did not specify all the parameters required to successfully make a list.
			const EScrollIntoViewResult ScrollIntoViewResult = ScrollIntoView( PanelGeometry );

			const FReGenerateResults ReGenerateResults = ReGenerateItems( PanelGeometry );
			LastGenerateResults = ReGenerateResults;

			const int32 NumItemsBeingObserved = GetNumItemsBeingObserved();

			const int32 NumItemsWide = GetNumItemsWide();
			const int32 NumItemRows = NumItemsBeingObserved / NumItemsWide;

			const bool bEnoughRoomForAllItems = ReGenerateResults.ExactNumRowsOnScreen >= NumItemRows;
			if (bEnoughRoomForAllItems)
			{
				// We can show all the items, so make sure there is no scrolling.
				ScrollOffset = 0;
			}
			else if ( ReGenerateResults.bGeneratedPastLastItem )
			{
				ScrollOffset = ReGenerateResults.NewScrollOffset;
			}
			
			
			SetScrollOffset( FMath::Max(0.0, ScrollOffset) );
			ItemsPanel->SmoothScrollOffset( FMath::Fractional(ScrollOffset / GetNumItemsWide()) );

			if (AllowOverscroll == EAllowOverscroll::Yes)
			{
				const float OverscrollAmount = Overscroll.GetOverscroll();
				ItemsPanel->SetOverscrollAmount( OverscrollAmount );
			}

			UpdateSelectionSet();

			// Update scrollbar
			if (NumItemsBeingObserved > 0)
			{
				if (ReGenerateResults.ExactNumRowsOnScreen < 1.0f)
				{
					// We are be observing a single row which is larger than the available visible area, so we should calculate thumb size based on that
					const double VisibleSizeFraction = AllottedGeometry.GetLocalSize().Y / ReGenerateResults.HeightOfGeneratedItems;
					const double ThumbSizeFraction = FMath::Min(VisibleSizeFraction, 1.0);
					const double OffsetFraction = ScrollOffset / NumItemsBeingObserved;
					ScrollBar->SetState( OffsetFraction, ThumbSizeFraction );
				}
				else
				{
					// The thumb size is whatever fraction of the items we are currently seeing (including partially seen items).
					// e.g. if we are seeing 0.5 of the first generated widget and 0.75 of the last widget, that's 1.25 widgets.
					const double ThumbSizeFraction = ReGenerateResults.ExactNumRowsOnScreen / NumItemRows;
					const double OffsetFraction = ScrollOffset / NumItemsBeingObserved;
					ScrollBar->SetState( OffsetFraction, ThumbSizeFraction );
				}
			}
			else
			{
				const double ThumbSizeFraction = 1;
				const double OffsetFraction = 0;
				ScrollBar->SetState( OffsetFraction, ThumbSizeFraction );
			}

			bWasAtEndOfList = (ScrollBar->DistanceFromBottom() < KINDA_SMALL_NUMBER);

			bItemsNeedRefresh = false;
			ItemsPanel->SetRefreshPending(false);

			if (ScrollIntoViewResult == EScrollIntoViewResult::Deferred)
			{
				// We call this rather than just leave bItemsNeedRefresh as true to ensure that EnsureTickToRefresh is registered
				RequestListRefresh();
			}
			else
			{
				NotifyItemScrolledIntoView();
			}
		}
	}
}