1
0
forked from 0ad/0ad

Implement an auto-scroll setting for GUI lists.

Patch By: fpre / ffffffff
Fixes #4987, refs #4254

This allows the replay menu and lobby to focus the selected element if,
but only if it is expected by the user.
Replaces 3f5648767d which scrolled the selected player into view every
single time a new playerlist was received by the lobby server.

This was SVN commit r20958.
This commit is contained in:
elexis 2018-01-22 04:45:27 +00:00
parent 3d65bfe555
commit 8aaff7fc62
7 changed files with 21 additions and 1 deletions

View File

@ -47,6 +47,7 @@ base_settings =
# Defaults are not put in here, because it ruins the concept of styles.
ex_settings =
attribute anchor { valign }?&
attribute auto_scroll { bool }?&
attribute buffer_zone { xsd:decimal }?&
attribute buffer_width { xsd:decimal }?&
attribute button_width { xsd:decimal }?&

View File

@ -174,6 +174,11 @@
<ref name="valign"/>
</attribute>
</optional>
<optional>
<attribute name="auto_scroll">
<ref name="bool"/>
</attribute>
</optional>
<optional>
<attribute name="buffer_zone">
<data type="decimal"/>

View File

@ -62,6 +62,7 @@
selected_column_order="1"
size="0 25 100%-2 100%"
font="sans-stroke-13"
auto_scroll="true"
>
<action on="SelectionChange">showModDescription(this.name);</action>
<action on="SelectionColumnChange">applyFilters();</action>
@ -113,6 +114,7 @@
size="0 25 96%-5 100%"
font="sans-stroke-13"
tooltip_style="pgToolTip"
auto_scroll="true"
>
<action on="SelectionChange">showModDescription(this.name);</action>
<action on="MouseLeftDoubleClickItem">disableMod();</action>

View File

@ -22,6 +22,7 @@
sortable="true"
size="24 4 100%-24 100%-70"
type="olist"
auto_scroll="true"
>
<action on="SelectionChange">selectionChanged();</action>
<action on="SelectionColumnChange">init();</action>

View File

@ -801,6 +801,7 @@ function selectGameFromPlayername()
if (g_SelectedPlayer != splitRatingFromNick(player.Name).nick)
continue;
gameList.auto_scroll = true;
if (player.Team == "observer")
{
foundAsObserver = true;
@ -1084,6 +1085,8 @@ function updateGameList()
// Change these last, otherwise crash
gamesBox.list = list;
gamesBox.list_data = list_data;
gamesBox.auto_scroll = false;
gamesBox.selected = selectedGameIndex;
updateGameSelection();

View File

@ -57,6 +57,7 @@
selected_column="months"
selected_column_order="-1"
font="sans-stroke-13"
auto_scroll="true"
>
<action on="SelectionChange">displayReplayDetails();</action>

View File

@ -45,6 +45,7 @@ CList::CList()
AddSetting(GUIST_CColor, "textcolor");
AddSetting(GUIST_CColor, "textcolor_selected");
AddSetting(GUIST_int, "selected"); // Index selected. -1 is none.
AddSetting(GUIST_bool, "auto_scroll");
AddSetting(GUIST_int, "hovered");
AddSetting(GUIST_CStrW, "tooltip");
AddSetting(GUIST_CStr, "tooltip_style");
@ -56,6 +57,7 @@ CList::CList()
GUI<bool>::SetSetting(this, "scrollbar", false);
GUI<int>::SetSetting(this, "selected", -1);
GUI<int>::SetSetting(this, "hovered", -1);
GUI<int>::SetSetting(this, "auto_scroll", false);
// Add scroll-bar
CGUIScrollBarVertical* bar = new CGUIScrollBarVertical();
@ -161,6 +163,11 @@ void CList::HandleMessage(SGUIMessage& Message)
{
// TODO: Check range
bool auto_scroll;
GUI<bool>::GetSetting(this, "auto_scroll", auto_scroll);
if (auto_scroll)
UpdateAutoScroll();
// TODO only works if lower-case, shouldn't it be made case sensitive instead?