From 2141a2648cba0451aec05c8ef2a8ad5dd724ef16 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 17 Apr 2005 12:03:03 +0000 Subject: Use variable width scrollbar in the console dialog svn-id: r17652 --- gui/console.cpp | 32 ++++++++++++++------------------ gui/console.h | 2 -- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'gui') diff --git a/gui/console.cpp b/gui/console.cpp index badbce2cee..a079a976d3 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -57,9 +57,21 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) : Dialog(0, 0, 1, 1), _widthPercent(widthPercent), _heightPercent(heightPercent) { - // Setup basic layout/dialog size - reflowLayout(); + // Calculate the real width/height (rounded to char/line multiples) + _w = (uint16)(_widthPercent * g_system->getOverlayWidth()); + _h = (uint16)((_heightPercent * g_system->getOverlayHeight() - 2) / kConsoleLineHeight); + _h = _h * kConsoleLineHeight + 2; + // Add scrollbar + int scrollBarWidth = kDefaultScrollBarWidth; + if (g_system->getOverlayWidth() >= 640) + scrollBarWidth = 14; + _scrollBar = new ScrollBarWidget(this, _w - scrollBarWidth - 1, 0, scrollBarWidth, _h); + _scrollBar->setTarget(this); + + // Reset the line buffer + _lineWidth = (_w - scrollBarWidth - 2) / kConsoleCharWidth; + _linesPerPage = (_h - 2) / kConsoleLineHeight; memset(_buffer, ' ', kBufferSize); _linesInBuffer = kBufferSize / _lineWidth; @@ -73,9 +85,6 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) _slideMode = kNoSlideMode; _slideTime = 0; - // Add scrollbar - _scrollBar = new ScrollBarWidget(this, _w - kDefaultScrollBarWidth - 1, 0, kDefaultScrollBarWidth, _h); - _scrollBar->setTarget(this); // Init callback _callbackProc = 0; @@ -95,19 +104,6 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) print("\nConsole is ready\n"); } -void ConsoleDialog::reflowLayout() { - // Calculate the real width/height (rounded to char/line multiples) - _w = (uint16)(_widthPercent * g_system->getOverlayWidth()); -// _w = (_widthPercent * g_system->getOverlayWidth() - kDefaultScrollBarWidth - 2) / kConsoleCharWidth; -// _w = _w * kConsoleCharWidth + kDefaultScrollBarWidth + 2; - _h = (uint16)((_heightPercent * g_system->getOverlayHeight() - 2) / kConsoleLineHeight); - _h = _h * kConsoleLineHeight + 2; - - // Calculate depending values - _lineWidth = (_w - kDefaultScrollBarWidth - 2) / kConsoleCharWidth; - _linesPerPage = (_h - 2) / kConsoleLineHeight; -} - void ConsoleDialog::slideUpAndClose() { if (_slideMode == kNoSlideMode) { _slideTime = g_system->getMillis(); diff --git a/gui/console.h b/gui/console.h index af68a82355..8b74d7917d 100644 --- a/gui/console.h +++ b/gui/console.h @@ -86,8 +86,6 @@ protected: float _widthPercent, _heightPercent; - void reflowLayout(); - void slideUpAndClose(); public: -- cgit v1.2.3