diff options
| -rw-r--r-- | gui/ListWidget.cpp | 8 | ||||
| -rw-r--r-- | gui/ListWidget.h | 1 | ||||
| -rw-r--r-- | gui/PopUpWidget.cpp | 2 | ||||
| -rw-r--r-- | gui/dialog.cpp | 6 | ||||
| -rw-r--r-- | gui/newgui.cpp | 14 | 
5 files changed, 17 insertions, 14 deletions
| diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 327fa2e95a..f4a0a81e84 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -112,7 +112,7 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) {  	// First check whether the selection changed  	int newSelectedItem; -	newSelectedItem = (y - 1) / kLineHeight + _currentPos; +	newSelectedItem = findItem(x, y);  	if (newSelectedItem > (int)_list.size() - 1)  		newSelectedItem = -1; @@ -132,7 +132,7 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) {  void ListWidget::handleMouseUp(int x, int y, int button, int clickCount) {  	// If this was a double click and the mouse is still over the selected item,  	// send the double click command -	if (clickCount == 2 && (_selectedItem == (y - 1) / kLineHeight + _currentPos)) { +	if (clickCount == 2 && (_selectedItem == findItem(x, y))) {  		sendCommand(kListItemDoubleClickedCmd, _selectedItem);  	}  } @@ -142,6 +142,10 @@ void ListWidget::handleMouseWheel(int x, int y, int direction) {  } +int ListWidget::findItem(int x, int y) const { +	return (y - 1) / kLineHeight + _currentPos; +} +  static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) {  	int match = 0;  	while (*x && *y && toupper(*x) == toupper(*y)) { diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 3a826a490b..36ce8150c0 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -90,6 +90,7 @@ public:  protected:  	void drawWidget(bool hilite); +	int findItem(int x, int y) const;  	void scrollBarRecalc();  	void endEditMode(); diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index ac72892a7d..b1bfa18c4e 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -187,7 +187,7 @@ void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {  int PopUpDialog::findItem(int x, int y) const {  	if (x >= 0 && x < _w && y >= 0 && y < _h) { -		return (y-2) / kLineHeight; +		return (y - 2) / kLineHeight;  	}  	return -1;  } diff --git a/gui/dialog.cpp b/gui/dialog.cpp index dde31feeb2..9d7968b93f 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -119,8 +119,6 @@ void Dialog::drawDialog() {  }  void Dialog::handleMouseDown(int x, int y, int button, int clickCount) { -	x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); -  	Widget *w;  	w = findWidget(x, y); @@ -146,8 +144,6 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {  }  void Dialog::handleMouseUp(int x, int y, int button, int clickCount) { -	x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); -  	Widget *w;  	if (_focusedWidget) { @@ -168,8 +164,6 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {  }  void Dialog::handleMouseWheel(int x, int y, int direction) { -	x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); -  	Widget *w;  	// This may look a bit backwards, but I think it makes more sense for diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 74753584b6..9b9ff8f3bd 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -132,6 +132,10 @@ void NewGui::runLoop() {  		uint32 time = _system->getMillis();  		while (_system->pollEvent(event)) { +			Common::Point mouse(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor)); +			mouse.x /= _scaleFactor; +			mouse.y /= _scaleFactor; +			  			switch (event.type) {  			case OSystem::EVENT_KEYDOWN:  #if !defined(__PALM_OS__) @@ -151,7 +155,7 @@ void NewGui::runLoop() {  					_currentKeyDown.keycode = 0;  				break;  			case OSystem::EVENT_MOUSEMOVE: -				activeDialog->handleMouseMoved(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 0); +				activeDialog->handleMouseMoved(mouse.x, mouse.y, 0);  				break;  			// We don't distinguish between mousebuttons (for now at least)  			case OSystem::EVENT_LBUTTONDOWN: @@ -167,18 +171,18 @@ void NewGui::runLoop() {  					_lastClick.count = 1;  				}  				_lastClick.time = time; -				activeDialog->handleMouseDown(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), button, _lastClick.count); +				activeDialog->handleMouseDown(mouse.x, mouse.y, button, _lastClick.count);  				break;  			case OSystem::EVENT_LBUTTONUP:  			case OSystem::EVENT_RBUTTONUP:  				button = (event.type == OSystem::EVENT_LBUTTONUP ? 1 : 2); -				activeDialog->handleMouseUp(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), button, _lastClick.count); +				activeDialog->handleMouseUp(mouse.x, mouse.y, button, _lastClick.count);  				break;  			case OSystem::EVENT_WHEELUP: -				activeDialog->handleMouseWheel(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), -1); +				activeDialog->handleMouseWheel(mouse.x, mouse.y, -1);  				break;  			case OSystem::EVENT_WHEELDOWN: -				activeDialog->handleMouseWheel(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 1); +				activeDialog->handleMouseWheel(mouse.x, mouse.y, 1);  				break;  			case OSystem::EVENT_QUIT:  				_system->quit(); | 
