Count direct children of text fields and buttons for mouseover.

This improves polish when mousing over prefix glyphs.
This commit is contained in:
Paul Chote
2018-07-07 15:00:30 +01:00
committed by abcdefg30
parent df20ae1aec
commit f08bfae9a0
2 changed files with 4 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets namespace OpenRA.Mods.Common.Widgets
@@ -240,7 +241,8 @@ namespace OpenRA.Mods.Common.Widgets
var position = GetTextPosition(textSize, rb); var position = GetTextPosition(textSize, rb);
DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this, highlighted); var hover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
DrawBackground(rb, disabled, Depressed, hover, highlighted);
if (Contrast) if (Contrast)
font.DrawTextWithContrast(text, position + stateOffset, font.DrawTextWithContrast(text, position + stateOffset,
disabled ? colordisabled : color, bgDark, bgLight, 2); disabled ? colordisabled : color, bgDark, bgLight, 2);

View File

@@ -567,7 +567,7 @@ namespace OpenRA.Mods.Common.Widgets
var disabled = IsDisabled(); var disabled = IsDisabled();
var state = disabled ? "textfield-disabled" : var state = disabled ? "textfield-disabled" :
HasKeyboardFocus ? "textfield-focused" : HasKeyboardFocus ? "textfield-focused" :
Ui.MouseOverWidget == this ? "textfield-hover" : Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget) ? "textfield-hover" :
"textfield"; "textfield";
WidgetUtils.DrawPanel(state, WidgetUtils.DrawPanel(state,