Ticket #8085: mousewheel.diff

File mousewheel.diff, 7.2 KB (added by eriktorbjorn, 22 years ago)

Patch against an October 8 CVS snapshot

  • scummvm/backends/sdl/sdl-common.cpp

    diff -ur ScummVM-cvs20021008/scummvm/backends/sdl/sdl-common.cpp ScummVM-cvs20021008+hack/scummvm/backends/sdl/sdl-common.cpp
    old new  
    586586                                event->event_code = EVENT_LBUTTONDOWN;
    587587                        else if (ev.button.button == SDL_BUTTON_RIGHT)
    588588                                event->event_code = EVENT_RBUTTONDOWN;
     589#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
     590                        else if (ev.button.button == SDL_BUTTON_WHEELUP)
     591                                event->event_code = EVENT_WHEELUP;
     592                        else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
     593                                event->event_code = EVENT_WHEELDOWN;
     594#endif
    589595                        else
    590596                                break;
    591597                        km.x = event->mouse.x = ev.motion.x;
  • scummvm/common/system.h

    diff -ur ScummVM-cvs20021008/scummvm/common/system.h ScummVM-cvs20021008+hack/scummvm/common/system.h
    old new  
    5454                EVENT_LBUTTONUP = 5,
    5555                EVENT_RBUTTONDOWN = 6,
    5656                EVENT_RBUTTONUP = 7,
     57                EVENT_WHEELUP = 8,
     58                EVENT_WHEELDOWN = 9,
    5759        };
    5860
    5961        enum {
  • scummvm/gui/ListWidget.cpp

    diff -ur ScummVM-cvs20021008/scummvm/gui/ListWidget.cpp ScummVM-cvs20021008+hack/scummvm/gui/ListWidget.cpp
    old new  
    8585        }
    8686}
    8787
     88void ListWidget::handleMouseWheel(int x, int y, int direction)
     89{
     90        _scrollBar->handleMouseWheel(x, y, direction);
     91}
     92
    8893bool ListWidget::handleKeyDown(char key, int modifiers)
    8994{
    9095        bool handled = true;
  • scummvm/gui/ListWidget.h

    diff -ur ScummVM-cvs20021008/scummvm/gui/ListWidget.h ScummVM-cvs20021008+hack/scummvm/gui/ListWidget.h
    old new  
    6868       
    6969        virtual void handleMouseDown(int x, int y, int button, int clickCount);
    7070        virtual void handleMouseUp(int x, int y, int button, int clickCount);
     71        virtual void handleMouseWheel(int x, int y, int direction);
    7172        virtual bool handleKeyDown(char key, int modifiers);
    7273        virtual bool handleKeyUp(char key, int modifiers);
    7374        virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
  • scummvm/gui/ScrollBarWidget.cpp

    diff -ur ScummVM-cvs20021008/scummvm/gui/ScrollBarWidget.cpp ScummVM-cvs20021008+hack/scummvm/gui/ScrollBarWidget.cpp
    old new  
    3131 * - Allow for a horizontal scrollbar, too?
    3232 * - If there are less items than fit on one pages, no scrolling can be done
    3333 *   and we thus should not highlight the arrows/slider.
     34 * - Allow the mouse wheel to scroll more than one line at a time
    3435 */
    3536
    3637#define UP_DOWN_BOX_HEIGHT      10
     
    104105        _draggingPart = kNoPart;
    105106}
    106107
     108void ScrollBarWidget::handleMouseWheel(int x, int y, int direction)
     109{
     110        int old_pos = _currentPos;
     111
     112        if (_numEntries < _entriesPerPage)
     113                return;
     114
     115        if (direction < 0) {
     116                _currentPos--;
     117        } else {
     118                _currentPos++;
     119        }
     120
     121        // Make sure that _currentPos is still inside the bounds
     122        checkBounds(old_pos);
     123}
     124
    107125void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
    108126{
    109127        // Do nothing if there are less items than fit on one page
  • scummvm/gui/ScrollBarWidget.h

    diff -ur ScummVM-cvs20021008/scummvm/gui/ScrollBarWidget.h ScummVM-cvs20021008+hack/scummvm/gui/ScrollBarWidget.h
    old new  
    6161
    6262        void handleMouseDown(int x, int y, int button, int clickCount);
    6363        void handleMouseUp(int x, int y, int button, int clickCount);
     64        void handleMouseWheel(int x, int y, int direction);
    6465        void handleMouseMoved(int x, int y, int button);
    6566        void handleMouseEntered(int button)     { setFlags(WIDGET_HILITED); }
    6667        void handleMouseLeft(int button)        { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); }
  • scummvm/gui/dialog.cpp

    diff -ur ScummVM-cvs20021008/scummvm/gui/dialog.cpp ScummVM-cvs20021008+hack/scummvm/gui/dialog.cpp
    old new  
    139139                w->handleMouseUp(x - w->_x, y - w->_y, button, clickCount);
    140140}
    141141
     142void Dialog::handleMouseWheel(int x, int y, int direction)
     143{
     144        Widget *w;
     145
     146        // This may look a bit backwards, but I think it makes more sense for
     147        // the mouse wheel to primarily affect the widget the mouse is at than
     148        // the widget that happens to be focused.
     149
     150        w = findWidget(x, y);
     151        if (!w)
     152                w = _focusedWidget;
     153        if (w)
     154                w->handleMouseWheel(x, y, direction);
     155}
     156
    142157void Dialog::handleKeyDown(char key, int modifiers)
    143158{
    144159        if (_focusedWidget) {
  • scummvm/gui/dialog.h

    diff -ur ScummVM-cvs20021008/scummvm/gui/dialog.h ScummVM-cvs20021008+hack/scummvm/gui/dialog.h
    old new  
    5858        virtual void handleTickle(); // Called periodically (in every guiloop() )
    5959        virtual void handleMouseDown(int x, int y, int button, int clickCount);
    6060        virtual void handleMouseUp(int x, int y, int button, int clickCount);
     61        virtual void handleMouseWheel(int x, int y, int direction);
    6162        virtual void handleKeyDown(char key, int modifiers);
    6263        virtual void handleKeyUp(char key, int modifiers);
    6364        virtual void handleMouseMoved(int x, int y, int button);
  • scummvm/gui/newgui.cpp

    diff -ur ScummVM-cvs20021008/scummvm/gui/newgui.cpp ScummVM-cvs20021008+hack/scummvm/gui/newgui.cpp
    old new  
    174174                                case OSystem::EVENT_RBUTTONUP:
    175175                                        activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count);
    176176                                        break;
     177                                case OSystem::EVENT_WHEELUP:
     178                                        activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1);
     179                                        break;
     180                                case OSystem::EVENT_WHEELDOWN:
     181                                        activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1);
     182                                        break;
    177183                        }
    178184                }
    179185
  • scummvm/gui/widget.h

    diff -ur ScummVM-cvs20021008/scummvm/gui/widget.h ScummVM-cvs20021008+hack/scummvm/gui/widget.h
    old new  
    9696        virtual void handleMouseEntered(int button) {}
    9797        virtual void handleMouseLeft(int button) {}
    9898        virtual void handleMouseMoved(int x, int y, int button) {}
     99        virtual void handleMouseWheel(int x, int y, int direction) {}
    99100        virtual bool handleKeyDown(char key, int modifiers) { return false; }   // Return true if the event was handled
    100101        virtual bool handleKeyUp(char key, int modifiers) { return false; }     // Return true if the event was handled
    101102        virtual void handleTickle() {}