UI: Slightly better console log scrolling logic.

DevNote: This is about as user friendly as the log will ever get while using Windows RichText control.  The only way it will ever behave better (notably when draggin scrollbars and such) is if we write a custom read-only log text control that paints itself manually.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3443 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-07-09 20:10:52 +00:00
parent d36bb19612
commit dd100a775e
2 changed files with 8 additions and 40 deletions

View File

@ -97,10 +97,6 @@ protected:
//EventListenerHelper_CoreThread<pxLogTextCtrl> m_listener_CoreThread;
//EventListenerHelper_Plugins<pxLogTextCtrl> m_listener_Plugins;
#ifdef __WXMSW__
int m_win32_LinesPerPage;
int m_win32_LinesPerScroll;
#endif
ScopedPtr<ScopedCoreThreadPause> m_IsPaused;
bool m_FreezeWrites;

View File

@ -23,19 +23,15 @@
void pxLogTextCtrl::DispatchEvent( const CoreThreadStatus& status )
{
#ifdef __WXMSW__
// See ConcludeIssue for details on WM_VSCROLL
if( HasWriteLock() ) return;
::SendMessage((HWND)GetHWND(), WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
#endif
ConcludeIssue();
}
void pxLogTextCtrl::DispatchEvent( const PluginEventType& evt )
{
#ifdef __WXMSW__
if( HasWriteLock() ) return;
::SendMessage((HWND)GetHWND(), WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
#endif
ConcludeIssue();
}
pxLogTextCtrl::pxLogTextCtrl( wxWindow* parent )
@ -43,10 +39,6 @@ pxLogTextCtrl::pxLogTextCtrl( wxWindow* parent )
wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH2
)
{
#ifdef __WXMSW__
m_win32_LinesPerScroll = 10;
m_win32_LinesPerPage = 0;
#endif
m_IsPaused = false;
m_FreezeWrites = false;
@ -66,15 +58,6 @@ void pxLogTextCtrl::WriteText(const wxString& text)
void pxLogTextCtrl::OnResize( wxSizeEvent& evt )
{
#ifdef __WXMSW__
// Windows has retarded console window update patterns. This helps smarten them up.
int ctrly = GetSize().y;
int fonty;
GetTextExtent( L"blH yh", NULL, &fonty );
m_win32_LinesPerPage = (ctrly / fonty) + 1;
m_win32_LinesPerScroll = m_win32_LinesPerPage * 0.40;
#endif
evt.Skip();
}
@ -107,25 +90,14 @@ pxLogTextCtrl::~pxLogTextCtrl() throw()
void pxLogTextCtrl::ConcludeIssue()
{
if( HasWriteLock() ) return;
SetInsertionPointEnd();
ScrollLines(1);
ShowPosition( GetLastPosition() );
#ifdef __WXMSW__
// EM_LINESCROLL avoids weird errors when the buffer reaches "max" and starts
// clearing old history:
::SendMessage((HWND)GetHWND(), EM_LINESCROLL, 0, 0xfffffff);
// WM_VSCROLL makes the scrolling 'smooth' (such that the last line of the log contents
// are always displayed as the last line of the log window). Unfortunately this also
// makes logging very slow, so we only send the message for status changes, so that the
// log aligns itself nicely when we pause emulation or when errors occur.
wxTextPos showpos = XYToPosition( 1, GetNumberOfLines()-m_win32_LinesPerScroll );
if( showpos > 0 )
ShowPosition( showpos );
//::SendMessage((HWND)GetHWND(), WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
// This is needed to keep the scrolling "nice" when the textbox doesn't
// have the focus.
::SendMessage((HWND)GetHWND(), WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
#endif
}