Changeset View
Changeset View
Standalone View
Standalone View
source/gui/COList.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | case GUIM_MOUSE_PRESS_LEFT: | ||||
int selectedColumnOrder; | int selectedColumnOrder; | ||||
GUI<int>::GetSetting(this, "selected_column_order", selectedColumnOrder); | GUI<int>::GetSetting(this, "selected_column_order", selectedColumnOrder); | ||||
float headingHeight; | float headingHeight; | ||||
GUI<float>::GetSetting(this, "heading_height", headingHeight); | GUI<float>::GetSetting(this, "heading_height", headingHeight); | ||||
float xpos = 0; | float xpos = 0; | ||||
for (COListColumn column : m_Columns) | for (COListColumn column : m_Columns) | ||||
{ | { | ||||
bool hidden = false; | |||||
GUI<bool>::GetSetting(this, "hidden_" + column.m_Id, hidden); | |||||
if (hidden) | |||||
continue; | |||||
float width = column.m_Width; | float width = column.m_Width; | ||||
// Check if it's a decimal value, and if so, assume relative positioning. | // Check if it's a decimal value, and if so, assume relative positioning. | ||||
if (column.m_Width < 1 && column.m_Width > 0) | if (column.m_Width < 1 && column.m_Width > 0) | ||||
width *= m_TotalAvailableColumnWidth; | width *= m_TotalAvailableColumnWidth; | ||||
CPos leftTopCorner = m_CachedActualSize.TopLeft() + CPos(xpos, 0); | CPos leftTopCorner = m_CachedActualSize.TopLeft() + CPos(xpos, 0); | ||||
if (mouse.x >= leftTopCorner.x && | if (mouse.x >= leftTopCorner.x && | ||||
mouse.x < leftTopCorner.x + width && | mouse.x < leftTopCorner.x + width && | ||||
mouse.y < leftTopCorner.y + headingHeight) | mouse.y < leftTopCorner.y + headingHeight) | ||||
Show All 37 Lines | bool COList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile) | ||||
if (child.GetNodeName() == elmt_item) | if (child.GetNodeName() == elmt_item) | ||||
{ | { | ||||
AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8()); | AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8()); | ||||
return true; | return true; | ||||
} | } | ||||
else if (child.GetNodeName() == elmt_column) | else if (child.GetNodeName() == elmt_column) | ||||
{ | { | ||||
COListColumn column; | COListColumn column; | ||||
bool hidden = false; | |||||
for (XMBAttribute attr : child.GetAttributes()) | for (XMBAttribute attr : child.GetAttributes()) | ||||
{ | { | ||||
CStr attr_name(pFile->GetAttributeString(attr.Name)); | CStr attr_name(pFile->GetAttributeString(attr.Name)); | ||||
CStr attr_value(attr.Value); | CStr attr_value(attr.Value); | ||||
if (attr_name == "color") | if (attr_name == "color") | ||||
{ | { | ||||
CColor color; | CColor color; | ||||
if (!GUI<CColor>::ParseString(attr_value.FromUTF8(), color)) | if (!GUI<CColor>::ParseString(attr_value.FromUTF8(), color)) | ||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); | ||||
else | else | ||||
column.m_TextColor = color; | column.m_TextColor = color; | ||||
} | } | ||||
else if (attr_name == "id") | else if (attr_name == "id") | ||||
{ | { | ||||
column.m_Id = attr_value; | column.m_Id = attr_value; | ||||
} | } | ||||
else if (attr_name == "hidden") | |||||
{ | |||||
if (!GUI<bool>::ParseString(attr_value.FromUTF8(), hidden)) | |||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); | |||||
} | |||||
else if (attr_name == "width") | else if (attr_name == "width") | ||||
{ | { | ||||
float width; | float width; | ||||
if (!GUI<float>::ParseString(attr_value.FromUTF8(), width)) | if (!GUI<float>::ParseString(attr_value.FromUTF8(), width)) | ||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); | ||||
else | else | ||||
{ | { | ||||
// Check if it's a relative value, and save as decimal if so. | // Check if it's a relative value, and save as decimal if so. | ||||
Show All 36 Lines | for (XMBElement grandchild : child.GetChildNodes()) | ||||
CStr translatedValue(g_L10n.Translate(value)); | CStr translatedValue(g_L10n.Translate(value)); | ||||
column.m_Heading = translatedValue.FromUTF8(); | column.m_Heading = translatedValue.FromUTF8(); | ||||
} | } | ||||
} | } | ||||
m_Columns.push_back(column); | m_Columns.push_back(column); | ||||
AddSetting(GUIST_CGUIList, "list_" + column.m_Id); | AddSetting(GUIST_CGUIList, "list_" + column.m_Id); | ||||
AddSetting(GUIST_bool, "hidden_" + column.m_Id); | |||||
GUI<bool>::SetSetting(this, "hidden_" + column.m_Id, hidden); | |||||
SetupText(); | SetupText(); | ||||
return true; | return true; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor) | ||||
GUI<int>::GetSetting(this, "selected_column_order", selectedColumnOrder); | GUI<int>::GetSetting(this, "selected_column_order", selectedColumnOrder); | ||||
CColor color; | CColor color; | ||||
GUI<CColor>::GetSetting(this, _textcolor, color); | GUI<CColor>::GetSetting(this, _textcolor, color); | ||||
float xpos = 0; | float xpos = 0; | ||||
for (size_t col = 0; col < m_Columns.size(); ++col) | for (size_t col = 0; col < m_Columns.size(); ++col) | ||||
{ | { | ||||
bool hidden = false; | |||||
GUI<bool>::GetSetting(this, "hidden_" + m_Columns[col].m_Id, hidden); | |||||
if (hidden) | |||||
continue; | |||||
// Check if it's a decimal value, and if so, assume relative positioning. | // Check if it's a decimal value, and if so, assume relative positioning. | ||||
float width = m_Columns[col].m_Width; | float width = m_Columns[col].m_Width; | ||||
if (m_Columns[col].m_Width < 1 && m_Columns[col].m_Width > 0) | if (m_Columns[col].m_Width < 1 && m_Columns[col].m_Width > 0) | ||||
width *= m_TotalAvailableColumnWidth; | width *= m_TotalAvailableColumnWidth; | ||||
CPos leftTopCorner = m_CachedActualSize.TopLeft() + CPos(xpos, 0); | CPos leftTopCorner = m_CachedActualSize.TopLeft() + CPos(xpos, 0); | ||||
// Draw sort arrows in colum header | // Draw sort arrows in colum header | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (scrollbar) | ||||
cliparea.left < GetScrollBar(0).GetOuterRect().right) | cliparea.left < GetScrollBar(0).GetOuterRect().right) | ||||
cliparea.left = GetScrollBar(0).GetOuterRect().right; | cliparea.left = GetScrollBar(0).GetOuterRect().right; | ||||
} | } | ||||
// Draw all items for that column | // Draw all items for that column | ||||
xpos = 0; | xpos = 0; | ||||
for (size_t col = 0; col < objectsCount; ++col) | for (size_t col = 0; col < objectsCount; ++col) | ||||
{ | { | ||||
bool hidden = false; | |||||
GUI<bool>::GetSetting(this, "hidden_" + m_Columns[col].m_Id, hidden); | |||||
if (hidden) | |||||
continue; | |||||
// Determine text position and width | // Determine text position and width | ||||
const CPos textPos = rect.TopLeft() + CPos(xpos, -scroll + m_ItemsYPositions[i]); | const CPos textPos = rect.TopLeft() + CPos(xpos, -scroll + m_ItemsYPositions[i]); | ||||
float width = m_Columns[col].m_Width; | float width = m_Columns[col].m_Width; | ||||
// Check if it's a decimal value, and if so, assume relative positioning. | // Check if it's a decimal value, and if so, assume relative positioning. | ||||
if (m_Columns[col].m_Width < 1 && m_Columns[col].m_Width > 0) | if (m_Columns[col].m_Width < 1 && m_Columns[col].m_Width > 0) | ||||
width *= m_TotalAvailableColumnWidth; | width *= m_TotalAvailableColumnWidth; | ||||
Show All 11 Lines |
Wildfire Games · Phabricator