Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/ObjectTypes/COList.cpp
Show First 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | |||||
void COList::AdditionalChildrenHandled() | void COList::AdditionalChildrenHandled() | ||||
{ | { | ||||
SetupText(); | SetupText(); | ||||
} | } | ||||
void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& sprite_selected, const CGUIColor& textcolor) | void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& sprite_selected, const CGUIColor& textcolor) | ||||
{ | { | ||||
const float bz = GetBufferedZ(); | |||||
if (m_ScrollBar) | if (m_ScrollBar) | ||||
IGUIScrollBarOwner::Draw(); | IGUIScrollBarOwner::Draw(); | ||||
CRect rect = GetListRect(); | CRect rect = GetListRect(); | ||||
m_pGUI.DrawSprite(sprite, bz, rect); | m_pGUI.DrawSprite(sprite, rect); | ||||
float scroll = 0.f; | float scroll = 0.f; | ||||
if (m_ScrollBar) | if (m_ScrollBar) | ||||
scroll = GetScrollBar(0).GetPos(); | scroll = GetScrollBar(0).GetPos(); | ||||
// Draw item selection | // Draw item selection | ||||
if (selected != -1) | if (selected != -1) | ||||
{ | { | ||||
Show All 19 Lines | if (rect_sel.top <= rect.bottom && | ||||
rect_sel.right = GetScrollBar(0).GetOuterRect().left; | rect_sel.right = GetScrollBar(0).GetOuterRect().left; | ||||
if (rect_sel.left >= GetScrollBar(0).GetOuterRect().left && | if (rect_sel.left >= GetScrollBar(0).GetOuterRect().left && | ||||
rect_sel.left < GetScrollBar(0).GetOuterRect().right) | rect_sel.left < GetScrollBar(0).GetOuterRect().right) | ||||
rect_sel.left = GetScrollBar(0).GetOuterRect().right; | rect_sel.left = GetScrollBar(0).GetOuterRect().right; | ||||
} | } | ||||
// Draw item selection | // Draw item selection | ||||
m_pGUI.DrawSprite(sprite_selected, bz + 0.05f, rect_sel); | m_pGUI.DrawSprite(sprite_selected, rect_sel); | ||||
} | } | ||||
} | } | ||||
// Draw line above column header | // Draw line above column header | ||||
CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right, | CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right, | ||||
m_CachedActualSize.top + m_HeadingHeight); | m_CachedActualSize.top + m_HeadingHeight); | ||||
m_pGUI.DrawSprite(m_SpriteHeading, bz, rect_head); | m_pGUI.DrawSprite(m_SpriteHeading, rect_head); | ||||
// Draw column headers | // Draw column headers | ||||
float xpos = 0; | float xpos = 0; | ||||
size_t col = 0; | size_t col = 0; | ||||
for (const COListColumn& column : m_Columns) | for (const COListColumn& column : m_Columns) | ||||
{ | { | ||||
if (column.m_Hidden) | if (column.m_Hidden) | ||||
{ | { | ||||
Show All 20 Lines | if (m_Sortable) | ||||
if (m_SelectedColumnOrder != -1) | if (m_SelectedColumnOrder != -1) | ||||
pSprite = &*m_SpriteAsc; | pSprite = &*m_SpriteAsc; | ||||
else | else | ||||
pSprite = &*m_SpriteDesc; | pSprite = &*m_SpriteDesc; | ||||
} | } | ||||
else | else | ||||
pSprite = &*m_SpriteNotSorted; | pSprite = &*m_SpriteNotSorted; | ||||
m_pGUI.DrawSprite(*pSprite, bz + 0.1f, CRect(leftTopCorner + CVector2D(width - SORT_SPRITE_DIM, 0), leftTopCorner + CVector2D(width, SORT_SPRITE_DIM))); | m_pGUI.DrawSprite(*pSprite, CRect(leftTopCorner + CVector2D(width - SORT_SPRITE_DIM, 0), leftTopCorner + CVector2D(width, SORT_SPRITE_DIM))); | ||||
} | } | ||||
// Draw column header text | // Draw column header text | ||||
DrawText(col, textcolor, leftTopCorner + COLUMN_SHIFT, bz + 0.1f, rect_head); | DrawText(col, textcolor, leftTopCorner + COLUMN_SHIFT, rect_head); | ||||
xpos += width; | xpos += width; | ||||
++col; | ++col; | ||||
} | } | ||||
// Draw list items for each column | // Draw list items for each column | ||||
const size_t objectsCount = m_Columns.size(); | const size_t objectsCount = m_Columns.size(); | ||||
for (size_t i = 0; i < m_List->m_Items.size(); ++i) | for (size_t i = 0; i < m_List->m_Items.size(); ++i) | ||||
{ | { | ||||
Show All 34 Lines | for (size_t colIdx = 0; colIdx < m_Columns.size(); ++colIdx) | ||||
width *= m_TotalAvailableColumnWidth; | width *= m_TotalAvailableColumnWidth; | ||||
// Clip text to the column (to prevent drawing text into the neighboring column) | // Clip text to the column (to prevent drawing text into the neighboring column) | ||||
CRect cliparea2 = cliparea; | CRect cliparea2 = cliparea; | ||||
cliparea2.right = std::min(cliparea2.right, textPos.X + width); | cliparea2.right = std::min(cliparea2.right, textPos.X + width); | ||||
cliparea2.bottom = std::min(cliparea2.bottom, textPos.Y + rowHeight); | cliparea2.bottom = std::min(cliparea2.bottom, textPos.Y + rowHeight); | ||||
// Draw list item | // Draw list item | ||||
DrawText(objectsCount * (i +/*Heading*/1) + colIdx, column.m_TextColor, textPos, bz + 0.1f, cliparea2); | DrawText(objectsCount * (i +/*Heading*/1) + colIdx, column.m_TextColor, textPos, cliparea2); | ||||
xpos += width; | xpos += width; | ||||
} | } | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator