Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectTypes/CInput.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | CInput::CInput(CGUI& pGUI) | ||||
RegisterSetting("multiline", m_MultiLine); | RegisterSetting("multiline", m_MultiLine); | ||||
RegisterSetting("readonly", m_Readonly); | RegisterSetting("readonly", m_Readonly); | ||||
RegisterSetting("scrollbar", m_ScrollBar); | RegisterSetting("scrollbar", m_ScrollBar); | ||||
RegisterSetting("scrollbar_style", m_ScrollBarStyle); | RegisterSetting("scrollbar_style", m_ScrollBarStyle); | ||||
RegisterSetting("sprite", m_Sprite); | RegisterSetting("sprite", m_Sprite); | ||||
RegisterSetting("sprite_selectarea", m_SpriteSelectArea); | RegisterSetting("sprite_selectarea", m_SpriteSelectArea); | ||||
RegisterSetting("textcolor", m_TextColor); | RegisterSetting("textcolor", m_TextColor); | ||||
RegisterSetting("textcolor_selected", m_TextColorSelected); | RegisterSetting("textcolor_selected", m_TextColorSelected); | ||||
RegisterSetting("placeholder_text", m_PlaceholderText); | |||||
RegisterSetting("placeholder_color", m_PlaceholderColor); | |||||
CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate); | CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate); | ||||
CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(pGUI); | CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(pGUI); | ||||
bar->SetRightAligned(true); | bar->SetRightAligned(true); | ||||
AddScrollBar(bar); | AddScrollBar(bar); | ||||
} | } | ||||
CInput::~CInput() | CInput::~CInput() | ||||
{ | { | ||||
} | } | ||||
void CInput::UpdateBufferPositionSetting() | void CInput::UpdateBufferPositionSetting() | ||||
{ | { | ||||
SetSetting<i32>("buffer_position", m_iBufferPos, false); | SetSetting<i32>("buffer_position", m_iBufferPos, false); | ||||
} | } | ||||
void CInput::ClearComposedText() | void CInput::ClearComposedText() | ||||
{ | { | ||||
m_Caption.erase(m_iInsertPos, m_iComposedLength); | m_Caption.erase(m_iInsertPos, m_iComposedLength); | ||||
m_iBufferPos = m_iInsertPos; | m_iBufferPos = m_iInsertPos; | ||||
vladislavbelov: That's the strange line, why this comment and strange cast? | |||||
UpdateBufferPositionSetting(); | UpdateBufferPositionSetting(); | ||||
m_iComposedLength = 0; | m_iComposedLength = 0; | ||||
m_iComposedPos = 0; | m_iComposedPos = 0; | ||||
} | } | ||||
InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev) | InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev) | ||||
{ | { | ||||
ENSURE(m_iBufferPos != -1); | ENSURE(m_iBufferPos != -1); | ||||
▲ Show 20 Lines • Show All 781 Lines • ▼ Show 20 Lines | if (Message.value == "multiline") | ||||
else | else | ||||
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top); | GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top); | ||||
UpdateText(); | UpdateText(); | ||||
} | } | ||||
UpdateAutoScroll(); | UpdateAutoScroll(); | ||||
break; | break; | ||||
Done Inline Actions:( Silier: :( | |||||
} | } | ||||
case GUIM_MOUSE_PRESS_LEFT: | case GUIM_MOUSE_PRESS_LEFT: | ||||
{ | { | ||||
// Check if we're selecting the scrollbar | // Check if we're selecting the scrollbar | ||||
if (m_ScrollBar && | if (m_ScrollBar && | ||||
m_MultiLine && | m_MultiLine && | ||||
GetScrollBar(0).GetStyle()) | GetScrollBar(0).GetStyle()) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 551 Lines • ▼ Show 20 Lines | if (buffered_y + m_BufferZone >= -ls || !m_MultiLine) | ||||
if (using_selected_color) | if (using_selected_color) | ||||
textRenderer.Color(m_TextColorSelected); | textRenderer.Color(m_TextColorSelected); | ||||
} | } | ||||
textRenderer.SetTransform(savedTransform); | textRenderer.SetTransform(savedTransform); | ||||
} | } | ||||
if (!m_Caption.length() && m_PlaceholderText.length()) | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsI prefer if (m_Caption.empty() && !m_PlaceholderText.empty()). vladislavbelov: I prefer `if (m_Caption.empty() && !m_PlaceholderText.empty())`. | |||||
{ | |||||
textRenderer.Color(m_PlaceholderColor); | |||||
textRenderer.PutAdvance(&m_PlaceholderText[0]); | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsThat's not a correct usage, usually we pass m_PlaceholderText.c_str(), but after C++11 we might also pass m_PlaceholderText.data(). vladislavbelov: That's not a correct usage, usually we pass `m_PlaceholderText.c_str()`, but after C++11 we… | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsAlso you it on each frame, which means that the textRenderer recalculate glyphs/sizes for each frame. Which means a not needed work that costs time. vladislavbelov: Also you it on each frame, which means that the textRenderer recalculate glyphs/sizes for each… | |||||
} | |||||
textRenderer.Translate(0.f, ls, 0.f); | textRenderer.Translate(0.f, ls, 0.f); | ||||
} | } | ||||
textRenderer.Render(); | textRenderer.Render(); | ||||
if (cliparea != CRect()) | if (cliparea != CRect()) | ||||
glDisable(GL_SCISSOR_TEST); | glDisable(GL_SCISSOR_TEST); | ||||
▲ Show 20 Lines • Show All 570 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
That's the strange line, why this comment and strange cast?