2019-07-26 20:57:28 +02:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
#include "precompiled.h"
|
2013-07-01 06:15:09 +02:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
#include "CList.h"
|
2013-07-01 06:15:09 +02:00
|
|
|
|
2019-07-26 20:57:28 +02:00
|
|
|
#include "gui/CGUIColor.h"
|
|
|
|
#include "gui/CGUIScrollBarVertical.h"
|
2012-01-13 00:32:27 +01:00
|
|
|
#include "lib/external_libraries/libsdl.h"
|
2019-09-07 15:35:45 +02:00
|
|
|
#include "lib/timer.h"
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-21 12:12:33 +02:00
|
|
|
CList::CList(CGUI& pGUI)
|
2019-08-02 01:55:10 +02:00
|
|
|
: IGUIObject(pGUI), IGUITextOwner(pGUI), IGUIScrollBarOwner(pGUI),
|
2019-08-01 22:20:24 +02:00
|
|
|
m_Modified(false), m_PrevSelectedItem(-1), m_LastItemClickTime(0)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
// Add sprite_disabled! TODO
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<float>("buffer_zone");
|
|
|
|
AddSetting<CStrW>("font");
|
|
|
|
AddSetting<bool>("scrollbar");
|
|
|
|
AddSetting<CStr>("scrollbar_style");
|
|
|
|
AddSetting<CStrW>("sound_disabled");
|
|
|
|
AddSetting<CStrW>("sound_selected");
|
|
|
|
AddSetting<CGUISpriteInstance>("sprite");
|
|
|
|
AddSetting<CGUISpriteInstance>("sprite_selectarea");
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
AddSetting<i32>("cell_id");
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<EAlign>("text_align");
|
|
|
|
AddSetting<CGUIColor>("textcolor");
|
|
|
|
AddSetting<CGUIColor>("textcolor_selected");
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
AddSetting<i32>("selected"); // Index selected. -1 is none.
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<bool>("auto_scroll");
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
AddSetting<i32>("hovered");
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<CStrW>("tooltip");
|
|
|
|
AddSetting<CStr>("tooltip_style");
|
2017-05-15 23:49:10 +02:00
|
|
|
|
2010-08-08 17:22:17 +02:00
|
|
|
// Each list item has both a name (in 'list') and an associated data string (in 'list_data')
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<CGUIList>("list");
|
|
|
|
AddSetting<CGUIList>("list_data");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<bool>("scrollbar", false, true);
|
|
|
|
SetSetting<i32>("selected", -1, true);
|
|
|
|
SetSetting<i32>("hovered", -1, true);
|
|
|
|
SetSetting<bool>("auto_scroll", false, true);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// Add scroll-bar
|
2019-08-01 22:20:24 +02:00
|
|
|
CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(pGUI);
|
2006-04-24 01:14:18 +02:00
|
|
|
bar->SetRightAligned(true);
|
|
|
|
AddScrollBar(bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
CList::~CList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CList::SetupText()
|
|
|
|
{
|
2012-07-31 05:34:09 +02:00
|
|
|
m_Modified = true;
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIList& pList = GetSetting<CGUIList>("list");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2011-04-30 15:01:45 +02:00
|
|
|
//ENSURE(m_GeneratedTexts.size()>=1);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
m_ItemsYPositions.resize(pList.m_Items.size() + 1);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// Delete all generated texts. Some could probably be saved,
|
|
|
|
// but this is easier, and this function will never be called
|
|
|
|
// continuously, or even often, so it'll probably be okay.
|
|
|
|
m_GeneratedTexts.clear();
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const CStrW& font = GetSetting<CStrW>("font");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
float width = GetListRect().GetWidth();
|
|
|
|
// remove scrollbar if applicable
|
|
|
|
if (scrollbar && GetScrollBar(0).GetStyle())
|
|
|
|
width -= GetScrollBar(0).GetStyle()->m_Width;
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const float buffer_zone = GetSetting<float>("buffer_zone");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// Generate texts
|
|
|
|
float buffered_y = 0.f;
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
CGUIText* text;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
if (!pList.m_Items[i].GetOriginalString().empty())
|
|
|
|
text = &AddText(pList.m_Items[i], font, width, buffer_zone, this);
|
2017-03-17 02:10:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Minimum height of a space character of the current font size
|
|
|
|
CGUIString align_string;
|
|
|
|
align_string.SetValue(L" ");
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
text = &AddText(align_string, font, width, buffer_zone, this);
|
2017-03-17 02:10:49 +01:00
|
|
|
}
|
2015-11-16 19:48:05 +01:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
m_ItemsYPositions[i] = buffered_y;
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
buffered_y += text->GetSize().cy;
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
m_ItemsYPositions[pList.m_Items.size()] = buffered_y;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// Setup scrollbar
|
|
|
|
if (scrollbar)
|
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
GetScrollBar(0).SetScrollRange(m_ItemsYPositions.back());
|
|
|
|
GetScrollBar(0).SetScrollSpace(GetListRect().GetHeight());
|
2010-06-30 23:20:08 +02:00
|
|
|
|
|
|
|
CRect rect = GetListRect();
|
2015-08-21 19:08:41 +02:00
|
|
|
GetScrollBar(0).SetX(rect.right);
|
|
|
|
GetScrollBar(0).SetY(rect.top);
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
GetScrollBar(0).SetLength(rect.bottom - rect.top);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void CList::HandleMessage(SGUIMessage& Message)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
IGUIScrollBarOwner::HandleMessage(Message);
|
|
|
|
//IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead!
|
|
|
|
|
2012-07-31 05:34:09 +02:00
|
|
|
m_Modified = false;
|
2006-04-24 01:14:18 +02:00
|
|
|
switch (Message.type)
|
|
|
|
{
|
|
|
|
case GUIM_SETTINGS_UPDATED:
|
|
|
|
if (Message.value == "list")
|
|
|
|
SetupText();
|
|
|
|
|
|
|
|
// If selected is changed, call "SelectionChange"
|
|
|
|
if (Message.value == "selected")
|
|
|
|
{
|
|
|
|
// TODO: Check range
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
if (GetSetting<bool>("auto_scroll"))
|
2018-01-22 05:45:27 +01:00
|
|
|
UpdateAutoScroll();
|
2016-11-14 16:28:49 +01:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
// TODO only works if lower-case, shouldn't it be made case sensitive instead?
|
2015-08-21 19:08:41 +02:00
|
|
|
ScriptEvent("selectionchange");
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
2010-06-30 23:20:08 +02:00
|
|
|
if (Message.value == "scrollbar")
|
2006-04-24 01:14:18 +02:00
|
|
|
SetupText();
|
|
|
|
|
|
|
|
// Update scrollbar
|
2010-06-30 23:20:08 +02:00
|
|
|
if (Message.value == "scrollbar_style")
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
GetScrollBar(0).SetScrollBarStyle(GetSetting<CStr>(Message.value));
|
2006-04-24 01:14:18 +02:00
|
|
|
SetupText();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUIM_MOUSE_PRESS_LEFT:
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
if (!GetSetting<bool>("enabled"))
|
2013-07-01 06:15:09 +02:00
|
|
|
{
|
2019-08-23 00:34:12 +02:00
|
|
|
PlaySound("sound_disabled");
|
2010-06-30 23:20:08 +02:00
|
|
|
break;
|
2013-07-01 06:15:09 +02:00
|
|
|
}
|
2010-06-30 23:20:08 +02:00
|
|
|
|
2017-05-15 23:49:10 +02:00
|
|
|
int hovered = GetHoveredItem();
|
|
|
|
if (hovered == -1)
|
|
|
|
break;
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("selected", hovered, true);
|
2017-05-15 23:49:10 +02:00
|
|
|
UpdateAutoScroll();
|
2019-08-23 00:34:12 +02:00
|
|
|
PlaySound("sound_selected");
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2017-05-15 23:49:10 +02:00
|
|
|
if (timer_Time() - m_LastItemClickTime < SELECT_DBLCLICK_RATE && hovered == m_PrevSelectedItem)
|
|
|
|
this->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT_ITEM, "mouseleftdoubleclickitem");
|
2017-06-29 04:58:04 +02:00
|
|
|
else
|
|
|
|
this->SendEvent(GUIM_MOUSE_PRESS_LEFT_ITEM, "mouseleftclickitem");
|
|
|
|
|
2017-05-15 23:49:10 +02:00
|
|
|
m_LastItemClickTime = timer_Time();
|
|
|
|
m_PrevSelectedItem = hovered;
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 06:15:09 +02:00
|
|
|
|
2017-05-15 23:49:10 +02:00
|
|
|
case GUIM_MOUSE_LEAVE:
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
if (GetSetting<i32>("hovered") == -1)
|
2017-05-15 23:49:10 +02:00
|
|
|
break;
|
2015-11-16 19:23:21 +01:00
|
|
|
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("hovered", -1, true);
|
2017-05-15 23:49:10 +02:00
|
|
|
ScriptEvent("hoverchange");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GUIM_MOUSE_OVER:
|
|
|
|
{
|
|
|
|
int hovered = GetHoveredItem();
|
2019-08-26 14:25:07 +02:00
|
|
|
if (hovered == GetSetting<i32>("hovered"))
|
2017-05-15 23:49:10 +02:00
|
|
|
break;
|
|
|
|
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("hovered", hovered, true);
|
2017-05-15 23:49:10 +02:00
|
|
|
ScriptEvent("hoverchange");
|
2006-04-24 01:14:18 +02:00
|
|
|
break;
|
2013-12-31 05:54:16 +01:00
|
|
|
}
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
case GUIM_LOAD:
|
2015-08-21 19:08:41 +02:00
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
GetScrollBar(0).SetScrollBarStyle(GetSetting<CStr>("scrollbar_style"));
|
2006-04-24 01:14:18 +02:00
|
|
|
break;
|
2015-08-21 19:08:41 +02:00
|
|
|
}
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IGUITextOwner::HandleMessage(Message);
|
|
|
|
}
|
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
InReaction CList::ManuallyHandleEvent(const SDL_Event_* ev)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2014-10-27 05:37:06 +01:00
|
|
|
InReaction result = IN_PASS;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
if (ev->ev.type == SDL_KEYDOWN)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2014-10-27 05:37:06 +01:00
|
|
|
int szChar = ev->ev.key.keysym.sym;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
switch (szChar)
|
|
|
|
{
|
|
|
|
case SDLK_HOME:
|
|
|
|
SelectFirstElement();
|
|
|
|
UpdateAutoScroll();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
case SDLK_END:
|
|
|
|
SelectLastElement();
|
|
|
|
UpdateAutoScroll();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
case SDLK_UP:
|
|
|
|
SelectPrevElement();
|
|
|
|
UpdateAutoScroll();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
case SDLK_DOWN:
|
|
|
|
SelectNextElement();
|
|
|
|
UpdateAutoScroll();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
case SDLK_PAGEUP:
|
|
|
|
GetScrollBar(0).ScrollMinusPlenty();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_PAGEDOWN:
|
|
|
|
GetScrollBar(0).ScrollPlusPlenty();
|
|
|
|
result = IN_HANDLED;
|
|
|
|
break;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
default: // Do nothing
|
|
|
|
result = IN_PASS;
|
|
|
|
}
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
return result;
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void CList::Draw()
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
DrawList(GetSetting<i32>("selected"), "sprite", "sprite_selectarea", "textcolor");
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
float bz = GetBufferedZ();
|
|
|
|
|
|
|
|
// First call draw on ScrollBarOwner
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
if (scrollbar)
|
|
|
|
IGUIScrollBarOwner::Draw();
|
|
|
|
|
|
|
|
{
|
|
|
|
CRect rect = GetListRect();
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
CGUISpriteInstance& sprite = GetSetting<CGUISpriteInstance>(_sprite);
|
|
|
|
CGUISpriteInstance& sprite_selectarea = GetSetting<CGUISpriteInstance>(_sprite_selected);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const int cell_id = GetSetting<i32>("cell_id");
|
2019-08-21 12:12:33 +02:00
|
|
|
m_pGUI.DrawSprite(sprite, cell_id, bz, rect);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
float scroll = 0.f;
|
2006-04-24 01:14:18 +02:00
|
|
|
if (scrollbar)
|
|
|
|
scroll = GetScrollBar(0).GetPos();
|
|
|
|
|
2016-02-12 17:38:25 +01:00
|
|
|
if (selected >= 0 && selected+1 < (int)m_ItemsYPositions.size())
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
// Get rectangle of selection:
|
|
|
|
CRect rect_sel(rect.left, rect.top + m_ItemsYPositions[selected] - scroll,
|
|
|
|
rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-21 12:12:33 +02:00
|
|
|
m_pGUI.DrawSprite(sprite_selectarea, cell_id, bz+0.05f, rect_sel);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIList& pList = GetSetting<CGUIList>("list");
|
|
|
|
const CGUIColor& color = GetSetting<CGUIColor>(_textcolor);
|
2019-08-19 12:32:29 +02:00
|
|
|
|
|
|
|
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
if (m_ItemsYPositions[i+1] - scroll < 0 ||
|
|
|
|
m_ItemsYPositions[i] - scroll > rect.GetHeight())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Clipping area (we'll have to substract the scrollbar)
|
|
|
|
CRect cliparea = GetListRect();
|
|
|
|
|
|
|
|
if (scrollbar)
|
|
|
|
{
|
|
|
|
if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
|
|
|
|
cliparea.right <= GetScrollBar(0).GetOuterRect().right)
|
|
|
|
cliparea.right = GetScrollBar(0).GetOuterRect().left;
|
|
|
|
|
|
|
|
if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
|
|
|
|
cliparea.left < GetScrollBar(0).GetOuterRect().right)
|
|
|
|
cliparea.left = GetScrollBar(0).GetOuterRect().right;
|
|
|
|
}
|
|
|
|
|
Stop copying color every draw call for every GUI object using colors.
Avoid color copies for rendering Draw calls in
GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes,
CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,
8f4f8e240f, 3028551b91, a905fbbc98.
Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage,
CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren.
Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors,
CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for
consistency with the other "databases", refs 3028551b91.
Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an
unexplicit copy, refs 3028551b91.
Explicit ugly copy in CGUI::Xeromyces_ReadColor and
CGUIColor::ParseString.
Deregister copying <CGUIColor>GetSetting functions, refs 8f4f8e240f.
Uses the const ref GetSetting from 3dfa23cd25.
This was SVN commit r22694.
2019-08-19 14:53:58 +02:00
|
|
|
DrawText(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz + 0.1f, cliparea);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-08 17:22:17 +02:00
|
|
|
void CList::AddItem(const CStrW& str, const CStrW& data)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2010-08-08 17:22:17 +02:00
|
|
|
CGUIString gui_string;
|
|
|
|
gui_string.SetValue(str);
|
2019-08-19 12:32:29 +02:00
|
|
|
|
|
|
|
// Do not send a settings-changed message
|
2019-08-26 14:25:07 +02:00
|
|
|
CGUIList& pList = GetSetting<CGUIList>("list");
|
2019-08-19 12:32:29 +02:00
|
|
|
pList.m_Items.push_back(gui_string);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2010-08-08 17:22:17 +02:00
|
|
|
CGUIString data_string;
|
|
|
|
data_string.SetValue(data);
|
2019-08-26 14:25:07 +02:00
|
|
|
CGUIList& pListData = GetSetting<CGUIList>("list_data");
|
2019-08-19 12:32:29 +02:00
|
|
|
pListData.m_Items.push_back(data_string);
|
2010-08-08 17:22:17 +02:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
// TODO Temp
|
|
|
|
SetupText();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile)
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
int elmt_item = pFile->GetElementID("item");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
if (child.GetNodeName() == elmt_item)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2011-02-17 21:08:20 +01:00
|
|
|
AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8());
|
2006-04-24 01:14:18 +02:00
|
|
|
return true;
|
|
|
|
}
|
2015-08-21 19:08:41 +02:00
|
|
|
|
|
|
|
return false;
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CList::SelectNextElement()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
int selected = GetSetting<i32>("selected");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIList& pList = GetSetting<CGUIList>("list");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
if (selected != static_cast<int>(pList.m_Items.size()) - 1)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
++selected;
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("selected", selected, true);
|
2019-08-23 00:34:12 +02:00
|
|
|
PlaySound("sound_selected");
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
void CList::SelectPrevElement()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
int selected = GetSetting<i32>("selected");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2014-10-27 05:37:06 +01:00
|
|
|
if (selected > 0)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
--selected;
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("selected", selected, true);
|
2019-08-23 00:34:12 +02:00
|
|
|
PlaySound("sound_selected");
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CList::SelectFirstElement()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
if (GetSetting<i32>("selected") >= 0)
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
SetSetting<i32>("selected", 0, true);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
void CList::SelectLastElement()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIList& pList = GetSetting<CGUIList>("list");
|
2019-08-19 12:32:29 +02:00
|
|
|
const int index = static_cast<int>(pList.m_Items.size()) - 1;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.
Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.
Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts
This was SVN commit r22796.
2019-08-28 13:21:11 +02:00
|
|
|
if (GetSetting<i32>("selected") != index)
|
|
|
|
SetSetting<i32>("selected", index, true);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CList::UpdateAutoScroll()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
const int selected = GetSetting<i32>("selected");
|
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// No scrollbar, no scrolling (at least it's not made to work properly).
|
2019-08-19 12:32:29 +02:00
|
|
|
if (!scrollbar || selected < 0 || static_cast<std::size_t>(selected) >= m_ItemsYPositions.size())
|
2006-04-24 01:14:18 +02:00
|
|
|
return;
|
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
float scroll = GetScrollBar(0).GetPos();
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// Check upper boundary
|
|
|
|
if (m_ItemsYPositions[selected] < scroll)
|
|
|
|
{
|
|
|
|
GetScrollBar(0).SetPos(m_ItemsYPositions[selected]);
|
|
|
|
return; // this means, if it wants to align both up and down at the same time
|
|
|
|
// this will have precedence.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check lower boundary
|
2016-11-14 16:28:49 +01:00
|
|
|
CRect rect = GetListRect();
|
2006-04-24 01:14:18 +02:00
|
|
|
if (m_ItemsYPositions[selected+1]-rect.GetHeight() > scroll)
|
|
|
|
GetScrollBar(0).SetPos(m_ItemsYPositions[selected+1]-rect.GetHeight());
|
|
|
|
}
|
2017-05-15 23:49:10 +02:00
|
|
|
|
|
|
|
int CList::GetHoveredItem()
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2019-08-19 12:32:29 +02:00
|
|
|
const float scroll = scrollbar ? GetScrollBar(0).GetPos() : 0.f;
|
2017-05-15 23:49:10 +02:00
|
|
|
|
2019-08-10 14:51:27 +02:00
|
|
|
const CRect& rect = GetListRect();
|
2019-08-21 12:12:33 +02:00
|
|
|
CPos mouse = m_pGUI.GetMousePos();
|
2017-05-15 23:49:10 +02:00
|
|
|
mouse.y += scroll;
|
|
|
|
|
|
|
|
// Mouse is over scrollbar
|
|
|
|
if (scrollbar && GetScrollBar(0).IsVisible() &&
|
|
|
|
mouse.x >= GetScrollBar(0).GetOuterRect().left &&
|
|
|
|
mouse.x <= GetScrollBar(0).GetOuterRect().right)
|
|
|
|
return -1;
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIList& pList = GetSetting<CGUIList>("list");
|
2019-08-19 12:32:29 +02:00
|
|
|
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
2017-05-15 23:49:10 +02:00
|
|
|
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
|
|
|
|
mouse.y < rect.top + m_ItemsYPositions[i + 1])
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|