2019-07-26 11:57:28 -07:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2009-04-18 10:00:33 -07: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-23 16:14:18 -07:00
|
|
|
#include "precompiled.h"
|
2013-06-30 21:15:09 -07:00
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "CDropDown.h"
|
|
|
|
|
|
2019-09-18 13:51:45 -07:00
|
|
|
#include "gui/CGUI.h"
|
2019-07-26 11:57:28 -07:00
|
|
|
#include "gui/CGUIColor.h"
|
2019-09-22 16:28:25 -07:00
|
|
|
#include "gui/CGUIList.h"
|
|
|
|
|
#include "gui/IGUIScrollBar.h"
|
2012-01-12 15:32:27 -08:00
|
|
|
#include "lib/external_libraries/libsdl.h"
|
2013-07-14 05:17:07 -07:00
|
|
|
#include "lib/timer.h"
|
2019-09-07 06:35:45 -07:00
|
|
|
#include "ps/Profile.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2019-08-21 03:12:33 -07:00
|
|
|
CDropDown::CDropDown(CGUI& pGUI)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
: CList(pGUI),
|
|
|
|
|
IGUIObject(pGUI),
|
|
|
|
|
m_Open(),
|
|
|
|
|
m_HideScrollBar(),
|
|
|
|
|
m_ElementHighlight(-1),
|
|
|
|
|
m_ButtonWidth(),
|
|
|
|
|
m_DropDownSize(),
|
|
|
|
|
m_DropDownBuffer(),
|
|
|
|
|
m_MinimumVisibleItems(),
|
|
|
|
|
m_SoundClosed(),
|
|
|
|
|
m_SoundEnter(),
|
|
|
|
|
m_SoundLeave(),
|
|
|
|
|
m_SoundOpened(),
|
|
|
|
|
m_SpriteDisabled(),
|
|
|
|
|
m_SpriteList(),
|
|
|
|
|
m_Sprite2(),
|
|
|
|
|
m_Sprite2Over(),
|
|
|
|
|
m_Sprite2Pressed(),
|
|
|
|
|
m_Sprite2Disabled(),
|
|
|
|
|
m_TextColorDisabled(),
|
|
|
|
|
m_TextVAlign()
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
RegisterSetting("button_width", m_ButtonWidth);
|
|
|
|
|
RegisterSetting("dropdown_size", m_DropDownSize);
|
|
|
|
|
RegisterSetting("dropdown_buffer", m_DropDownBuffer);
|
|
|
|
|
RegisterSetting("minimum_visible_items", m_MinimumVisibleItems);
|
|
|
|
|
RegisterSetting("sound_closed", m_SoundClosed);
|
|
|
|
|
RegisterSetting("sound_enter", m_SoundEnter);
|
|
|
|
|
RegisterSetting("sound_leave", m_SoundLeave);
|
|
|
|
|
RegisterSetting("sound_opened", m_SoundOpened);
|
2019-09-22 15:49:20 -07:00
|
|
|
// Setting "sprite" is registered by CList and used as the background
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
RegisterSetting("sprite_disabled", m_SpriteDisabled);
|
|
|
|
|
RegisterSetting("sprite_list", m_SpriteList); // Background of the drop down list
|
|
|
|
|
RegisterSetting("sprite2", m_Sprite2); // Button that sits to the right
|
|
|
|
|
RegisterSetting("sprite2_over", m_Sprite2Over);
|
|
|
|
|
RegisterSetting("sprite2_pressed", m_Sprite2Pressed);
|
|
|
|
|
RegisterSetting("sprite2_disabled", m_Sprite2Disabled);
|
|
|
|
|
RegisterSetting("textcolor_disabled", m_TextColorDisabled);
|
|
|
|
|
RegisterSetting("text_valign", m_TextVAlign);
|
2006-04-23 16:14:18 -07:00
|
|
|
// Add these in CList! And implement TODO
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
//RegisterSetting("textcolor_over");
|
|
|
|
|
//RegisterSetting("textcolor_pressed");
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
// Scrollbar is forced to be true.
|
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 04:21:11 -07:00
|
|
|
SetSetting<bool>("scrollbar", true, true);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CDropDown::~CDropDown()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDropDown::SetupText()
|
|
|
|
|
{
|
|
|
|
|
SetupListRect();
|
2010-06-30 14:20:08 -07:00
|
|
|
CList::SetupText();
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2017-06-29 16:39:12 -07:00
|
|
|
void CDropDown::UpdateCachedSize()
|
|
|
|
|
{
|
|
|
|
|
CList::UpdateCachedSize();
|
|
|
|
|
SetupText();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
void CDropDown::HandleMessage(SGUIMessage& Message)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
// Important
|
|
|
|
|
|
|
|
|
|
switch (Message.type)
|
|
|
|
|
{
|
|
|
|
|
case GUIM_SETTINGS_UPDATED:
|
2010-06-30 14:20:08 -07:00
|
|
|
{
|
2006-04-23 16:14:18 -07:00
|
|
|
// Update cached list rect
|
2010-06-30 14:20:08 -07:00
|
|
|
if (Message.value == "size" ||
|
|
|
|
|
Message.value == "absolute" ||
|
|
|
|
|
Message.value == "dropdown_size" ||
|
|
|
|
|
Message.value == "dropdown_buffer" ||
|
2018-02-25 14:26:31 -08:00
|
|
|
Message.value == "minimum_visible_items" ||
|
2010-06-30 14:20:08 -07:00
|
|
|
Message.value == "scrollbar_style" ||
|
|
|
|
|
Message.value == "button_width")
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
SetupListRect();
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
break;
|
2010-06-30 14:20:08 -07:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2010-06-30 14:20:08 -07:00
|
|
|
case GUIM_MOUSE_MOTION:
|
|
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
if (!m_Open)
|
|
|
|
|
break;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2019-08-21 03:12:33 -07:00
|
|
|
CPos mouse = m_pGUI.GetMousePos();
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (!GetListRect().PointInside(mouse))
|
|
|
|
|
break;
|
|
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
const float scroll = m_ScrollBar ? GetScrollBar(0).GetPos() : 0.f;
|
2015-08-21 10:08:41 -07:00
|
|
|
|
|
|
|
|
CRect rect = GetListRect();
|
|
|
|
|
mouse.y += scroll;
|
|
|
|
|
int set = -1;
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
for (int i = 0; i < static_cast<int>(m_List.m_Items.size()); ++i)
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
|
|
|
|
|
mouse.y < rect.top + m_ItemsYPositions[i+1] &&
|
|
|
|
|
// mouse is not over scroll-bar
|
2015-10-30 22:40:43 -07:00
|
|
|
(m_HideScrollBar ||
|
|
|
|
|
mouse.x < GetScrollBar(0).GetOuterRect().left ||
|
|
|
|
|
mouse.x > GetScrollBar(0).GetOuterRect().right))
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
set = i;
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (set != -1)
|
|
|
|
|
{
|
|
|
|
|
m_ElementHighlight = set;
|
|
|
|
|
//UpdateAutoScroll();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-30 14:20:08 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2013-06-30 21:15:09 -07:00
|
|
|
case GUIM_MOUSE_ENTER:
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_Enabled)
|
|
|
|
|
PlaySound(m_SoundEnter);
|
2013-06-30 21:15:09 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-30 14:20:08 -07:00
|
|
|
case GUIM_MOUSE_LEAVE:
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ElementHighlight = m_Selected;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_Enabled)
|
|
|
|
|
PlaySound(m_SoundLeave);
|
2010-06-30 14:20:08 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2010-06-30 14:20:08 -07:00
|
|
|
// We can't inherent this routine from CList, because we need to include
|
|
|
|
|
// a mouse click to open the dropdown, also the coordinates are changed.
|
2006-04-23 16:14:18 -07:00
|
|
|
case GUIM_MOUSE_PRESS_LEFT:
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (!m_Enabled)
|
2013-06-30 21:15:09 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
PlaySound(m_SoundDisabled);
|
2010-06-30 14:20:08 -07:00
|
|
|
break;
|
2013-06-30 21:15:09 -07:00
|
|
|
}
|
2010-06-30 14:20:08 -07:00
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
if (!m_Open)
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_List.m_Items.empty())
|
2013-10-03 17:31:36 -07:00
|
|
|
return;
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
m_Open = true;
|
2010-06-30 14:20:08 -07:00
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ElementHighlight = m_Selected;
|
2012-08-08 10:22:52 -07:00
|
|
|
|
|
|
|
|
// Start at the position of the selected item, if possible.
|
2015-08-21 10:08:41 -07:00
|
|
|
GetScrollBar(0).SetPos(m_ItemsYPositions.empty() ? 0 : m_ItemsYPositions[m_ElementHighlight] - 60);
|
2013-06-30 21:15:09 -07:00
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
PlaySound(m_SoundOpened);
|
2006-04-23 16:14:18 -07:00
|
|
|
return; // overshadow
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-08-21 03:12:33 -07:00
|
|
|
const CPos& mouse = m_pGUI.GetMousePos();
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
// If the regular area is pressed, then abort, and close.
|
|
|
|
|
if (m_CachedActualSize.PointInside(mouse))
|
|
|
|
|
{
|
|
|
|
|
m_Open = false;
|
2010-06-30 14:20:08 -07:00
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
PlaySound(m_SoundClosed);
|
2006-04-23 16:14:18 -07:00
|
|
|
return; // overshadow
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 22:40:43 -07:00
|
|
|
if (m_HideScrollBar ||
|
|
|
|
|
mouse.x < GetScrollBar(0).GetOuterRect().left ||
|
|
|
|
|
mouse.x > GetScrollBar(0).GetOuterRect().right ||
|
|
|
|
|
mouse.y < GetListRect().top)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
m_Open = false;
|
2010-06-30 14:20:08 -07:00
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-30 14:20:08 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2013-12-30 20:54:16 -08:00
|
|
|
case GUIM_MOUSE_WHEEL_DOWN:
|
|
|
|
|
{
|
2013-12-31 03:06:00 -08:00
|
|
|
// Don't switch elements by scrolling when open, causes a confusing interaction between this and the scrollbar.
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_Open || !m_Enabled)
|
2013-12-30 20:54:16 -08:00
|
|
|
break;
|
|
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ElementHighlight = m_Selected;
|
2019-08-23 07:43:10 -07:00
|
|
|
|
2013-12-30 20:54:16 -08:00
|
|
|
if (m_ElementHighlight + 1 >= (int)m_ItemsYPositions.size() - 1)
|
|
|
|
|
break;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
++m_ElementHighlight;
|
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 04:21:11 -07:00
|
|
|
SetSetting<i32>("selected", m_ElementHighlight, true);
|
2013-12-30 20:54:16 -08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GUIM_MOUSE_WHEEL_UP:
|
|
|
|
|
{
|
|
|
|
|
// Don't switch elements by scrolling when open, causes a confusing interaction between this and the scrollbar.
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_Open || !m_Enabled)
|
2013-12-30 20:54:16 -08:00
|
|
|
break;
|
|
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ElementHighlight = m_Selected;
|
2013-12-30 20:54:16 -08:00
|
|
|
if (m_ElementHighlight - 1 < 0)
|
|
|
|
|
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 04:21:11 -07:00
|
|
|
--m_ElementHighlight;
|
|
|
|
|
SetSetting<i32>("selected", m_ElementHighlight, true);
|
2013-12-30 20:54:16 -08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
case GUIM_LOST_FOCUS:
|
2013-06-30 21:15:09 -07:00
|
|
|
{
|
|
|
|
|
if (m_Open)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
PlaySound(m_SoundClosed);
|
2019-08-22 15:34:12 -07:00
|
|
|
|
2010-06-30 14:20:08 -07:00
|
|
|
m_Open = false;
|
2006-04-23 16:14:18 -07:00
|
|
|
break;
|
2013-06-30 21:15:09 -07:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
case GUIM_LOAD:
|
|
|
|
|
SetupListRect();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Important that this is after, so that overshadowed implementations aren't processed
|
|
|
|
|
CList::HandleMessage(Message);
|
2012-07-30 20:34:09 -07:00
|
|
|
|
|
|
|
|
// As HandleMessage functions return void, we need to manually verify
|
|
|
|
|
// whether the child list's items were modified.
|
|
|
|
|
if (CList::GetModified())
|
|
|
|
|
SetupText();
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2006-08-26 14:52:18 -07:00
|
|
|
InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2014-10-26 21:37:06 -07:00
|
|
|
InReaction result = IN_PASS;
|
2006-04-23 16:14:18 -07:00
|
|
|
bool update_highlight = false;
|
|
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
if (ev->ev.type == SDL_KEYDOWN)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2014-10-26 21:37:06 -07:00
|
|
|
int szChar = ev->ev.key.keysym.sym;
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
switch (szChar)
|
|
|
|
|
{
|
|
|
|
|
case '\r':
|
|
|
|
|
m_Open = false;
|
|
|
|
|
result = IN_HANDLED;
|
|
|
|
|
break;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
case SDLK_HOME:
|
|
|
|
|
case SDLK_END:
|
|
|
|
|
case SDLK_UP:
|
|
|
|
|
case SDLK_DOWN:
|
|
|
|
|
case SDLK_PAGEUP:
|
|
|
|
|
case SDLK_PAGEDOWN:
|
|
|
|
|
if (!m_Open)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
// Set current selected item to highlighted, before
|
|
|
|
|
// then really processing these in CList::ManuallyHandleEvent()
|
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 04:21:11 -07:00
|
|
|
SetSetting<i32>("selected", m_ElementHighlight, true);
|
2014-10-26 21:37:06 -07:00
|
|
|
update_highlight = true;
|
|
|
|
|
break;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
default:
|
|
|
|
|
// If we have inputed a character try to get the closest element to it.
|
|
|
|
|
// TODO: not too nice and doesn't deal with dashes.
|
|
|
|
|
if (m_Open && ((szChar >= SDLK_a && szChar <= SDLK_z) || szChar == SDLK_SPACE
|
|
|
|
|
|| (szChar >= SDLK_0 && szChar <= SDLK_9)
|
|
|
|
|
|| (szChar >= SDLK_KP_0 && szChar <= SDLK_KP_9)))
|
|
|
|
|
{
|
|
|
|
|
// arbitrary 1 second limit to add to string or start fresh.
|
|
|
|
|
// maximal amount of characters is 100, which imo is far more than enough.
|
|
|
|
|
if (timer_Time() - m_TimeOfLastInput > 1.0 || m_InputBuffer.length() >= 100)
|
|
|
|
|
m_InputBuffer = szChar;
|
|
|
|
|
else
|
|
|
|
|
m_InputBuffer += szChar;
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
m_TimeOfLastInput = timer_Time();
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
// let's look for the closest element
|
|
|
|
|
// basically it's alphabetic order and "as many letters as we can get".
|
|
|
|
|
int closest = -1;
|
|
|
|
|
int bestIndex = -1;
|
|
|
|
|
int difference = 1250;
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
for (int i = 0; i < static_cast<int>(m_List.m_Items.size()); ++i)
|
2013-07-14 05:17:07 -07:00
|
|
|
{
|
2014-10-26 21:37:06 -07:00
|
|
|
int indexOfDifference = 0;
|
|
|
|
|
int diff = 0;
|
2015-08-21 10:08:41 -07:00
|
|
|
for (size_t j = 0; j < m_InputBuffer.length(); ++j)
|
2014-10-26 21:37:06 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
diff = std::abs(static_cast<int>(m_List.m_Items[i].GetRawString().LowerCase()[j]) - static_cast<int>(m_InputBuffer[j]));
|
2014-10-26 21:37:06 -07:00
|
|
|
if (diff == 0)
|
|
|
|
|
indexOfDifference = j+1;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (indexOfDifference > bestIndex || (indexOfDifference >= bestIndex && diff < difference))
|
|
|
|
|
{
|
|
|
|
|
bestIndex = indexOfDifference;
|
|
|
|
|
closest = i;
|
|
|
|
|
difference = diff;
|
|
|
|
|
}
|
2013-07-14 05:17:07 -07:00
|
|
|
}
|
2014-10-26 21:37:06 -07:00
|
|
|
// let's select the closest element. There should basically always be one.
|
|
|
|
|
if (closest != -1)
|
2013-07-14 05:17:07 -07: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 04:21:11 -07:00
|
|
|
SetSetting<i32>("selected", closest, true);
|
2014-10-26 21:37:06 -07:00
|
|
|
update_highlight = true;
|
|
|
|
|
GetScrollBar(0).SetPos(m_ItemsYPositions[closest] - 60);
|
2013-07-14 05:17:07 -07:00
|
|
|
}
|
2014-10-26 21:37:06 -07:00
|
|
|
result = IN_HANDLED;
|
2013-07-14 05:17:07 -07:00
|
|
|
}
|
2014-10-26 21:37:06 -07:00
|
|
|
break;
|
2013-07-14 05:17:07 -07:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
if (CList::ManuallyHandleEvent(ev) == IN_HANDLED)
|
|
|
|
|
result = IN_HANDLED;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
if (update_highlight)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ElementHighlight = m_Selected;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2014-10-26 21:37:06 -07:00
|
|
|
return result;
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDropDown::SetupListRect()
|
|
|
|
|
{
|
2018-02-25 14:26:31 -08:00
|
|
|
extern int g_yres;
|
|
|
|
|
extern float g_GuiScale;
|
2019-08-23 07:43:10 -07:00
|
|
|
const float yres = g_yres / g_GuiScale;
|
|
|
|
|
|
2018-02-25 14:26:31 -08:00
|
|
|
if (m_ItemsYPositions.empty())
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom + m_DropDownBuffer,
|
|
|
|
|
m_CachedActualSize.right, m_CachedActualSize.bottom + m_DropDownBuffer + m_DropDownSize);
|
2018-02-25 14:26:31 -08:00
|
|
|
m_HideScrollBar = false;
|
|
|
|
|
}
|
|
|
|
|
// Too many items so use a scrollbar
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
else if (m_ItemsYPositions.back() > m_DropDownSize)
|
2018-02-25 14:26:31 -08:00
|
|
|
{
|
|
|
|
|
// Place items below if at least some items can be placed below
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_CachedActualSize.bottom + m_DropDownBuffer + m_DropDownSize <= yres)
|
|
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom + m_DropDownBuffer,
|
|
|
|
|
m_CachedActualSize.right, m_CachedActualSize.bottom + m_DropDownBuffer + m_DropDownSize);
|
|
|
|
|
else if ((m_ItemsYPositions.size() > m_MinimumVisibleItems && yres - m_CachedActualSize.bottom - m_DropDownBuffer >= m_ItemsYPositions[m_MinimumVisibleItems]) ||
|
2018-02-25 14:26:31 -08:00
|
|
|
m_CachedActualSize.top < yres - m_CachedActualSize.bottom)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom + m_DropDownBuffer,
|
2018-02-25 14:26:31 -08:00
|
|
|
m_CachedActualSize.right, yres);
|
|
|
|
|
// Not enough space below, thus place items above
|
|
|
|
|
else
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, std::max(0.f, m_CachedActualSize.top - m_DropDownBuffer - m_DropDownSize),
|
|
|
|
|
m_CachedActualSize.right, m_CachedActualSize.top - m_DropDownBuffer);
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
m_HideScrollBar = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-02-25 14:26:31 -08:00
|
|
|
// Enough space below, no scrollbar needed
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_CachedActualSize.bottom + m_DropDownBuffer + m_ItemsYPositions.back() <= yres)
|
2018-02-25 14:26:31 -08:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom + m_DropDownBuffer,
|
|
|
|
|
m_CachedActualSize.right, m_CachedActualSize.bottom + m_DropDownBuffer + m_ItemsYPositions.back());
|
2018-02-25 14:26:31 -08:00
|
|
|
m_HideScrollBar = true;
|
|
|
|
|
}
|
|
|
|
|
// Enough space below for some items, but not all, so place items below and use a scrollbar
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
else if ((m_ItemsYPositions.size() > m_MinimumVisibleItems && yres - m_CachedActualSize.bottom - m_DropDownBuffer >= m_ItemsYPositions[m_MinimumVisibleItems]) ||
|
2018-02-25 14:26:31 -08:00
|
|
|
m_CachedActualSize.top < yres - m_CachedActualSize.bottom)
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom + m_DropDownBuffer,
|
2018-02-25 14:26:31 -08:00
|
|
|
m_CachedActualSize.right, yres);
|
|
|
|
|
m_HideScrollBar = false;
|
|
|
|
|
}
|
|
|
|
|
// Not enough space below, thus place items above. Hide the scrollbar accordingly
|
|
|
|
|
else
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedListRect = CRect(m_CachedActualSize.left, std::max(0.f, m_CachedActualSize.top - m_DropDownBuffer - m_ItemsYPositions.back()),
|
|
|
|
|
m_CachedActualSize.right, m_CachedActualSize.top - m_DropDownBuffer);
|
|
|
|
|
m_HideScrollBar = m_CachedActualSize.top > m_ItemsYPositions.back() + m_DropDownBuffer;
|
2018-02-25 14:26:31 -08:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CRect CDropDown::GetListRect() const
|
|
|
|
|
{
|
|
|
|
|
return m_CachedListRect;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-22 16:51:10 -07:00
|
|
|
bool CDropDown::IsMouseOver() const
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
if (m_Open)
|
|
|
|
|
{
|
2018-02-25 14:26:31 -08:00
|
|
|
CRect rect(m_CachedActualSize.left, std::min(m_CachedActualSize.top, GetListRect().top),
|
|
|
|
|
m_CachedActualSize.right, std::max(m_CachedActualSize.bottom, GetListRect().bottom));
|
2019-08-21 03:12:33 -07:00
|
|
|
return rect.PointInside(m_pGUI.GetMousePos());
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
else
|
2019-08-21 03:12:33 -07:00
|
|
|
return m_CachedActualSize.PointInside(m_pGUI.GetMousePos());
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
void CDropDown::Draw()
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2019-08-23 07:43:10 -07:00
|
|
|
const float bz = GetBufferedZ();
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
const CGUISpriteInstance& sprite = m_Enabled ? m_Sprite : m_SpriteDisabled;
|
2019-08-19 03:32:29 -07:00
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_pGUI.DrawSprite(sprite, m_CellID, bz, m_CachedActualSize);
|
2006-04-23 16:14:18 -07:00
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_ButtonWidth > 0.f)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
CRect rect(m_CachedActualSize.right - m_ButtonWidth, m_CachedActualSize.top,
|
2006-04-23 16:14:18 -07:00
|
|
|
m_CachedActualSize.right, m_CachedActualSize.bottom);
|
|
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (!m_Enabled)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_pGUI.DrawSprite(m_Sprite2Disabled || m_Sprite2, m_CellID, bz + 0.05f, rect);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
else if (m_Open)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_pGUI.DrawSprite(m_Sprite2Pressed || m_Sprite2, m_CellID, bz + 0.05f, rect);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
else if (m_MouseHovering)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_pGUI.DrawSprite(m_Sprite2Over || m_Sprite2, m_CellID, bz + 0.05f, rect);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
else
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_pGUI.DrawSprite(m_Sprite2, m_CellID, bz + 0.05f, rect);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
if (m_Selected != -1) // TODO: Maybe check validity completely?
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
|
|
|
|
CRect cliparea(m_CachedActualSize.left, m_CachedActualSize.top,
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_CachedActualSize.right - m_ButtonWidth, m_CachedActualSize.bottom);
|
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 05:53:58 -07:00
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
CPos pos(m_CachedActualSize.left, m_CachedActualSize.top);
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
DrawText(m_Selected, m_Enabled ? m_TextColorSelected : m_TextColorDisabled, pos, bz + 0.1f, cliparea);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2019-08-19 03:32:29 -07:00
|
|
|
// Disable scrollbar during drawing without sending a setting-changed message
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
bool old = m_ScrollBar;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
if (m_Open)
|
|
|
|
|
{
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
// TODO: drawScrollbar as an argument of DrawList?
|
2006-04-23 16:14:18 -07:00
|
|
|
if (m_HideScrollBar)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ScrollBar = false;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
DrawList(m_ElementHighlight, m_SpriteList, m_SpriteSelectArea, m_TextColor);
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
if (m_HideScrollBar)
|
Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.
Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 05:49:59 -07:00
|
|
|
m_ScrollBar = old;
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// When a dropdown list is opened, it needs to be visible above all the other
|
|
|
|
|
// controls on the page. The only way I can think of to do this is to increase
|
|
|
|
|
// its z value when opened, so that it's probably on top.
|
|
|
|
|
float CDropDown::GetBufferedZ() const
|
|
|
|
|
{
|
|
|
|
|
float bz = CList::GetBufferedZ();
|
|
|
|
|
if (m_Open)
|
2008-07-13 14:22:03 -07:00
|
|
|
return std::min(bz + 500.f, 1000.f); // TODO - don't use magic number for max z value
|
2006-04-23 16:14:18 -07:00
|
|
|
else
|
|
|
|
|
return bz;
|
|
|
|
|
}
|