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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-10-14 14:01:13 -07:00
|
|
|
#include "precompiled.h"
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2004-10-14 14:01:13 -07:00
|
|
|
#include "CInput.h"
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2019-09-18 13:51:45 -07:00
|
|
|
#include "gui/CGUI.h"
|
2019-07-26 11:57:28 -07:00
|
|
|
#include "gui/CGUIScrollBarVertical.h"
|
2013-10-18 08:53:07 -07:00
|
|
|
#include "graphics/FontMetrics.h"
|
2012-01-29 16:27:23 -08:00
|
|
|
#include "graphics/ShaderManager.h"
|
2012-01-29 12:04:21 -08:00
|
|
|
#include "graphics/TextRenderer.h"
|
2007-09-23 03:15:28 -07:00
|
|
|
#include "lib/sysdep/clipboard.h"
|
2013-01-11 17:20:01 -08:00
|
|
|
#include "lib/timer.h"
|
2014-09-20 05:12:35 -07:00
|
|
|
#include "lib/utf8.h"
|
2013-01-11 17:20:01 -08:00
|
|
|
#include "ps/ConfigDB.h"
|
2016-08-02 09:58:30 -07:00
|
|
|
#include "ps/GameSetup/Config.h"
|
2005-10-16 16:16:08 -07:00
|
|
|
#include "ps/Globals.h"
|
2012-01-29 12:04:21 -08:00
|
|
|
#include "ps/Hotkey.h"
|
2012-01-29 16:27:23 -08:00
|
|
|
#include "renderer/Renderer.h"
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
#include <sstream>
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2012-01-29 12:04:21 -08:00
|
|
|
extern int g_yres;
|
|
|
|
|
|
2019-08-21 03:12:33 -07:00
|
|
|
CInput::CInput(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
|
|
|
:
|
|
|
|
|
IGUIObject(pGUI),
|
2019-09-30 07:08:14 -07:00
|
|
|
IGUIScrollBarOwner(*static_cast<IGUIObject*>(this)),
|
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_iBufferPos(-1),
|
|
|
|
|
m_iBufferPos_Tail(-1),
|
|
|
|
|
m_SelectingText(),
|
|
|
|
|
m_HorizontalScroll(),
|
|
|
|
|
m_PrevTime(),
|
|
|
|
|
m_CursorVisState(true),
|
|
|
|
|
m_CursorBlinkRate(0.5),
|
|
|
|
|
m_ComposingText(),
|
|
|
|
|
m_iComposedLength(),
|
|
|
|
|
m_iComposedPos(),
|
|
|
|
|
m_iInsertPos(),
|
|
|
|
|
m_BufferPosition(),
|
|
|
|
|
m_BufferZone(),
|
|
|
|
|
m_Caption(),
|
|
|
|
|
m_CellID(),
|
|
|
|
|
m_Font(),
|
|
|
|
|
m_MaskChar(),
|
|
|
|
|
m_Mask(),
|
|
|
|
|
m_MaxLength(),
|
|
|
|
|
m_MultiLine(),
|
|
|
|
|
m_Readonly(),
|
|
|
|
|
m_ScrollBar(),
|
|
|
|
|
m_ScrollBarStyle(),
|
|
|
|
|
m_Sprite(),
|
|
|
|
|
m_SpriteSelectArea(),
|
|
|
|
|
m_TextColor(),
|
|
|
|
|
m_TextColorSelected()
|
2004-10-14 14:01:13 -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("buffer_position", m_BufferPosition);
|
|
|
|
|
RegisterSetting("buffer_zone", m_BufferZone);
|
|
|
|
|
RegisterSetting("caption", m_Caption);
|
|
|
|
|
RegisterSetting("cell_id", m_CellID);
|
|
|
|
|
RegisterSetting("font", m_Font);
|
|
|
|
|
RegisterSetting("mask_char", m_MaskChar);
|
|
|
|
|
RegisterSetting("mask", m_Mask);
|
|
|
|
|
RegisterSetting("max_length", m_MaxLength);
|
|
|
|
|
RegisterSetting("multiline", m_MultiLine);
|
|
|
|
|
RegisterSetting("readonly", m_Readonly);
|
|
|
|
|
RegisterSetting("scrollbar", m_ScrollBar);
|
|
|
|
|
RegisterSetting("scrollbar_style", m_ScrollBarStyle);
|
|
|
|
|
RegisterSetting("sprite", m_Sprite);
|
|
|
|
|
RegisterSetting("sprite_selectarea", m_SpriteSelectArea);
|
|
|
|
|
RegisterSetting("textcolor", m_TextColor);
|
|
|
|
|
RegisterSetting("textcolor_selected", m_TextColorSelected);
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2014-11-17 15:29:49 -08:00
|
|
|
CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate);
|
2013-01-11 17:20:01 -08:00
|
|
|
|
2019-08-01 13:20:24 -07:00
|
|
|
CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(pGUI);
|
2004-10-14 14:01:13 -07:00
|
|
|
bar->SetRightAligned(true);
|
|
|
|
|
AddScrollBar(bar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CInput::~CInput()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 15:44:06 -08:00
|
|
|
void CInput::UpdateBufferPositionSetting()
|
|
|
|
|
{
|
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>("buffer_position", m_iBufferPos, false);
|
2015-02-02 15:44:06 -08:00
|
|
|
}
|
|
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
void CInput::ClearComposedText()
|
|
|
|
|
{
|
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_Caption.erase(m_iInsertPos, m_iComposedLength);
|
2014-10-03 16:33:41 -07:00
|
|
|
m_iBufferPos = m_iInsertPos;
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2014-10-03 16:33:41 -07:00
|
|
|
m_iComposedLength = 0;
|
|
|
|
|
m_iComposedPos = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-26 14:52:18 -07:00
|
|
|
InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
2004-10-14 14:01:13 -07:00
|
|
|
{
|
2011-04-30 06:01:45 -07:00
|
|
|
ENSURE(m_iBufferPos != -1);
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-30 05:01:17 -07:00
|
|
|
switch (ev->ev.type)
|
|
|
|
|
{
|
|
|
|
|
case SDL_HOTKEYDOWN:
|
2005-01-22 10:46:03 -08:00
|
|
|
{
|
2014-09-22 12:00:20 -07:00
|
|
|
if (m_ComposingText)
|
|
|
|
|
return IN_HANDLED;
|
2017-08-29 16:29:29 -07:00
|
|
|
|
|
|
|
|
return ManuallyHandleHotkeyEvent(ev);
|
2005-01-22 10:46:03 -08:00
|
|
|
}
|
2014-09-22 12:00:20 -07:00
|
|
|
// SDL2 has a new method of text input that better supports Unicode and CJK
|
|
|
|
|
// see https://wiki.libsdl.org/Tutorials/TextInput
|
2017-08-30 05:01:17 -07:00
|
|
|
case SDL_TEXTINPUT:
|
2014-09-22 12:00:20 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2014-09-22 12:00:20 -07:00
|
|
|
// Text has been committed, either single key presses or through an IME
|
|
|
|
|
std::wstring text = wstring_from_utf8(ev->ev.text.text);
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2014-09-22 12:00:20 -07:00
|
|
|
|
|
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
|
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
if (m_ComposingText)
|
|
|
|
|
{
|
|
|
|
|
ClearComposedText();
|
|
|
|
|
m_ComposingText = false;
|
|
|
|
|
}
|
|
|
|
|
|
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_iBufferPos == static_cast<int>(m_Caption.length()))
|
|
|
|
|
m_Caption.append(text);
|
2014-09-22 12:00:20 -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_Caption.insert(m_iBufferPos, text);
|
2014-09-22 12:00:20 -07:00
|
|
|
|
|
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2014-09-22 12:00:20 -07:00
|
|
|
m_iBufferPos += text.length();
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2014-09-22 12:00:20 -07:00
|
|
|
m_iBufferPos_Tail = -1;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2014-09-22 12:00:20 -07:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2014-09-22 12:00:20 -07:00
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2017-08-30 05:01:17 -07:00
|
|
|
case SDL_TEXTEDITING:
|
2014-09-22 12:00:20 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2014-09-22 12:00:20 -07:00
|
|
|
// Text is being composed with an IME
|
|
|
|
|
// TODO: indicate this by e.g. underlining the uncommitted text
|
2015-08-21 10:08:41 -07:00
|
|
|
const char* rawText = ev->ev.edit.text;
|
2014-10-03 16:33:41 -07:00
|
|
|
int rawLength = strlen(rawText);
|
|
|
|
|
std::wstring wtext = wstring_from_utf8(rawText);
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-02-13 17:45:13 -08:00
|
|
|
debug_printf("SDL_TEXTEDITING: text=%s, start=%d, length=%d\n", rawText, ev->ev.edit.start, ev->ev.edit.length);
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2014-09-22 12:00:20 -07:00
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
if (SelectingText())
|
2014-09-22 12:00:20 -07:00
|
|
|
DeleteCurSelection();
|
|
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
// Remember cursor position when text composition begins
|
|
|
|
|
if (!m_ComposingText)
|
|
|
|
|
m_iInsertPos = m_iBufferPos;
|
2014-09-22 12:00:20 -07:00
|
|
|
else
|
2014-10-03 16:33:41 -07:00
|
|
|
{
|
|
|
|
|
// Composed text is replaced each time
|
|
|
|
|
ClearComposedText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ComposingText = ev->ev.edit.start != 0 || rawLength != 0;
|
|
|
|
|
if (m_ComposingText)
|
|
|
|
|
{
|
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_Caption.insert(m_iInsertPos, wtext);
|
2014-09-22 12:00:20 -07:00
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
// The text buffer is limited to SDL_TEXTEDITINGEVENT_TEXT_SIZE bytes, yet start
|
|
|
|
|
// increases without limit, so don't let it advance beyond the composed text length
|
|
|
|
|
m_iComposedLength = wtext.length();
|
|
|
|
|
m_iComposedPos = ev->ev.edit.start < m_iComposedLength ? ev->ev.edit.start : m_iComposedLength;
|
|
|
|
|
m_iBufferPos = m_iInsertPos + m_iComposedPos;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2014-10-03 16:33:41 -07:00
|
|
|
// TODO: composed text selection - what does ev.edit.length do?
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2014-09-22 12:00:20 -07:00
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
|
|
|
|
|
|
|
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2014-09-22 12:00:20 -07:00
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2017-08-30 05:01:17 -07:00
|
|
|
case SDL_KEYDOWN:
|
2005-01-22 10:46:03 -08:00
|
|
|
{
|
2014-09-22 12:00:20 -07:00
|
|
|
if (m_ComposingText)
|
|
|
|
|
return IN_HANDLED;
|
2017-08-29 16:29:29 -07:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
// Since the GUI framework doesn't handle to set settings
|
|
|
|
|
// in Unicode (CStrW), we'll simply retrieve the actual
|
|
|
|
|
// pointer and edit that.
|
2017-08-30 05:01:17 -07:00
|
|
|
SDL_Keycode keyCode = ev->ev.key.keysym.sym;
|
2005-01-22 10:46:03 -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
|
|
|
ManuallyImmutableHandleKeyDownEvent(keyCode);
|
|
|
|
|
ManuallyMutableHandleKeyDownEvent(keyCode);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateBufferPositionSetting();
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2017-08-30 05:01:17 -07:00
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-29 16:29:29 -07:00
|
|
|
}
|
2005-02-04 23:25:16 -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
|
|
|
void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode)
|
2017-08-29 16:29:29 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
wchar_t cooked = 0;
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
switch (keyCode)
|
|
|
|
|
{
|
|
|
|
|
case SDLK_TAB:
|
|
|
|
|
{
|
|
|
|
|
SendEvent(GUIM_TAB, "tab");
|
2017-09-01 05:06:18 -07:00
|
|
|
// Don't send a textedit event, because it should only
|
|
|
|
|
// be sent if the GUI control changes the text
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_BACKSPACE:
|
|
|
|
|
{
|
|
|
|
|
m_WantedX = 0.0f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
2004-10-14 14:01:13 -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_Caption.empty() || m_iBufferPos == 0)
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
2004-10-14 14:01:13 -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_iBufferPos == static_cast<int>(m_Caption.length()))
|
|
|
|
|
m_Caption = m_Caption.Left(static_cast<long>(m_Caption.length()) - 1);
|
2017-08-29 16:29:29 -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_Caption =
|
|
|
|
|
m_Caption.Left(m_iBufferPos - 1) +
|
|
|
|
|
m_Caption.Right(static_cast<long>(m_Caption.length()) - m_iBufferPos);
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
--m_iBufferPos;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos + 1, m_iBufferPos);
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_DELETE:
|
|
|
|
|
{
|
|
|
|
|
m_WantedX = 0.0f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
|
|
|
|
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
|
|
|
if (m_Caption.empty() || m_iBufferPos == static_cast<int>(m_Caption.length()))
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -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_Caption =
|
|
|
|
|
m_Caption.Left(m_iBufferPos) +
|
|
|
|
|
m_Caption.Right(static_cast<long>(m_Caption.length()) - (m_iBufferPos + 1));
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos + 1, m_iBufferPos);
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_KP_ENTER:
|
|
|
|
|
case SDLK_RETURN:
|
|
|
|
|
{
|
|
|
|
|
// 'Return' should do a Press event for single liners (e.g. submitting forms)
|
|
|
|
|
// otherwise a '\n' character will be added.
|
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_MultiLine)
|
2017-08-29 16:29:29 -07:00
|
|
|
{
|
|
|
|
|
SendEvent(GUIM_PRESSED, "press");
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2017-08-29 16:29:29 -07:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
cooked = '\n'; // Change to '\n' and do default:
|
2017-09-01 13:04:53 -07:00
|
|
|
FALLTHROUGH;
|
2017-08-29 16:29:29 -07:00
|
|
|
}
|
|
|
|
|
default: // Insert a character
|
|
|
|
|
{
|
|
|
|
|
// In SDL2, we no longer get Unicode wchars via SDL_Keysym
|
|
|
|
|
// we use text input events instead and they provide UTF-8 chars
|
|
|
|
|
if (cooked == 0)
|
|
|
|
|
return;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
// check max length
|
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_MaxLength != 0 && static_cast<int>(m_Caption.length()) >= m_MaxLength)
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
m_WantedX = 0.0f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
2004-10-14 14:01:13 -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_iBufferPos == static_cast<int>(m_Caption.length()))
|
|
|
|
|
m_Caption += cooked;
|
2017-08-29 16:29:29 -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_Caption =
|
|
|
|
|
m_Caption.Left(m_iBufferPos) + cooked +
|
|
|
|
|
m_Caption.Right(static_cast<long>(m_Caption.length()) - m_iBufferPos);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos + 1);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
++m_iBufferPos;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2017-08-29 16:29:29 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-04 23:25:16 -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
|
|
|
void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode)
|
2017-08-29 16:29:29 -07:00
|
|
|
{
|
|
|
|
|
bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
switch (keyCode)
|
|
|
|
|
{
|
|
|
|
|
case SDLK_HOME:
|
|
|
|
|
{
|
|
|
|
|
// If there's not a selection, we should create one now
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
{
|
|
|
|
|
// Make sure a selection isn't created.
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
}
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
{
|
|
|
|
|
// Place tail at the current point:
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
m_iBufferPos = 0;
|
|
|
|
|
m_WantedX = 0.0f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_END:
|
|
|
|
|
{
|
|
|
|
|
// If there's not a selection, we should create one now
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
{
|
|
|
|
|
// Make sure a selection isn't created.
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
}
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
{
|
|
|
|
|
// Place tail at the current point:
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
}
|
|
|
|
|
|
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_iBufferPos = static_cast<long>(m_Caption.length());
|
2017-08-29 16:29:29 -07:00
|
|
|
m_WantedX = 0.0f;
|
|
|
|
|
|
|
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Conventions for Left/Right when text is selected:
|
|
|
|
|
*
|
|
|
|
|
* References:
|
|
|
|
|
*
|
|
|
|
|
* Visual Studio
|
|
|
|
|
* Visual Studio has the 'newer' approach, used by newer versions of
|
|
|
|
|
* things, and in newer applications. A left press will always place
|
|
|
|
|
* the pointer on the left edge of the selection, and then of course
|
|
|
|
|
* remove the selection. Right will do the exact same thing.
|
|
|
|
|
* If you have the pointer on the right edge and press right, it will
|
|
|
|
|
* in other words just remove the selection.
|
|
|
|
|
*
|
|
|
|
|
* Windows (eg. Notepad)
|
|
|
|
|
* A left press always takes the pointer a step to the left and
|
|
|
|
|
* removes the selection as if it were never there in the first place.
|
|
|
|
|
* Right of course does the same thing but to the right.
|
|
|
|
|
*
|
|
|
|
|
* I chose the Visual Studio convention. Used also in Word, gtk 2.0, MSN
|
|
|
|
|
* Messenger.
|
|
|
|
|
*/
|
|
|
|
|
case SDLK_LEFT:
|
|
|
|
|
{
|
|
|
|
|
m_WantedX = 0.f;
|
|
|
|
|
|
|
|
|
|
if (shiftKeyPressed || !SelectingText())
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (m_iBufferPos > 0)
|
|
|
|
|
--m_iBufferPos;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos_Tail < m_iBufferPos)
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
m_iBufferPos_Tail = -1;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_RIGHT:
|
|
|
|
|
{
|
|
|
|
|
m_WantedX = 0.0f;
|
|
|
|
|
|
|
|
|
|
if (shiftKeyPressed || !SelectingText())
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
2004-10-14 14:01:13 -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_iBufferPos < static_cast<int>(m_Caption.length()))
|
2017-08-29 16:29:29 -07:00
|
|
|
++m_iBufferPos;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos_Tail > m_iBufferPos)
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Conventions for Up/Down when text is selected:
|
|
|
|
|
*
|
|
|
|
|
* References:
|
|
|
|
|
*
|
|
|
|
|
* Visual Studio
|
|
|
|
|
* Visual Studio has a very strange approach, down takes you below the
|
|
|
|
|
* selection to the next row, and up to the one prior to the whole
|
|
|
|
|
* selection. The weird part is that it is always aligned as the
|
|
|
|
|
* 'pointer'. I decided this is to much work for something that is
|
|
|
|
|
* a bit arbitrary
|
|
|
|
|
*
|
|
|
|
|
* Windows (eg. Notepad)
|
|
|
|
|
* Just like with left/right, the selection is destroyed and it moves
|
|
|
|
|
* just as if there never were a selection.
|
|
|
|
|
*
|
|
|
|
|
* I chose the Notepad convention even though I use the VS convention with
|
|
|
|
|
* left/right.
|
|
|
|
|
*/
|
|
|
|
|
case SDLK_UP:
|
|
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
std::list<SRow>::iterator current = m_CharacterPositions.begin();
|
|
|
|
|
while (current != m_CharacterPositions.end())
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos >= current->m_ListStart &&
|
|
|
|
|
m_iBufferPos <= current->m_ListStart + (int)current->m_ListOfX.size())
|
|
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
++current;
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
float pos_x;
|
|
|
|
|
if (m_iBufferPos - current->m_ListStart == 0)
|
|
|
|
|
pos_x = 0.f;
|
|
|
|
|
else
|
|
|
|
|
pos_x = current->m_ListOfX[m_iBufferPos - current->m_ListStart - 1];
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (m_WantedX > pos_x)
|
|
|
|
|
pos_x = m_WantedX;
|
2005-01-22 10:46:03 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
// Now change row:
|
|
|
|
|
if (current != m_CharacterPositions.begin())
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
2017-08-29 16:29:29 -07:00
|
|
|
--current;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
// Find X-position:
|
|
|
|
|
m_iBufferPos = current->m_ListStart + GetXTextPosition(current, pos_x, m_WantedX);
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2017-08-29 16:29:29 -07:00
|
|
|
// else we can't move up
|
|
|
|
|
|
|
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_DOWN:
|
|
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
|
|
|
|
|
std::list<SRow>::iterator current = m_CharacterPositions.begin();
|
|
|
|
|
while (current != m_CharacterPositions.end())
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
2017-08-29 16:29:29 -07:00
|
|
|
if (m_iBufferPos >= current->m_ListStart &&
|
|
|
|
|
m_iBufferPos <= current->m_ListStart + (int)current->m_ListOfX.size())
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
++current;
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
float pos_x;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (m_iBufferPos - current->m_ListStart == 0)
|
|
|
|
|
pos_x = 0.f;
|
|
|
|
|
else
|
|
|
|
|
pos_x = current->m_ListOfX[m_iBufferPos - current->m_ListStart - 1];
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
if (m_WantedX > pos_x)
|
|
|
|
|
pos_x = m_WantedX;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
// Now change row:
|
|
|
|
|
// Add first, so we can check if it's .end()
|
|
|
|
|
++current;
|
|
|
|
|
if (current != m_CharacterPositions.end())
|
|
|
|
|
{
|
|
|
|
|
// Find X-position:
|
|
|
|
|
m_iBufferPos = current->m_ListStart + GetXTextPosition(current, pos_x, m_WantedX);
|
2005-01-22 10:46:03 -08:00
|
|
|
}
|
2017-08-29 16:29:29 -07:00
|
|
|
// else we can't move up
|
2010-06-30 14:20:08 -07:00
|
|
|
|
2017-08-29 16:29:29 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_PAGEUP:
|
|
|
|
|
{
|
|
|
|
|
GetScrollBar(0).ScrollMinusPlenty();
|
|
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SDLK_PAGEDOWN:
|
|
|
|
|
{
|
|
|
|
|
GetScrollBar(0).ScrollPlusPlenty();
|
|
|
|
|
UpdateAutoScroll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-01-22 10:46:03 -08:00
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|
|
|
|
{
|
|
|
|
|
bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
|
|
|
|
|
|
|
|
|
|
std::string hotkey = static_cast<const char*>(ev->ev.user.data1);
|
2017-08-29 16:53:23 -07:00
|
|
|
|
2011-06-24 17:04:41 -07:00
|
|
|
if (hotkey == "paste")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
wchar_t* text = sys_clipboard_get();
|
|
|
|
|
if (text)
|
|
|
|
|
{
|
2011-06-24 17:04:41 -07:00
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
|
|
|
|
|
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_iBufferPos == static_cast<int>(m_Caption.length()))
|
|
|
|
|
m_Caption += text;
|
2011-06-23 03:12:43 -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_Caption =
|
|
|
|
|
m_Caption.Left(m_iBufferPos) + text +
|
|
|
|
|
m_Caption.Right(static_cast<long>(m_Caption.length()) - m_iBufferPos);
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
|
|
|
|
|
|
|
|
|
|
m_iBufferPos += (int)wcslen(text);
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
sys_clipboard_free(text);
|
2017-09-01 05:06:18 -07:00
|
|
|
|
|
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2011-06-24 17:04:41 -07:00
|
|
|
else if (hotkey == "copy" || hotkey == "cut")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly && hotkey == "cut")
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
if (SelectingText())
|
|
|
|
|
{
|
|
|
|
|
int virtualFrom;
|
|
|
|
|
int virtualTo;
|
|
|
|
|
|
|
|
|
|
if (m_iBufferPos_Tail >= m_iBufferPos)
|
|
|
|
|
{
|
|
|
|
|
virtualFrom = m_iBufferPos;
|
|
|
|
|
virtualTo = m_iBufferPos_Tail;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
virtualFrom = m_iBufferPos_Tail;
|
|
|
|
|
virtualTo = m_iBufferPos;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
CStrW text = m_Caption.Left(virtualTo).Right(virtualTo - virtualFrom);
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
sys_clipboard_set(&text[0]);
|
|
|
|
|
|
2011-06-24 17:04:41 -07:00
|
|
|
if (hotkey == "cut")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
|
|
|
|
DeleteCurSelection();
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2011-06-24 17:04:41 -07:00
|
|
|
else if (hotkey == "text.delete.left")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
2017-08-31 18:51:48 -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_Caption.empty() && m_iBufferPos != 0)
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
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
|
|
|
CStrW searchString = m_Caption.Left(m_iBufferPos);
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
// If we are starting in whitespace, adjust position until we get a non whitespace
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
|
|
|
|
if (!iswspace(searchString[m_iBufferPos - 1]))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
// If we end up on a punctuation char we just delete it (treat punct like a word)
|
2011-06-23 03:12:43 -07:00
|
|
|
if (iswpunct(searchString[m_iBufferPos - 1]))
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Now we are on a non white space character, adjust position to char after next whitespace char is found
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
|
|
|
|
if (iswspace(searchString[m_iBufferPos - 1]) || iswpunct(searchString[m_iBufferPos - 1]))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2011-06-23 03:12:43 -07:00
|
|
|
DeleteCurSelection();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2011-06-23 03:12:43 -07:00
|
|
|
return IN_HANDLED;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2011-06-24 17:04:41 -07:00
|
|
|
else if (hotkey == "text.delete.right")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2017-08-29 16:53:23 -07:00
|
|
|
if (m_Readonly)
|
|
|
|
|
return IN_PASS;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
if (SelectingText())
|
|
|
|
|
DeleteCurSelection();
|
2017-08-31 18:51:48 -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_Caption.empty() && m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
|
|
|
|
// Delete the word to the right of the cursor
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
|
|
|
|
|
// Delete chars to the right unit we hit whitespace
|
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
|
|
|
while (++m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Eliminate any whitespace behind the word we just deleted
|
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
|
|
|
while (m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (!iswspace(m_Caption[m_iBufferPos]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
++m_iBufferPos;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2011-06-23 03:12:43 -07:00
|
|
|
DeleteCurSelection();
|
|
|
|
|
}
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2017-09-01 05:06:18 -07:00
|
|
|
SendEvent(GUIM_TEXTEDIT, "textedit");
|
2015-01-29 08:10:03 -08:00
|
|
|
return IN_HANDLED;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
2011-06-24 17:04:41 -07:00
|
|
|
else if (hotkey == "text.move.left")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
if (shiftKeyPressed || !SelectingText())
|
|
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
|
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_Caption.empty() && m_iBufferPos != 0)
|
2011-06-23 03:12:43 -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
|
|
|
CStrW searchString = m_Caption.Left(m_iBufferPos);
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
// If we are starting in whitespace, adjust position until we get a non whitespace
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
|
|
|
|
if (!iswspace(searchString[m_iBufferPos - 1]))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
// If we end up on a puctuation char we just select it (treat punct like a word)
|
|
|
|
|
if (iswpunct(searchString[m_iBufferPos - 1]))
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Now we are on a non white space character, adjust position to char after next whitespace char is found
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
|
|
|
|
if (iswspace(searchString[m_iBufferPos - 1]) || iswpunct(searchString[m_iBufferPos - 1]))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos_Tail < m_iBufferPos)
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2011-06-23 03:12:43 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2011-06-24 17:04:41 -07:00
|
|
|
else if (hotkey == "text.move.right")
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
m_WantedX = 0.0f;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
|
|
|
|
if (shiftKeyPressed || !SelectingText())
|
|
|
|
|
{
|
|
|
|
|
if (!shiftKeyPressed)
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
|
|
|
|
else if (!SelectingText())
|
|
|
|
|
m_iBufferPos_Tail = m_iBufferPos;
|
|
|
|
|
|
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_Caption.empty() && m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
|
|
|
|
// Select chars to the right until we hit whitespace
|
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
|
|
|
while (++m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Also select any whitespace following the word we just selected
|
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
|
|
|
while (m_iBufferPos < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (!iswspace(m_Caption[m_iBufferPos]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
++m_iBufferPos;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos_Tail > m_iBufferPos)
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
2015-01-29 08:10:03 -08:00
|
|
|
}
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2011-06-23 03:12:43 -07:00
|
|
|
UpdateAutoScroll();
|
|
|
|
|
|
|
|
|
|
return IN_HANDLED;
|
|
|
|
|
}
|
2017-08-29 16:29:29 -07:00
|
|
|
|
|
|
|
|
return IN_PASS;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
|
2019-09-30 07:08:14 -07:00
|
|
|
void CInput::ResetStates()
|
|
|
|
|
{
|
|
|
|
|
IGUIObject::ResetStates();
|
|
|
|
|
IGUIScrollBarOwner::ResetStates();
|
|
|
|
|
}
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
void CInput::HandleMessage(SGUIMessage& Message)
|
2004-10-14 14:01:13 -07:00
|
|
|
{
|
2019-09-30 07:08:14 -07:00
|
|
|
IGUIObject::HandleMessage(Message);
|
2004-10-14 14:01:13 -07:00
|
|
|
IGUIScrollBarOwner::HandleMessage(Message);
|
|
|
|
|
|
|
|
|
|
switch (Message.type)
|
|
|
|
|
{
|
|
|
|
|
case GUIM_SETTINGS_UPDATED:
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
2004-10-14 14:01:13 -07:00
|
|
|
// Update scroll-bar
|
|
|
|
|
// TODO Gee: (2004-09-01) Is this really updated each time it should?
|
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_ScrollBar &&
|
|
|
|
|
(Message.value == "size" ||
|
|
|
|
|
Message.value == "z" ||
|
|
|
|
|
Message.value == "absolute"))
|
2015-01-29 08:10:03 -08:00
|
|
|
{
|
2011-02-18 14:49:24 -08:00
|
|
|
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
|
|
|
|
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
2004-10-14 14:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update 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 (Message.value == "scrollbar_style")
|
|
|
|
|
GetScrollBar(0).SetScrollBarStyle(m_ScrollBarStyle);
|
2004-10-14 14:01:13 -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 (Message.value == "buffer_position")
|
2015-02-02 15:44:06 -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_iBufferPos = m_BufferPosition;
|
2015-02-02 15:44:06 -08:00
|
|
|
m_iBufferPos_Tail = -1; // position change resets selection
|
|
|
|
|
}
|
|
|
|
|
|
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 (Message.value == "size" ||
|
|
|
|
|
Message.value == "z" ||
|
|
|
|
|
Message.value == "font" ||
|
|
|
|
|
Message.value == "absolute" ||
|
|
|
|
|
Message.value == "caption" ||
|
|
|
|
|
Message.value == "scrollbar" ||
|
|
|
|
|
Message.value == "scrollbar_style")
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
|
|
|
|
UpdateText();
|
|
|
|
|
}
|
|
|
|
|
|
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 (Message.value == "multiline")
|
2005-02-04 23:25:16 -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
|
|
|
if (!m_MultiLine)
|
2005-02-04 23:25:16 -08:00
|
|
|
GetScrollBar(0).SetLength(0.f);
|
|
|
|
|
else
|
2015-02-02 15:44:06 -08:00
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
UpdateText();
|
|
|
|
|
}
|
2017-08-31 18:51:48 -07:00
|
|
|
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2017-08-29 16:53:23 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
case GUIM_MOUSE_PRESS_LEFT:
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
// Check if we're selecting 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_ScrollBar &&
|
|
|
|
|
m_MultiLine &&
|
2019-08-23 07:43:10 -07:00
|
|
|
GetScrollBar(0).GetStyle())
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2019-08-21 03:12:33 -07:00
|
|
|
if (m_pGUI.GetMousePos().x > m_CachedActualSize.right - GetScrollBar(0).GetStyle()->m_Width)
|
2005-02-04 23:25:16 -08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-22 12:00:20 -07:00
|
|
|
if (m_ComposingText)
|
|
|
|
|
break;
|
|
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
// Okay, this section is about pressing the mouse and
|
|
|
|
|
// choosing where the point should be placed. For
|
|
|
|
|
// instance, if we press between a and b, the point
|
|
|
|
|
// should of course be placed accordingly. Other
|
|
|
|
|
// special cases are handled like the input box norms.
|
2005-10-31 10:36:36 -08:00
|
|
|
if (g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT])
|
2005-02-04 23:25:16 -08:00
|
|
|
m_iBufferPos = GetMouseHoveringTextPosition();
|
|
|
|
|
else
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail = GetMouseHoveringTextPosition();
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
m_SelectingText = true;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
UpdateAutoScroll();
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// If we immediately release the button it will just be seen as a click
|
|
|
|
|
// for the user though.
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2011-06-23 03:12:43 -07:00
|
|
|
case GUIM_MOUSE_DBLCLICK_LEFT:
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
if (m_ComposingText)
|
|
|
|
|
break;
|
2014-09-22 12:00:20 -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_Caption.empty())
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-08-15 18:01:39 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_iBufferPos = m_iBufferPos_Tail = GetMouseHoveringTextPosition();
|
2011-06-23 03:12:43 -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_iBufferPos >= (int)m_Caption.length())
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail = m_Caption.length() - 1;
|
2011-08-15 18:01:39 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// See if we are clicking over whitespace
|
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 (iswspace(m_Caption[m_iBufferPos]))
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
// see if we are in a section of whitespace greater than one character
|
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_iBufferPos + 1 < (int) m_Caption.length() && iswspace(m_Caption[m_iBufferPos + 1])) ||
|
|
|
|
|
(m_iBufferPos - 1 > 0 && iswspace(m_Caption[m_iBufferPos - 1])))
|
2011-06-23 03:12:43 -07:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
//
|
|
|
|
|
// We are clicking in an area with more than one whitespace character
|
|
|
|
|
// so we select both the word to the left and then the word to the right
|
|
|
|
|
//
|
|
|
|
|
// [1] First the left
|
|
|
|
|
// skip the whitespace
|
|
|
|
|
while (m_iBufferPos > 0)
|
2011-06-23 03:12:43 -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 (!iswspace(m_Caption[m_iBufferPos - 1]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_iBufferPos--;
|
|
|
|
|
}
|
|
|
|
|
// now go until we hit white space or punctuation
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
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 (iswspace(m_Caption[m_iBufferPos - 1]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
m_iBufferPos--;
|
2011-08-15 18:01:39 -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 (iswpunct(m_Caption[m_iBufferPos]))
|
2011-08-15 18:01:39 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// [2] Then the right
|
|
|
|
|
// go right until we are not in whitespace
|
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
|
|
|
while (++m_iBufferPos_Tail < static_cast<int>(m_Caption.length()))
|
2015-08-21 10:08:41 -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 (!iswspace(m_Caption[m_iBufferPos_Tail]))
|
2011-08-15 18:01:39 -07:00
|
|
|
break;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2011-08-15 18:01:39 -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_iBufferPos_Tail == static_cast<int>(m_Caption.length()))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// now go to the right until we hit whitespace or punctuation
|
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
|
|
|
while (++m_iBufferPos_Tail < static_cast<int>(m_Caption.length()))
|
2015-08-21 10:08:41 -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 (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
// single whitespace so select word to the right
|
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
|
|
|
while (++m_iBufferPos_Tail < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (!iswspace(m_Caption[m_iBufferPos_Tail]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2011-06-23 03:12:43 -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_iBufferPos_Tail == static_cast<int>(m_Caption.length()))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2011-06-23 03:12:43 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Don't include the leading whitespace
|
|
|
|
|
m_iBufferPos = m_iBufferPos_Tail;
|
|
|
|
|
|
|
|
|
|
// now go to the right until we hit whitespace or punctuation
|
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
|
|
|
while (++m_iBufferPos_Tail < static_cast<int>(m_Caption.length()))
|
2011-06-23 03:12:43 -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 (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail]))
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// clicked on non-whitespace so select current word
|
|
|
|
|
// go until we hit white space or punctuation
|
|
|
|
|
while (m_iBufferPos > 0)
|
|
|
|
|
{
|
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 (iswspace(m_Caption[m_iBufferPos - 1]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
m_iBufferPos--;
|
|
|
|
|
|
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 (iswpunct(m_Caption[m_iBufferPos]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// go to the right until we hit whitespace or punctuation
|
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
|
|
|
while (++m_iBufferPos_Tail < static_cast<int>(m_Caption.length()))
|
|
|
|
|
if (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail]))
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2011-06-23 03:12:43 -07:00
|
|
|
break;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
case GUIM_MOUSE_RELEASE_LEFT:
|
2017-08-31 18:51:48 -07:00
|
|
|
{
|
2005-02-04 23:25:16 -08:00
|
|
|
if (m_SelectingText)
|
|
|
|
|
m_SelectingText = false;
|
|
|
|
|
break;
|
2017-08-31 18:51:48 -07:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
case GUIM_MOUSE_MOTION:
|
2017-08-31 18:51:48 -07:00
|
|
|
{
|
2005-02-04 23:25:16 -08:00
|
|
|
// If we just pressed down and started to move before releasing
|
|
|
|
|
// this is one way of selecting larger portions of text.
|
|
|
|
|
if (m_SelectingText)
|
|
|
|
|
{
|
|
|
|
|
// Actually, first we need to re-check that the mouse button is
|
|
|
|
|
// really pressed (it can be released while outside the control.
|
2005-10-13 11:05:55 -07:00
|
|
|
if (!g_mouse_buttons[SDL_BUTTON_LEFT])
|
2005-02-04 23:25:16 -08:00
|
|
|
m_SelectingText = false;
|
|
|
|
|
else
|
|
|
|
|
m_iBufferPos = GetMouseHoveringTextPosition();
|
|
|
|
|
UpdateAutoScroll();
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
|
|
|
|
break;
|
2017-08-31 18:51:48 -07:00
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
case GUIM_LOAD:
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
|
|
|
|
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - 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
|
|
|
GetScrollBar(0).SetScrollBarStyle(m_ScrollBarStyle);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
UpdateText();
|
2017-02-22 07:28:09 -08:00
|
|
|
UpdateAutoScroll();
|
2017-08-29 16:53:23 -07:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
break;
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
case GUIM_GOT_FOCUS:
|
2017-08-31 18:51:48 -07:00
|
|
|
{
|
2010-08-11 14:04:09 -07:00
|
|
|
m_iBufferPos = 0;
|
2013-01-11 17:20:01 -08:00
|
|
|
m_PrevTime = 0.0;
|
|
|
|
|
m_CursorVisState = false;
|
2014-09-22 12:00:20 -07:00
|
|
|
|
|
|
|
|
// Tell the IME where to draw the candidate list
|
|
|
|
|
SDL_Rect rect;
|
|
|
|
|
rect.h = m_CachedActualSize.GetSize().cy;
|
|
|
|
|
rect.w = m_CachedActualSize.GetSize().cx;
|
|
|
|
|
rect.x = m_CachedActualSize.TopLeft().x;
|
|
|
|
|
rect.y = m_CachedActualSize.TopLeft().y;
|
|
|
|
|
SDL_SetTextInputRect(&rect);
|
2014-10-03 16:33:41 -07:00
|
|
|
SDL_StartTextInput();
|
2004-10-14 14:01:13 -07:00
|
|
|
break;
|
2017-08-31 18:51:48 -07:00
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
case GUIM_LOST_FOCUS:
|
2017-08-31 18:51:48 -07:00
|
|
|
{
|
2014-09-22 12:00:20 -07:00
|
|
|
if (m_ComposingText)
|
|
|
|
|
{
|
|
|
|
|
// Simulate a final text editing event to clear the composition
|
|
|
|
|
SDL_Event_ evt;
|
|
|
|
|
evt.ev.type = SDL_TEXTEDITING;
|
|
|
|
|
evt.ev.edit.length = 0;
|
|
|
|
|
evt.ev.edit.start = 0;
|
|
|
|
|
evt.ev.edit.text[0] = 0;
|
|
|
|
|
ManuallyHandleEvent(&evt);
|
|
|
|
|
}
|
2014-10-03 16:33:41 -07:00
|
|
|
SDL_StopTextInput();
|
2014-09-22 12:00:20 -07:00
|
|
|
|
2004-10-14 14:01:13 -07:00
|
|
|
m_iBufferPos = -1;
|
2005-02-04 23:25:16 -08:00
|
|
|
m_iBufferPos_Tail = -1;
|
2004-10-14 14:01:13 -07:00
|
|
|
break;
|
2017-08-31 18:51:48 -07:00
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
default:
|
2017-08-31 18:51:48 -07:00
|
|
|
{
|
2004-10-14 14:01:13 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2017-08-31 18:51:48 -07:00
|
|
|
}
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2004-10-14 14:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
2011-02-18 14:49:24 -08:00
|
|
|
void CInput::UpdateCachedSize()
|
|
|
|
|
{
|
|
|
|
|
// If an ancestor's size changed, this will let us intercept the change and
|
|
|
|
|
// update our scrollbar positions
|
|
|
|
|
|
|
|
|
|
IGUIObject::UpdateCachedSize();
|
|
|
|
|
|
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_ScrollBar)
|
2011-02-18 14:49:24 -08:00
|
|
|
{
|
|
|
|
|
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
|
|
|
|
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-02 14:28:48 -07:00
|
|
|
void CInput::Draw()
|
2004-10-14 14:01:13 -07:00
|
|
|
{
|
|
|
|
|
float bz = GetBufferedZ();
|
|
|
|
|
|
2013-01-11 17:20:01 -08:00
|
|
|
if (m_CursorBlinkRate > 0.0)
|
|
|
|
|
{
|
|
|
|
|
// check if the cursor visibility state needs to be changed
|
|
|
|
|
double currTime = timer_Time();
|
2017-08-31 18:51:48 -07:00
|
|
|
if (currTime - m_PrevTime >= m_CursorBlinkRate)
|
2013-01-11 17:20:01 -08:00
|
|
|
{
|
|
|
|
|
m_CursorVisState = !m_CursorVisState;
|
|
|
|
|
m_PrevTime = currTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// should always be visible
|
|
|
|
|
m_CursorVisState = true;
|
|
|
|
|
|
2004-10-14 14:01:13 -07:00
|
|
|
// First call draw on ScrollBarOwner
|
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_ScrollBar && m_MultiLine)
|
2004-10-14 14:01:13 -07:00
|
|
|
IGUIScrollBarOwner::Draw();
|
2015-08-21 10:08:41 -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
|
|
|
CStrIntern font_name(m_Font.ToUTF8());
|
2015-08-21 10:08:41 -07:00
|
|
|
|
|
|
|
|
wchar_t mask_char = L'*';
|
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_Mask && m_MaskChar.length() > 0)
|
|
|
|
|
mask_char = m_MaskChar[0];
|
2015-08-21 10:08:41 -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_Sprite, m_CellID, bz, m_CachedActualSize);
|
2015-08-21 10:08:41 -07:00
|
|
|
|
|
|
|
|
float scroll = 0.f;
|
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_ScrollBar && m_MultiLine)
|
2015-08-21 10:08:41 -07:00
|
|
|
scroll = GetScrollBar(0).GetPos();
|
|
|
|
|
|
|
|
|
|
CFontMetrics font(font_name);
|
|
|
|
|
|
|
|
|
|
// We'll have to setup clipping manually, since we're doing the rendering manually.
|
|
|
|
|
CRect cliparea(m_CachedActualSize);
|
|
|
|
|
|
|
|
|
|
// First we'll figure out the clipping area, which is the cached actual size
|
|
|
|
|
// substracted by an optional 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_ScrollBar)
|
2015-01-29 08:10:03 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
scroll = GetScrollBar(0).GetPos();
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// substract scrollbar from cliparea
|
|
|
|
|
if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
|
2017-08-31 18:51:48 -07:00
|
|
|
cliparea.right <= GetScrollBar(0).GetOuterRect().right)
|
2015-08-21 10:08:41 -07:00
|
|
|
cliparea.right = GetScrollBar(0).GetOuterRect().left;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
|
2017-08-31 18:51:48 -07:00
|
|
|
cliparea.left < GetScrollBar(0).GetOuterRect().right)
|
2015-08-21 10:08:41 -07:00
|
|
|
cliparea.left = GetScrollBar(0).GetOuterRect().right;
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (cliparea != CRect())
|
|
|
|
|
{
|
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
|
glScissor(
|
2017-06-14 10:13:44 -07:00
|
|
|
cliparea.left * g_GuiScale,
|
|
|
|
|
g_yres - cliparea.bottom * g_GuiScale,
|
|
|
|
|
cliparea.GetWidth() * g_GuiScale,
|
|
|
|
|
cliparea.GetHeight() * g_GuiScale);
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// These are useful later.
|
|
|
|
|
int VirtualFrom, VirtualTo;
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (m_iBufferPos_Tail >= m_iBufferPos)
|
|
|
|
|
{
|
|
|
|
|
VirtualFrom = m_iBufferPos;
|
|
|
|
|
VirtualTo = m_iBufferPos_Tail;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
VirtualFrom = m_iBufferPos_Tail;
|
|
|
|
|
VirtualTo = m_iBufferPos;
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Get the height of this font.
|
|
|
|
|
float h = (float)font.GetHeight();
|
|
|
|
|
float ls = (float)font.GetLineSpacing();
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text);
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
CTextRenderer textRenderer(tech->GetShader());
|
|
|
|
|
textRenderer.Font(font_name);
|
2005-07-24 17:52:03 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Set the Z to somewhat more, so we can draw a selected area between the
|
|
|
|
|
// the control and the text.
|
|
|
|
|
textRenderer.Translate(
|
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
|
|
|
(float)(int)(m_CachedActualSize.left) + m_BufferZone,
|
|
|
|
|
(float)(int)(m_CachedActualSize.top+h) + m_BufferZone,
|
2015-08-21 10:08:41 -07:00
|
|
|
bz+0.1f);
|
2005-07-24 17:52:03 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// U+FE33: PRESENTATION FORM FOR VERTICAL LOW LINE
|
|
|
|
|
// (sort of like a | which is aligned to the left of most characters)
|
2005-07-24 17:52:03 -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
|
|
|
float buffered_y = -scroll + m_BufferZone;
|
2005-07-24 17:52:03 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// When selecting larger areas, we need to draw a rectangle box
|
|
|
|
|
// around it, and this is to keep track of where the box
|
|
|
|
|
// started, because we need to follow the iteration until we
|
|
|
|
|
// reach the end, before we can actually draw it.
|
|
|
|
|
bool drawing_box = false;
|
|
|
|
|
float box_x = 0.f;
|
|
|
|
|
|
|
|
|
|
float x_pointer = 0.f;
|
|
|
|
|
|
|
|
|
|
// If we have a selecting box (i.e. when you have selected letters, not just when
|
|
|
|
|
// the pointer is between two letters) we need to process all letters once
|
|
|
|
|
// before we do it the second time and render all the text. We can't do it
|
|
|
|
|
// in the same loop because text will have been drawn, so it will disappear when
|
|
|
|
|
// drawn behind the text that has already been drawn. Confusing, well it's necessary
|
|
|
|
|
// (I think).
|
|
|
|
|
|
|
|
|
|
if (SelectingText())
|
|
|
|
|
{
|
|
|
|
|
// Now m_iBufferPos_Tail can be of both sides of m_iBufferPos,
|
|
|
|
|
// just like you can select from right to left, as you can
|
|
|
|
|
// left to right. Is there a difference? Yes, the pointer
|
|
|
|
|
// be placed accordingly, so that if you select shift and
|
|
|
|
|
// expand this selection, it will expand on appropriate side.
|
|
|
|
|
// Anyway, since the drawing procedure needs "To" to be
|
|
|
|
|
// greater than from, we need virtual values that might switch
|
|
|
|
|
// place.
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
int VirtualFrom, VirtualTo;
|
|
|
|
|
|
|
|
|
|
if (m_iBufferPos_Tail >= m_iBufferPos)
|
|
|
|
|
{
|
|
|
|
|
VirtualFrom = m_iBufferPos;
|
|
|
|
|
VirtualTo = m_iBufferPos_Tail;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
VirtualFrom = m_iBufferPos_Tail;
|
|
|
|
|
VirtualTo = m_iBufferPos;
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
bool done = false;
|
|
|
|
|
for (std::list<SRow>::const_iterator it = m_CharacterPositions.begin();
|
|
|
|
|
it != m_CharacterPositions.end();
|
|
|
|
|
++it, buffered_y += ls, x_pointer = 0.f)
|
2004-10-14 14:01:13 -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_MultiLine && buffered_y > m_CachedActualSize.GetHeight())
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// We might as well use 'i' here to iterate, because we need it
|
|
|
|
|
// (often compared against ints, so don't make it size_t)
|
|
|
|
|
for (int i = 0; i < (int)it->m_ListOfX.size()+2; ++i)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
if (it->m_ListStart + i == VirtualFrom)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
// we won't actually draw it now, because we don't
|
|
|
|
|
// know the width of each glyph to that position.
|
|
|
|
|
// we need to go along with the iteration, and
|
|
|
|
|
// make a mark where the box started:
|
|
|
|
|
drawing_box = true; // will turn false when finally rendered.
|
|
|
|
|
|
|
|
|
|
// Get current x position
|
|
|
|
|
box_x = x_pointer;
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
const bool at_end = (i == (int)it->m_ListOfX.size()+1);
|
2005-08-09 08:55:44 -07:00
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (drawing_box && (it->m_ListStart + i == VirtualTo || at_end))
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
// Depending on if it's just a row change, or if it's
|
|
|
|
|
// the end of the select box, do slightly different things.
|
|
|
|
|
if (at_end)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
if (it->m_ListStart + i != VirtualFrom)
|
|
|
|
|
// and actually add a white space! yes, this is done in any common input
|
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
|
|
|
x_pointer += font.GetCharacterWidth(L' ');
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
drawing_box = false;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
CRect rect;
|
|
|
|
|
// Set 'rect' depending on if it's a multiline control, or a one-line control
|
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_MultiLine)
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
2017-08-31 18:51:48 -07:00
|
|
|
rect = CRect(
|
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.left + box_x + m_BufferZone,
|
2017-08-31 18:51:48 -07:00
|
|
|
m_CachedActualSize.top + buffered_y + (h - ls) / 2,
|
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.left + x_pointer + m_BufferZone,
|
2017-08-31 18:51:48 -07:00
|
|
|
m_CachedActualSize.top + buffered_y + (h + ls) / 2);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (rect.bottom < m_CachedActualSize.top)
|
|
|
|
|
continue;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (rect.top < m_CachedActualSize.top)
|
|
|
|
|
rect.top = m_CachedActualSize.top;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (rect.bottom > m_CachedActualSize.bottom)
|
|
|
|
|
rect.bottom = m_CachedActualSize.bottom;
|
|
|
|
|
}
|
|
|
|
|
else // if one-line
|
|
|
|
|
{
|
2017-08-31 18:51:48 -07:00
|
|
|
rect = CRect(
|
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.left + box_x + m_BufferZone - m_HorizontalScroll,
|
2017-08-31 18:51:48 -07:00
|
|
|
m_CachedActualSize.top + buffered_y + (h - ls) / 2,
|
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.left + x_pointer + m_BufferZone - m_HorizontalScroll,
|
2017-08-31 18:51:48 -07:00
|
|
|
m_CachedActualSize.top + buffered_y + (h + ls) / 2);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (rect.left < m_CachedActualSize.left)
|
|
|
|
|
rect.left = m_CachedActualSize.left;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (rect.right > m_CachedActualSize.right)
|
|
|
|
|
rect.right = m_CachedActualSize.right;
|
2005-02-04 23:25:16 -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_pGUI.DrawSprite(m_SpriteSelectArea, m_CellID, bz + 0.05f, rect);
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (i < (int)it->m_ListOfX.size())
|
2005-02-04 23:25:16 -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
|
|
|
if (!m_Mask)
|
|
|
|
|
x_pointer += font.GetCharacterWidth(m_Caption[it->m_ListStart + i]);
|
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
|
|
|
x_pointer += font.GetCharacterWidth(mask_char);
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// If we're about to draw a box, and all of a sudden changes
|
|
|
|
|
// line, we need to draw that line's box, and then reset
|
|
|
|
|
// the box drawing to the beginning of the new line.
|
|
|
|
|
if (drawing_box)
|
|
|
|
|
box_x = 0.f;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Reset some from previous run
|
|
|
|
|
buffered_y = -scroll;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Setup initial color (then it might change and change back, when drawing selected area)
|
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
|
|
|
textRenderer.Color(m_TextColor);
|
2012-01-29 12:04:21 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
tech->BeginPass();
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
bool using_selected_color = false;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
for (std::list<SRow>::const_iterator it = m_CharacterPositions.begin();
|
|
|
|
|
it != m_CharacterPositions.end();
|
|
|
|
|
++it, buffered_y += ls)
|
|
|
|
|
{
|
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 (buffered_y + m_BufferZone >= -ls || !m_MultiLine)
|
2005-02-04 23:25:16 -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
|
|
|
if (m_MultiLine && buffered_y + m_BufferZone > m_CachedActualSize.GetHeight())
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
CMatrix3D savedTransform = textRenderer.GetTransform();
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// Text must always be drawn in integer values. So we have to convert scroll
|
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_MultiLine)
|
2015-08-21 10:08:41 -07:00
|
|
|
textRenderer.Translate(0.f, -(float)(int)scroll, 0.f);
|
|
|
|
|
else
|
|
|
|
|
textRenderer.Translate(-(float)(int)m_HorizontalScroll, 0.f, 0.f);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// We might as well use 'i' here, because we need it
|
|
|
|
|
// (often compared against ints, so don't make it size_t)
|
|
|
|
|
for (int i = 0; i < (int)it->m_ListOfX.size()+1; ++i)
|
|
|
|
|
{
|
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_MultiLine && i < (int)it->m_ListOfX.size())
|
2005-02-04 23:25:16 -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
|
|
|
if (it->m_ListOfX[i] - m_HorizontalScroll < -m_BufferZone)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
// We still need to translate the OpenGL matrix
|
|
|
|
|
if (i == 0)
|
|
|
|
|
textRenderer.Translate(it->m_ListOfX[i], 0.f, 0.f);
|
2013-11-07 12:07:24 -08:00
|
|
|
else
|
2015-08-21 10:08:41 -07:00
|
|
|
textRenderer.Translate(it->m_ListOfX[i] - it->m_ListOfX[i-1], 0.f, 0.f);
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
continue;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// End of selected area, change back color
|
2017-08-31 18:51:48 -07:00
|
|
|
if (SelectingText() && it->m_ListStart + i == VirtualTo)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
using_selected_color = false;
|
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
|
|
|
textRenderer.Color(m_TextColor);
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// selecting only one, then we need only to draw a cursor.
|
2017-08-31 18:51:48 -07:00
|
|
|
if (i != (int)it->m_ListOfX.size() && it->m_ListStart + i == m_iBufferPos && m_CursorVisState)
|
2015-08-21 10:08:41 -07:00
|
|
|
textRenderer.Put(0.0f, 0.0f, L"_");
|
|
|
|
|
|
|
|
|
|
// Drawing selected area
|
|
|
|
|
if (SelectingText() &&
|
2017-08-31 18:51:48 -07:00
|
|
|
it->m_ListStart + i >= VirtualFrom &&
|
|
|
|
|
it->m_ListStart + i < VirtualTo &&
|
|
|
|
|
!using_selected_color)
|
2015-08-21 10:08:41 -07:00
|
|
|
{
|
|
|
|
|
using_selected_color = true;
|
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
|
|
|
textRenderer.Color(m_TextColorSelected);
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i != (int)it->m_ListOfX.size())
|
|
|
|
|
{
|
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_Mask)
|
|
|
|
|
textRenderer.PrintfAdvance(L"%lc", m_Caption[it->m_ListStart + i]);
|
2015-08-21 10:08:41 -07:00
|
|
|
else
|
|
|
|
|
textRenderer.PrintfAdvance(L"%lc", mask_char);
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
// check it's now outside a one-liner, then we'll 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
|
|
|
if (!m_MultiLine && i < (int)it->m_ListOfX.size() &&
|
|
|
|
|
it->m_ListOfX[i] - m_HorizontalScroll > m_CachedActualSize.GetWidth() - m_BufferZone)
|
2015-08-21 10:08:41 -07:00
|
|
|
break;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
2012-01-29 12:04:21 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (it->m_ListStart + (int)it->m_ListOfX.size() == m_iBufferPos)
|
|
|
|
|
{
|
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
|
|
|
textRenderer.Color(m_TextColor);
|
2015-08-21 10:08:41 -07:00
|
|
|
if (m_CursorVisState)
|
|
|
|
|
textRenderer.PutAdvance(L"_");
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
if (using_selected_color)
|
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
|
|
|
textRenderer.Color(m_TextColorSelected);
|
2015-08-21 10:08:41 -07:00
|
|
|
}
|
2012-01-29 12:04:21 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
textRenderer.SetTransform(savedTransform);
|
|
|
|
|
}
|
2004-10-14 14:01:13 -07:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
textRenderer.Translate(0.f, ls, 0.f);
|
2004-10-14 14:01:13 -07:00
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
|
|
|
|
|
textRenderer.Render();
|
|
|
|
|
|
|
|
|
|
if (cliparea != CRect())
|
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
|
|
|
|
|
|
tech->EndPass();
|
2004-10-14 14:01:13 -07:00
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
void CInput::UpdateText(int from, int to_before, int to_after)
|
|
|
|
|
{
|
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
|
|
|
CStrIntern font_name(m_Font.ToUTF8());
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2013-11-07 12:07:24 -08:00
|
|
|
wchar_t mask_char = L'*';
|
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_Mask && m_MaskChar.length() > 0)
|
|
|
|
|
mask_char = m_MaskChar[0];
|
2013-11-07 12:07:24 -08:00
|
|
|
|
2010-07-02 14:28:48 -07:00
|
|
|
// Ensure positions are valid after caption changes
|
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_iBufferPos = std::min(m_iBufferPos, static_cast<int>(m_Caption.size()));
|
|
|
|
|
m_iBufferPos_Tail = std::min(m_iBufferPos_Tail, static_cast<int>(m_Caption.size()));
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2010-07-02 14:28:48 -07:00
|
|
|
|
2013-07-07 13:02:20 -07:00
|
|
|
if (font_name.empty())
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2017-08-31 18:51:48 -07:00
|
|
|
// Destroy everything stored, there's no font, so there can be no data.
|
2005-02-04 23:25:16 -08:00
|
|
|
m_CharacterPositions.clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
SRow row;
|
|
|
|
|
row.m_ListStart = 0;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2005-08-09 08:55:44 -07:00
|
|
|
int to = 0; // make sure it's initialized
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
if (to_before == -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
|
|
|
to = static_cast<int>(m_Caption.length());
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2013-10-18 08:53:07 -07:00
|
|
|
CFontMetrics font(font_name);
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2008-07-13 14:22:03 -07:00
|
|
|
std::list<SRow>::iterator current_line;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
// Used to ... TODO
|
|
|
|
|
int check_point_row_start = -1;
|
|
|
|
|
int check_point_row_end = -1;
|
|
|
|
|
|
|
|
|
|
// Reset
|
|
|
|
|
if (from == 0 && to_before == -1)
|
|
|
|
|
{
|
|
|
|
|
m_CharacterPositions.clear();
|
|
|
|
|
current_line = m_CharacterPositions.begin();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-04-30 06:01:45 -07:00
|
|
|
ENSURE(to_before != -1);
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
std::list<SRow>::iterator destroy_row_from;
|
|
|
|
|
std::list<SRow>::iterator destroy_row_to;
|
|
|
|
|
// Used to check if the above has been set to anything,
|
2005-02-04 23:25:16 -08:00
|
|
|
// previously a comparison like:
|
2008-07-13 14:22:03 -07:00
|
|
|
// destroy_row_from == std::list<SRow>::iterator()
|
2005-02-04 23:25:16 -08:00
|
|
|
// ... was used, but it didn't work with GCC.
|
2015-08-21 10:08:41 -07:00
|
|
|
bool destroy_row_from_used = false;
|
|
|
|
|
bool destroy_row_to_used = false;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
// Iterate, and remove everything between 'from' and 'to_before'
|
|
|
|
|
// actually remove the entire lines they are on, it'll all have
|
|
|
|
|
// to be redone. And when going along, we'll delete a row at a time
|
|
|
|
|
// when continuing to see how much more after 'to' we need to remake.
|
2015-08-21 10:08:41 -07:00
|
|
|
int i = 0;
|
|
|
|
|
for (std::list<SRow>::iterator it = m_CharacterPositions.begin();
|
|
|
|
|
it != m_CharacterPositions.end();
|
|
|
|
|
++it, ++i)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_from_used && it->m_ListStart > from)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
|
|
|
|
// Destroy the previous line, and all to 'to_before'
|
|
|
|
|
destroy_row_from = it;
|
|
|
|
|
--destroy_row_from;
|
|
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
destroy_row_from_used = true;
|
|
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
// For the rare case that we might remove characters to a word
|
2005-02-04 23:25:16 -08:00
|
|
|
// so that it suddenly fits on the previous row,
|
2015-08-21 10:08:41 -07:00
|
|
|
// we need to by standards re-do the whole previous line too
|
2005-02-04 23:25:16 -08:00
|
|
|
// (if one exists)
|
2004-11-24 15:39:52 -08:00
|
|
|
if (destroy_row_from != m_CharacterPositions.begin())
|
|
|
|
|
--destroy_row_from;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_to_used && it->m_ListStart > to_before)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
|
|
|
|
destroy_row_to = it;
|
2005-02-04 23:25:16 -08:00
|
|
|
destroy_row_to_used = true;
|
|
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
// If it isn't the last row, we'll add another row to delete,
|
2015-08-21 10:08:41 -07:00
|
|
|
// just so we can see if the last restorted line is
|
2004-11-24 15:39:52 -08:00
|
|
|
// identical to what it was before. If it isn't, then we'll
|
|
|
|
|
// have to continue.
|
|
|
|
|
// 'check_point_row_start' is where we store how the that
|
|
|
|
|
// line looked.
|
|
|
|
|
if (destroy_row_to != m_CharacterPositions.end())
|
|
|
|
|
{
|
|
|
|
|
check_point_row_start = destroy_row_to->m_ListStart;
|
2005-02-05 06:53:06 -08:00
|
|
|
check_point_row_end = check_point_row_start + (int)destroy_row_to->m_ListOfX.size();
|
2004-11-24 15:39:52 -08:00
|
|
|
if (destroy_row_to->m_ListOfX.empty())
|
|
|
|
|
++check_point_row_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++destroy_row_to;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_from_used)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
|
|
|
|
destroy_row_from = m_CharacterPositions.end();
|
|
|
|
|
--destroy_row_from;
|
|
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// As usual, let's destroy another row back
|
|
|
|
|
if (destroy_row_from != m_CharacterPositions.begin())
|
|
|
|
|
--destroy_row_from;
|
|
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
current_line = destroy_row_from;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_to_used)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2011-06-23 03:12:43 -07:00
|
|
|
destroy_row_to = m_CharacterPositions.end();
|
2004-11-24 15:39:52 -08:00
|
|
|
check_point_row_start = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set 'from' to the row we'll destroy from
|
|
|
|
|
// and 'to' to the row we'll destroy to
|
|
|
|
|
from = destroy_row_from->m_ListStart;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
if (destroy_row_to != m_CharacterPositions.end())
|
2011-06-23 03:12:43 -07:00
|
|
|
to = destroy_row_to->m_ListStart; // notice it will iterate [from, to), so it will never reach to.
|
2004-11-24 15:39:52 -08: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
|
|
|
to = static_cast<int>(m_Caption.length());
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Setup the first row
|
|
|
|
|
row.m_ListStart = destroy_row_from->m_ListStart;
|
|
|
|
|
|
2008-07-13 14:22:03 -07:00
|
|
|
std::list<SRow>::iterator temp_it = destroy_row_to;
|
2004-11-24 15:39:52 -08:00
|
|
|
--temp_it;
|
|
|
|
|
|
2013-07-07 13:02:20 -07:00
|
|
|
current_line = m_CharacterPositions.erase(destroy_row_from, destroy_row_to);
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
// If there has been a change in number of characters
|
|
|
|
|
// we need to change all m_ListStart that comes after
|
|
|
|
|
// the interval we just destroyed. We'll change all
|
|
|
|
|
// values with the delta change of the string length.
|
|
|
|
|
int delta = to_after - to_before;
|
|
|
|
|
if (delta != 0)
|
|
|
|
|
{
|
2013-07-07 13:02:20 -07:00
|
|
|
for (std::list<SRow>::iterator it = current_line;
|
2015-08-21 10:08:41 -07:00
|
|
|
it != m_CharacterPositions.end();
|
|
|
|
|
++it)
|
2004-11-24 15:39:52 -08:00
|
|
|
it->m_ListStart += delta;
|
|
|
|
|
|
|
|
|
|
// Update our check point too!
|
|
|
|
|
check_point_row_start += delta;
|
|
|
|
|
check_point_row_end += delta;
|
|
|
|
|
|
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 (to != static_cast<int>(m_Caption.length()))
|
2004-11-24 15:39:52 -08:00
|
|
|
to += delta;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
int last_word_started = from;
|
2004-11-24 15:39:52 -08:00
|
|
|
float x_pos = 0.f;
|
|
|
|
|
|
|
|
|
|
//if (to_before != -1)
|
|
|
|
|
// return;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
for (int i = from; i < to; ++i)
|
2004-11-24 15:39:52 -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
|
|
|
if (m_Caption[i] == L'\n' && m_MultiLine)
|
2004-11-24 15:39:52 -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
|
|
|
if (i == to-1 && to != static_cast<int>(m_Caption.length()))
|
2004-11-24 15:39:52 -08:00
|
|
|
break; // it will be added outside
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
current_line = m_CharacterPositions.insert(current_line, row);
|
2004-11-24 15:39:52 -08:00
|
|
|
++current_line;
|
|
|
|
|
|
|
|
|
|
// Setup the next row:
|
|
|
|
|
row.m_ListOfX.clear();
|
|
|
|
|
row.m_ListStart = i+1;
|
|
|
|
|
x_pos = 0.f;
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (m_Caption[i] == L' '/* || TODO Gee (2004-10-13): the '-' disappears, fix.
|
|
|
|
|
m_Caption[i] == L'-'*/)
|
2004-11-24 15:39:52 -08:00
|
|
|
last_word_started = i+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
|
|
|
if (!m_Mask)
|
|
|
|
|
x_pos += font.GetCharacterWidth(m_Caption[i]);
|
2013-11-07 12:07:24 -08: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
|
|
|
x_pos += font.GetCharacterWidth(mask_char);
|
2004-11-24 15:39:52 -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
|
|
|
if (x_pos >= GetTextAreaWidth() && m_MultiLine)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
|
|
|
|
// The following decides whether it will word-wrap a word,
|
|
|
|
|
// or if it's only one word on the line, where it has to
|
|
|
|
|
// break the word apart.
|
|
|
|
|
if (last_word_started == row.m_ListStart)
|
|
|
|
|
{
|
|
|
|
|
last_word_started = i;
|
|
|
|
|
row.m_ListOfX.resize(row.m_ListOfX.size() - (i-last_word_started));
|
2015-08-21 10:08:41 -07:00
|
|
|
//row.m_ListOfX.push_back(x_pos);
|
2004-11-24 15:39:52 -08:00
|
|
|
//continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// regular word-wrap
|
|
|
|
|
row.m_ListOfX.resize(row.m_ListOfX.size() - (i-last_word_started+1));
|
|
|
|
|
}
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2004-11-24 15:39:52 -08:00
|
|
|
// Now, create a new line:
|
|
|
|
|
// notice: when we enter a newline, you can stand with the cursor
|
|
|
|
|
// both before and after that character, being on different
|
|
|
|
|
// rows. With automatic word-wrapping, that is not possible. Which
|
|
|
|
|
// is intuitively correct.
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
current_line = m_CharacterPositions.insert(current_line, row);
|
2004-11-24 15:39:52 -08:00
|
|
|
++current_line;
|
|
|
|
|
|
|
|
|
|
// Setup the next row:
|
|
|
|
|
row.m_ListOfX.clear();
|
|
|
|
|
row.m_ListStart = last_word_started;
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
i = last_word_started-1;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
x_pos = 0.f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// Get width of this character:
|
2015-08-21 10:08:41 -07:00
|
|
|
row.m_ListOfX.push_back(x_pos);
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if it's the last iteration, and we're not revising the whole string
|
|
|
|
|
// because in that case, more word-wrapping might be needed.
|
|
|
|
|
// also check if the current line isn't the end
|
|
|
|
|
if (to_before != -1 && i == to-1 && current_line != m_CharacterPositions.end())
|
|
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
// check all rows and see if any existing
|
2005-02-04 23:25:16 -08:00
|
|
|
if (row.m_ListStart != check_point_row_start)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
std::list<SRow>::iterator destroy_row_from;
|
|
|
|
|
std::list<SRow>::iterator destroy_row_to;
|
|
|
|
|
// Are used to check if the above has been set to anything,
|
2005-02-04 23:25:16 -08:00
|
|
|
// previously a comparison like:
|
2008-07-13 14:22:03 -07:00
|
|
|
// destroy_row_from == std::list<SRow>::iterator()
|
2005-02-04 23:25:16 -08:00
|
|
|
// was used, but it didn't work with GCC.
|
2015-08-21 10:08:41 -07:00
|
|
|
bool destroy_row_from_used = false;
|
|
|
|
|
bool destroy_row_to_used = false;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Iterate, and remove everything between 'from' and 'to_before'
|
|
|
|
|
// actually remove the entire lines they are on, it'll all have
|
|
|
|
|
// to be redone. And when going along, we'll delete a row at a time
|
|
|
|
|
// when continuing to see how much more after 'to' we need to remake.
|
2015-08-21 10:08:41 -07:00
|
|
|
int i = 0;
|
|
|
|
|
for (std::list<SRow>::iterator it = m_CharacterPositions.begin();
|
|
|
|
|
it != m_CharacterPositions.end();
|
|
|
|
|
++it, ++i)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_from_used && it->m_ListStart > check_point_row_start)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
|
|
|
|
// Destroy the previous line, and all to 'to_before'
|
|
|
|
|
//if (i >= 2)
|
|
|
|
|
// destroy_row_from = it-2;
|
|
|
|
|
//else
|
|
|
|
|
// destroy_row_from = it-1;
|
|
|
|
|
destroy_row_from = it;
|
|
|
|
|
destroy_row_from_used = true;
|
|
|
|
|
//--destroy_row_from;
|
|
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_to_used && it->m_ListStart > check_point_row_end)
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2005-02-04 23:25:16 -08:00
|
|
|
destroy_row_to = it;
|
|
|
|
|
destroy_row_to_used = true;
|
|
|
|
|
|
|
|
|
|
// If it isn't the last row, we'll add another row to delete,
|
2015-08-21 10:08:41 -07:00
|
|
|
// just so we can see if the last restorted line is
|
2005-02-04 23:25:16 -08:00
|
|
|
// identical to what it was before. If it isn't, then we'll
|
|
|
|
|
// have to continue.
|
|
|
|
|
// 'check_point_row_start' is where we store how the that
|
|
|
|
|
// line looked.
|
|
|
|
|
if (destroy_row_to != m_CharacterPositions.end())
|
2004-11-24 15:39:52 -08:00
|
|
|
{
|
2005-02-04 23:25:16 -08:00
|
|
|
check_point_row_start = destroy_row_to->m_ListStart;
|
2005-02-05 06:53:06 -08:00
|
|
|
check_point_row_end = check_point_row_start + (int)destroy_row_to->m_ListOfX.size();
|
2005-02-04 23:25:16 -08:00
|
|
|
if (destroy_row_to->m_ListOfX.empty())
|
|
|
|
|
++check_point_row_end;
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
else
|
|
|
|
|
check_point_row_start = check_point_row_end = -1;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
++destroy_row_to;
|
|
|
|
|
break;
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_from_used)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
|
|
|
|
destroy_row_from = m_CharacterPositions.end();
|
|
|
|
|
--destroy_row_from;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
current_line = destroy_row_from;
|
|
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2017-08-31 18:51:48 -07:00
|
|
|
if (!destroy_row_to_used)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
|
|
|
|
destroy_row_to = m_CharacterPositions.end();
|
|
|
|
|
check_point_row_start = check_point_row_end = -1;
|
|
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
if (destroy_row_to != m_CharacterPositions.end())
|
|
|
|
|
to = destroy_row_to->m_ListStart; // notice it will iterate [from, to[, so it will never reach to.
|
|
|
|
|
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
|
|
|
to = static_cast<int>(m_Caption.length());
|
2004-11-24 15:39:52 -08:00
|
|
|
|
|
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// Set current line, new rows will be added before current_line, so
|
|
|
|
|
// we'll choose the destroy_row_to, because it won't be deleted
|
|
|
|
|
// in the coming erase.
|
|
|
|
|
current_line = destroy_row_to;
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
m_CharacterPositions.erase(destroy_row_from, destroy_row_to);
|
|
|
|
|
}
|
|
|
|
|
// else, the for loop will end naturally.
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
|
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
// This is kind of special, when we renew a some lines, then the last
|
|
|
|
|
// one will sometimes end with a space (' '), that really should
|
|
|
|
|
// be omitted when word-wrapping. So we'll check if the last row
|
|
|
|
|
// we'll add has got the same value as the next row.
|
|
|
|
|
if (current_line != m_CharacterPositions.end())
|
|
|
|
|
{
|
2005-08-09 08:55:44 -07:00
|
|
|
if (row.m_ListStart + (int)row.m_ListOfX.size() == current_line->m_ListStart)
|
2015-08-21 10:08:41 -07:00
|
|
|
row.m_ListOfX.resize(row.m_ListOfX.size()-1);
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
2004-11-24 15:39:52 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// add the final row (even if empty)
|
2011-02-18 14:49:24 -08:00
|
|
|
m_CharacterPositions.insert(current_line, row);
|
2005-02-04 23:25:16 -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
|
|
|
if (m_ScrollBar)
|
2005-02-04 23:25:16 -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
|
|
|
GetScrollBar(0).SetScrollRange(m_CharacterPositions.size() * font.GetLineSpacing() + m_BufferZone * 2.f);
|
2011-02-18 14:49:24 -08:00
|
|
|
GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight());
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
int CInput::GetMouseHoveringTextPosition() const
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
|
|
|
|
if (m_CharacterPositions.empty())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
// Return position
|
2011-06-23 03:12:43 -07:00
|
|
|
int retPosition;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
std::list<SRow>::const_iterator current = m_CharacterPositions.begin();
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2019-08-21 03:12:33 -07:00
|
|
|
CPos mouse = m_pGUI.GetMousePos();
|
2005-02-04 23:25:16 -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
|
|
|
if (m_MultiLine)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
float scroll = 0.f;
|
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_ScrollBar)
|
2015-08-21 10:08:41 -07:00
|
|
|
scroll = GetScrollBarPos(0);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Now get the height of the font.
|
|
|
|
|
// TODO: Get the real font
|
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
|
|
|
CFontMetrics font(CStrIntern(m_Font.ToUTF8()));
|
2005-02-05 06:53:06 -08:00
|
|
|
float spacing = (float)font.GetLineSpacing();
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Change mouse position relative to text.
|
|
|
|
|
mouse -= m_CachedActualSize.TopLeft();
|
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
|
|
|
mouse.x -= m_BufferZone;
|
|
|
|
|
mouse.y += scroll - m_BufferZone;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
int row = (int)((mouse.y) / spacing);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
if (row < 0)
|
|
|
|
|
row = 0;
|
|
|
|
|
|
2005-02-05 06:53:06 -08:00
|
|
|
if (row > (int)m_CharacterPositions.size()-1)
|
|
|
|
|
row = (int)m_CharacterPositions.size()-1;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2008-07-13 14:22:03 -07:00
|
|
|
// TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to
|
2005-02-04 23:25:16 -08:00
|
|
|
// be able to get the specific element here. This is hopefully a temporary hack.
|
|
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
for (int i = 0; i < row; ++i)
|
2005-02-04 23:25:16 -08:00
|
|
|
++current;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// current is already set to begin,
|
|
|
|
|
// but we'll change the mouse.x to fit our horizontal scrolling
|
|
|
|
|
mouse -= m_CachedActualSize.TopLeft();
|
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
|
|
|
mouse.x -= m_BufferZone - m_HorizontalScroll;
|
2005-02-04 23:25:16 -08:00
|
|
|
// mouse.y is moot
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
retPosition = current->m_ListStart;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// Okay, now loop through the glyphs to find the appropriate X position
|
|
|
|
|
float dummy;
|
2011-06-23 03:12:43 -07:00
|
|
|
retPosition += GetXTextPosition(current, mouse.x, dummy);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
return retPosition;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Does not process horizontal scrolling, 'x' must be modified before inputted.
|
2015-08-21 10:08:41 -07:00
|
|
|
int CInput::GetXTextPosition(const std::list<SRow>::const_iterator& current, const float& x, float& wanted) const
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2015-08-21 10:08:41 -07:00
|
|
|
int ret = 0;
|
|
|
|
|
float previous = 0.f;
|
|
|
|
|
int i = 0;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2015-08-21 10:08:41 -07:00
|
|
|
for (std::vector<float>::const_iterator it = current->m_ListOfX.begin();
|
|
|
|
|
it != current->m_ListOfX.end();
|
|
|
|
|
++it, ++i)
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
|
|
|
|
if (*it >= x)
|
|
|
|
|
{
|
|
|
|
|
if (x - previous >= *it - x)
|
2011-06-23 03:12:43 -07:00
|
|
|
ret += i+1;
|
2005-02-04 23:25:16 -08:00
|
|
|
else
|
2011-06-23 03:12:43 -07:00
|
|
|
ret += i;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
previous = *it;
|
|
|
|
|
}
|
|
|
|
|
// If a position wasn't found, we will assume the last
|
|
|
|
|
// character of that line.
|
2005-08-09 08:55:44 -07:00
|
|
|
if (i == (int)current->m_ListOfX.size())
|
2005-02-04 23:25:16 -08:00
|
|
|
{
|
2011-06-23 03:12:43 -07:00
|
|
|
ret += i;
|
2005-02-04 23:25:16 -08:00
|
|
|
wanted = x;
|
|
|
|
|
}
|
2015-08-21 10:08:41 -07:00
|
|
|
else
|
|
|
|
|
wanted = 0.f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
return ret;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CInput::DeleteCurSelection()
|
|
|
|
|
{
|
2011-06-23 03:12:43 -07:00
|
|
|
int virtualFrom;
|
|
|
|
|
int virtualTo;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
if (m_iBufferPos_Tail >= m_iBufferPos)
|
|
|
|
|
{
|
2011-06-23 03:12:43 -07:00
|
|
|
virtualFrom = m_iBufferPos;
|
|
|
|
|
virtualTo = m_iBufferPos_Tail;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-23 03:12:43 -07:00
|
|
|
virtualFrom = m_iBufferPos_Tail;
|
|
|
|
|
virtualTo = m_iBufferPos;
|
2005-02-04 23:25:16 -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_Caption =
|
|
|
|
|
m_Caption.Left(virtualFrom) +
|
|
|
|
|
m_Caption.Right(static_cast<long>(m_Caption.length()) - virtualTo);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2011-06-23 03:12:43 -07:00
|
|
|
UpdateText(virtualFrom, virtualTo, virtualFrom);
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Remove selection
|
|
|
|
|
m_iBufferPos_Tail = -1;
|
2011-06-23 03:12:43 -07:00
|
|
|
m_iBufferPos = virtualFrom;
|
2015-02-02 15:44:06 -08:00
|
|
|
UpdateBufferPositionSetting();
|
2004-11-24 15:39:52 -08:00
|
|
|
}
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
bool CInput::SelectingText() const
|
|
|
|
|
{
|
|
|
|
|
return m_iBufferPos_Tail != -1 &&
|
|
|
|
|
m_iBufferPos_Tail != m_iBufferPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float CInput::GetTextAreaWidth()
|
|
|
|
|
{
|
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_ScrollBar && GetScrollBar(0).GetStyle())
|
|
|
|
|
return m_CachedActualSize.GetWidth() - m_BufferZone * 2.f - GetScrollBar(0).GetStyle()->m_Width;
|
2005-02-04 23:25:16 -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
|
|
|
return m_CachedActualSize.GetWidth() - m_BufferZone * 2.f;
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CInput::UpdateAutoScroll()
|
|
|
|
|
{
|
|
|
|
|
// Autoscrolling up and down
|
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_MultiLine)
|
2005-02-04 23:25:16 -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
|
|
|
if (!m_ScrollBar)
|
2005-02-04 23:25:16 -08:00
|
|
|
return;
|
|
|
|
|
|
2019-08-23 07:43:10 -07:00
|
|
|
const float scroll = GetScrollBar(0).GetPos();
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
// Now get the height of the font.
|
|
|
|
|
// TODO: Get the real font
|
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
|
|
|
CFontMetrics font(CStrIntern(m_Font.ToUTF8()));
|
2005-02-05 06:53:06 -08:00
|
|
|
float spacing = (float)font.GetLineSpacing();
|
|
|
|
|
//float height = font.GetHeight();
|
2005-02-04 23:25:16 -08:00
|
|
|
|
2008-07-13 14:22:03 -07:00
|
|
|
// TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to
|
2005-02-04 23:25:16 -08:00
|
|
|
// be able to get the specific element here. This is hopefully a temporary hack.
|
|
|
|
|
|
2008-07-13 14:22:03 -07:00
|
|
|
std::list<SRow>::iterator current = m_CharacterPositions.begin();
|
2015-08-21 10:08:41 -07:00
|
|
|
int row = 0;
|
2005-02-04 23:25:16 -08:00
|
|
|
while (current != m_CharacterPositions.end())
|
|
|
|
|
{
|
|
|
|
|
if (m_iBufferPos >= current->m_ListStart &&
|
2017-08-29 16:29:29 -07:00
|
|
|
m_iBufferPos <= current->m_ListStart + (int)current->m_ListOfX.size())
|
2005-02-04 23:25:16 -08:00
|
|
|
break;
|
2015-01-29 08:10:03 -08:00
|
|
|
|
2005-02-04 23:25:16 -08:00
|
|
|
++current;
|
|
|
|
|
++row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If scrolling down
|
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 (-scroll + static_cast<float>(row + 1) * spacing + m_BufferZone * 2.f > m_CachedActualSize.GetHeight())
|
2005-02-04 23:25:16 -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
|
|
|
// Scroll so the selected row is shown completely, also with m_BufferZone length to the edge.
|
|
|
|
|
GetScrollBar(0).SetPos(static_cast<float>(row + 1) * spacing - m_CachedActualSize.GetHeight() + m_BufferZone * 2.f);
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
// If scrolling up
|
2015-08-21 10:08:41 -07:00
|
|
|
else if (-scroll + (float)row * spacing < 0.f)
|
2005-02-04 23:25:16 -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
|
|
|
// Scroll so the selected row is shown completely, also with m_BufferZone length to the edge.
|
2005-02-04 23:25:16 -08:00
|
|
|
GetScrollBar(0).SetPos((float)row * spacing);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // autoscrolling left and right
|
|
|
|
|
{
|
|
|
|
|
// Get X position of position:
|
|
|
|
|
if (m_CharacterPositions.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
float x_position = 0.f;
|
|
|
|
|
float x_total = 0.f;
|
|
|
|
|
if (!m_CharacterPositions.begin()->m_ListOfX.empty())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Get position of m_iBufferPos
|
2005-02-05 06:53:06 -08:00
|
|
|
if ((int)m_CharacterPositions.begin()->m_ListOfX.size() >= m_iBufferPos &&
|
2017-05-14 12:02:03 -07:00
|
|
|
m_iBufferPos > 0)
|
2005-02-04 23:25:16 -08:00
|
|
|
x_position = m_CharacterPositions.begin()->m_ListOfX[m_iBufferPos-1];
|
|
|
|
|
|
|
|
|
|
// Get complete length:
|
2015-08-21 10:08:41 -07:00
|
|
|
x_total = m_CharacterPositions.begin()->m_ListOfX[m_CharacterPositions.begin()->m_ListOfX.size()-1];
|
2005-02-04 23:25:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if outside to the right
|
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 (x_position - m_HorizontalScroll + m_BufferZone * 2.f > m_CachedActualSize.GetWidth())
|
|
|
|
|
m_HorizontalScroll = x_position - m_CachedActualSize.GetWidth() + m_BufferZone * 2.f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Check if outside to the left
|
|
|
|
|
if (x_position - m_HorizontalScroll < 0.f)
|
|
|
|
|
m_HorizontalScroll = x_position;
|
|
|
|
|
|
|
|
|
|
// Check if the text doesn't even fill up to the right edge even though scrolling is done.
|
|
|
|
|
if (m_HorizontalScroll != 0.f &&
|
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
|
|
|
x_total - m_HorizontalScroll + m_BufferZone * 2.f < m_CachedActualSize.GetWidth())
|
|
|
|
|
m_HorizontalScroll = x_total - m_CachedActualSize.GetWidth() + m_BufferZone * 2.f;
|
2005-02-04 23:25:16 -08:00
|
|
|
|
|
|
|
|
// Now this is the fail-safe, if x_total isn't even the length of the control,
|
|
|
|
|
// remove all scrolling
|
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 (x_total + m_BufferZone * 2.f < m_CachedActualSize.GetWidth())
|
2005-02-04 23:25:16 -08:00
|
|
|
m_HorizontalScroll = 0.f;
|
|
|
|
|
}
|
2005-02-05 06:53:06 -08:00
|
|
|
}
|