Changeset - r26378:95c6a625aaea
[Not reviewed]
master
0 1 0
Peter Nelson - 2 years ago 2022-09-13 22:14:14
peter1138@openttd.org
Fix: Online Players list mouse hover behaviour.

Hover highlight was visible even if the mouse pointer was in a different
window, and the window refreshed itself every frame if the mouse pointer
was not over its matrix widget.

Resolved by using OnMouseOver() instead of OnMouseLoop(), and only
redrawing if the hover position has changed.
1 file changed with 12 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/network/network_gui.cpp
Show inline comments
 
@@ -2112,27 +2112,25 @@ public:
 

	
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop() override
 
	void OnMouseOver(Point pt, int widget) override
 
	{
 
		if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) != WID_CL_MATRIX) {
 
			this->hover_index = -1;
 
			this->SetDirty();
 
			return;
 
		}
 

	
 
		NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_CL_MATRIX);
 
		int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
 
		int index = y / this->line_height;
 

	
 
		if (index != this->hover_index) {
 
			this->hover_index = index;
 
			this->SetDirty();
 
		if (widget != WID_CL_MATRIX) {
 
			if (this->hover_index != -1) {
 
				this->hover_index = -1;
 
				this->SetWidgetDirty(WID_CL_MATRIX);
 
			}
 
		} else {
 
			int index = this->GetRowFromWidget(pt.y, widget, 0, -1);
 
			if (index != this->hover_index) {
 
				this->hover_index = index;
 
				this->SetWidgetDirty(WID_CL_MATRIX);
 
			}
 
		}
 
	}
 
};
 

	
 
void ShowClientList()
 
{
0 comments (0 inline, 0 general)