Changeset View
Changeset View
Standalone View
Standalone View
source/gui/COList.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2018 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 320 Lines • ▼ Show 20 Lines | void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor) | ||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList); | GUI<CGUIList>::GetSettingPointer(this, "list", pList); | ||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, rect); | GetGUI()->DrawSprite(*sprite, cell_id, bz, rect); | ||||
float scroll = 0.f; | float scroll = 0.f; | ||||
if (scrollbar) | if (scrollbar) | ||||
scroll = GetScrollBar(0).GetPos(); | scroll = GetScrollBar(0).GetPos(); | ||||
// Draw item selection | CIntList sel; | ||||
if (selected != -1) | GUI<CIntList>::GetSetting(this, "multiSelected", sel); | ||||
{ | m_SelectedItems = sel.m_Items; | ||||
ENSURE(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size()); | if (m_SelectedItems.size() > 0) | ||||
{ | |||||
vladislavbelov: We need to avoid C-style case, especially this kind. Use `size_t`. | |||||
Done Inline ActionsIMHO, it'd be better you have a full name: numberOfSelections. vladislavbelov: IMHO, it'd be better you have a full name: `numberOfSelections`. | |||||
// Get rectangle of selection: | // Draw multi selection | ||||
CRect rect_sel(rect.left, rect.top + m_ItemsYPositions[selected] - scroll, | for (size_t selection = 0; selection < m_SelectedItems.size(); selection++) | ||||
Not Done Inline ActionsRange loop selecteditem for the name felse invert iterator Stan: Range loop selecteditem for the name felse invert iterator | |||||
rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll); | DrawSelection(m_SelectedItems[selection], scrollbar, scroll, *sprite_selectarea, cell_id, bz, rect); | ||||
Done Inline ActionsThe i is enough for the name, or use just selection. vladislavbelov: The `i` is enough for the name, or use just `selection`. | |||||
if (rect_sel.top <= rect.bottom && | |||||
rect_sel.bottom >= rect.top) | |||||
{ | |||||
if (rect_sel.bottom > rect.bottom) | |||||
rect_sel.bottom = rect.bottom; | |||||
if (rect_sel.top < rect.top) | |||||
rect_sel.top = rect.top; | |||||
if (scrollbar) | |||||
{ | |||||
// Remove any overlapping area of the scrollbar. | |||||
if (rect_sel.right > GetScrollBar(0).GetOuterRect().left && | |||||
rect_sel.right <= GetScrollBar(0).GetOuterRect().right) | |||||
rect_sel.right = 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; | |||||
} | } | ||||
else | |||||
{ | |||||
// Draw item selection | // Draw item selection | ||||
GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect_sel); | if (selected != -1) | ||||
} | DrawSelection(selected, scrollbar, scroll, *sprite_selectarea, cell_id, bz, rect); | ||||
} | } | ||||
float headingHeight; | float headingHeight; | ||||
GUI<float>::GetSetting(this, "heading_height", headingHeight); | GUI<float>::GetSetting(this, "heading_height", headingHeight); | ||||
// Draw line above column header | // Draw line above column header | ||||
CGUISpriteInstance* sprite_heading = NULL; | CGUISpriteInstance* sprite_heading = NULL; | ||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_heading", sprite_heading); | GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_heading", sprite_heading); | ||||
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 + headingHeight); | m_CachedActualSize.top + headingHeight); | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
We need to avoid C-style case, especially this kind. Use size_t.