GUI: Add mousewheel scrolling to credits.
This commit is contained in:
parent
76b02ac0d6
commit
648d7e9718
2 changed files with 22 additions and 2 deletions
|
@ -86,7 +86,7 @@ static const char *gpl_text[] = {
|
||||||
|
|
||||||
AboutDialog::AboutDialog()
|
AboutDialog::AboutDialog()
|
||||||
: Dialog(10, 20, 300, 174),
|
: Dialog(10, 20, 300, 174),
|
||||||
_scrollPos(0), _scrollTime(0), _willClose(false) {
|
_scrollPos(0), _scrollTime(0), _willClose(false), _autoScroll(true) {
|
||||||
|
|
||||||
reflowLayout();
|
reflowLayout();
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ void AboutDialog::drawDialog(DrawLayer layerToDraw) {
|
||||||
void AboutDialog::handleTickle() {
|
void AboutDialog::handleTickle() {
|
||||||
const uint32 t = g_system->getMillis();
|
const uint32 t = g_system->getMillis();
|
||||||
int scrollOffset = ((int)t - (int)_scrollTime) / kScrollMillisPerPixel;
|
int scrollOffset = ((int)t - (int)_scrollTime) / kScrollMillisPerPixel;
|
||||||
if (scrollOffset > 0) {
|
if (_autoScroll && scrollOffset > 0) {
|
||||||
int modifiers = g_system->getEventManager()->getModifierState();
|
int modifiers = g_system->getEventManager()->getModifierState();
|
||||||
|
|
||||||
// Scroll faster when shift is pressed
|
// Scroll faster when shift is pressed
|
||||||
|
@ -284,6 +284,24 @@ void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutDialog::handleMouseWheel(int x, int y, int direction) {
|
||||||
|
const int stepping = 5 * _lineHeight * direction;
|
||||||
|
|
||||||
|
if (stepping == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_autoScroll = false;
|
||||||
|
|
||||||
|
int newScrollPos = _scrollPos + stepping;
|
||||||
|
|
||||||
|
if (_scrollPos < 0) {
|
||||||
|
_scrollPos = 0;
|
||||||
|
} else if ((uint32)newScrollPos < _lines.size() * _lineHeight) {
|
||||||
|
_scrollPos = newScrollPos;
|
||||||
|
}
|
||||||
|
drawDialog(kDrawLayerForeground);
|
||||||
|
}
|
||||||
|
|
||||||
void AboutDialog::handleKeyDown(Common::KeyState state) {
|
void AboutDialog::handleKeyDown(Common::KeyState state) {
|
||||||
EEHandler eeHandler;
|
EEHandler eeHandler;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ protected:
|
||||||
Common::U32StringArray _lines;
|
Common::U32StringArray _lines;
|
||||||
uint32 _lineHeight;
|
uint32 _lineHeight;
|
||||||
bool _willClose;
|
bool _willClose;
|
||||||
|
bool _autoScroll;
|
||||||
|
|
||||||
int _xOff, _yOff;
|
int _xOff, _yOff;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ public:
|
||||||
void drawDialog(DrawLayer layerToDraw) override;
|
void drawDialog(DrawLayer layerToDraw) override;
|
||||||
void handleTickle() override;
|
void handleTickle() override;
|
||||||
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
void handleMouseUp(int x, int y, int button, int clickCount) override;
|
||||||
|
void handleMouseWheel(int x, int y, int direction) override;
|
||||||
void handleKeyDown(Common::KeyState state) override;
|
void handleKeyDown(Common::KeyState state) override;
|
||||||
void handleKeyUp(Common::KeyState state) override;
|
void handleKeyUp(Common::KeyState state) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue