1
0
forked from 0ad/0ad

Optional column "sort_order" attribute support olist GUI

Patch by: @Grapjas
Differential revision: D4859
Reviewed by: @trompetin17
This was SVN commit r27398.
This commit is contained in:
trompetin17 2023-01-09 14:26:03 +00:00
parent 7e63ecff2b
commit 9044735e87
3 changed files with 18 additions and 2 deletions

View File

@ -107,6 +107,12 @@
<data type="decimal"/>
</list>
</define>
<define name="sort_order">
<choice>
<value>asc</value>
<value>desc</value>
</choice>
</define>
<define name="unique_settings">
<a:documentation/>
<!-- Defines # -->
@ -596,6 +602,11 @@
<ref name="bool"/>
</attribute>
</optional>
<optional>
<attribute name="sort_order">
<ref name="sort_order"/>
</attribute>
</optional>
</interleave>
</element>
</define>

View File

@ -161,7 +161,7 @@ void COList::HandleMessage(SGUIMessage& Message)
{
if (column.m_Id != static_cast<CStr>(m_SelectedColumn))
{
m_SelectedColumnOrder.Set(-1, true);
m_SelectedColumnOrder.Set(column.m_SortOrder, true);
CStr selected_column = column.m_Id;
m_SelectedColumn.Set(selected_column, true);
}
@ -244,6 +244,10 @@ bool COList::HandleAdditionalChildren(const XMBData& xmb, const XMBElement& chil
{
column.m_Heading.Set(attr_value.FromUTF8(), false);
}
else if (attr_name == "sort_order")
{
column.m_SortOrder.Set(attr_value == "desc" ? -1 : 1, false);
}
}
for (XMBElement grandchild : child.GetChildNodes())

View File

@ -30,7 +30,7 @@ class COListColumn
public:
COListColumn(IGUIObject* owner, const CStr& cid)
: m_Id(cid), m_Width(0), m_Heading(owner, "heading_" + cid), m_List(owner, "list_" + cid),
m_Hidden(owner, "hidden_" + cid, false)
m_Hidden(owner, "hidden_" + cid, false), m_SortOrder(owner, " sort_order_" + cid, -1)
{}
// Avoid copying the strings.
NONCOPYABLE(COListColumn);
@ -41,6 +41,7 @@ public:
CGUISimpleSetting<CStrW> m_Heading; // CGUIString??
CGUISimpleSetting<CGUIList> m_List;
CGUISimpleSetting<bool> m_Hidden;
CGUISimpleSetting<i32> m_SortOrder;
};
/**