Changeset View
Changeset View
Standalone View
Standalone View
source/gui/COList.cpp
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 133 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 20 Lines • Show All 107 Lines • ▼ Show 20 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); | |||||
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