mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 06:55:53 +00:00
Update zeus
This commit is contained in:
parent
54a7108b04
commit
238f98f648
@ -40,7 +40,7 @@ void TextField::_setText()
|
|||||||
m_hasMarkSet = true;
|
m_hasMarkSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_setMarkedText()
|
void TextField::_setMarkedText()
|
||||||
{
|
{
|
||||||
if (m_hasMarkSet)
|
if (m_hasMarkSet)
|
||||||
@ -49,7 +49,7 @@ void TextField::_setMarkedText()
|
|||||||
m_markReplCount = m_deferredMarkReplCount;
|
m_markReplCount = m_deferredMarkReplCount;
|
||||||
m_markSelStart = m_deferredMarkSelStart;
|
m_markSelStart = m_deferredMarkSelStart;
|
||||||
m_markSelCount = m_deferredMarkSelCount;
|
m_markSelCount = m_deferredMarkSelCount;
|
||||||
|
|
||||||
size_t repPoint;
|
size_t repPoint;
|
||||||
size_t repEnd;
|
size_t repEnd;
|
||||||
if (m_selectionCount)
|
if (m_selectionCount)
|
||||||
@ -62,13 +62,13 @@ void TextField::_setMarkedText()
|
|||||||
repPoint = m_cursorPos;
|
repPoint = m_cursorPos;
|
||||||
repEnd = m_cursorPos;
|
repEnd = m_cursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_markReplStart != SIZE_MAX)
|
if (m_markReplStart != SIZE_MAX)
|
||||||
{
|
{
|
||||||
repPoint += m_markReplStart;
|
repPoint += m_markReplStart;
|
||||||
repEnd += m_markReplStart + m_markReplCount;
|
repEnd += m_markReplStart + m_markReplCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = UTF8Iterator(m_textStr.cbegin()).countTo(m_textStr.cend());
|
size_t len = UTF8Iterator(m_textStr.cbegin()).countTo(m_textStr.cend());
|
||||||
repPoint = std::min(repPoint, len);
|
repPoint = std::min(repPoint, len);
|
||||||
repEnd = std::min(repEnd, len);
|
repEnd = std::min(repEnd, len);
|
||||||
@ -77,7 +77,7 @@ void TextField::_setMarkedText()
|
|||||||
compStr += std::string((UTF8Iterator(m_textStr.cbegin()) + repEnd).iter(), m_textStr.cend());
|
compStr += std::string((UTF8Iterator(m_textStr.cbegin()) + repEnd).iter(), m_textStr.cend());
|
||||||
m_text->typesetGlyphs(compStr, m_error ? rootView().themeData().uiText() :
|
m_text->typesetGlyphs(compStr, m_error ? rootView().themeData().uiText() :
|
||||||
rootView().themeData().fieldText());
|
rootView().themeData().fieldText());
|
||||||
|
|
||||||
size_t pos = m_cursorPos;
|
size_t pos = m_cursorPos;
|
||||||
if (m_deferredMarkStr.size())
|
if (m_deferredMarkStr.size())
|
||||||
pos += m_markSelStart;
|
pos += m_markSelStart;
|
||||||
@ -85,18 +85,18 @@ void TextField::_setMarkedText()
|
|||||||
_reallySetMarkRange(pos, m_markSelCount);
|
_reallySetMarkRange(pos, m_markSelCount);
|
||||||
else
|
else
|
||||||
_reallySetCursorPos(pos);
|
_reallySetCursorPos(pos);
|
||||||
|
|
||||||
std::vector<TextView::RenderGlyph>& glyphs = m_text->accessGlyphs();
|
std::vector<TextView::RenderGlyph>& glyphs = m_text->accessGlyphs();
|
||||||
size_t defLen = UTF8Iterator(m_deferredMarkStr.cbegin()).countTo(m_deferredMarkStr.cend());
|
size_t defLen = UTF8Iterator(m_deferredMarkStr.cbegin()).countTo(m_deferredMarkStr.cend());
|
||||||
for (auto it=glyphs.begin()+repPoint ; it<glyphs.begin()+repPoint+defLen ; ++it)
|
for (auto it=glyphs.begin()+repPoint ; it<glyphs.begin()+repPoint+defLen ; ++it)
|
||||||
it->m_color = rootView().themeData().fieldMarkedText();
|
it->m_color = rootView().themeData().fieldMarkedText();
|
||||||
m_text->updateGlyphs();
|
m_text->updateGlyphs();
|
||||||
|
|
||||||
m_hasMarkSet = false;
|
m_hasMarkSet = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::setText(const std::string& str)
|
void TextField::setText(const std::string& str)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
@ -225,7 +225,7 @@ void TextField::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton butt
|
|||||||
{
|
{
|
||||||
size_t startPos = m_text->reverseSelectGlyph(coord.pixel[0] - m_text->subRect().location[0]);
|
size_t startPos = m_text->reverseSelectGlyph(coord.pixel[0] - m_text->subRect().location[0]);
|
||||||
setCursorPos(startPos);
|
setCursorPos(startPos);
|
||||||
m_dragging |= size_t(1 << int(button));
|
m_dragging |= size_t(1) << size_t(button);
|
||||||
m_dragStart = startPos;
|
m_dragStart = startPos;
|
||||||
rootView().setActiveDragView(this);
|
rootView().setActiveDragView(this);
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ void TextField::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton butt
|
|||||||
|
|
||||||
void TextField::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void TextField::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
m_dragging &= ~(1 << int(button));
|
m_dragging &= ~(size_t(1) << size_t(button));
|
||||||
if (m_dragging == 0)
|
if (m_dragging == 0)
|
||||||
rootView().setActiveDragView(nullptr);
|
rootView().setActiveDragView(nullptr);
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ void TextField::mouseLeave(const boo::SWindowCoord& coord)
|
|||||||
void TextField::clipboardCopy()
|
void TextField::clipboardCopy()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
|
|
||||||
if (!m_selectionCount)
|
if (!m_selectionCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -281,29 +281,29 @@ void TextField::clipboardCopy()
|
|||||||
rootView().window()->clipboardCopy(boo::EClipboardType::UTF8String,
|
rootView().window()->clipboardCopy(boo::EClipboardType::UTF8String,
|
||||||
(uint8_t*)&*begin.iter(), end.iter() - begin.iter());
|
(uint8_t*)&*begin.iter(), end.iter() - begin.iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::clipboardCut()
|
void TextField::clipboardCut()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
|
|
||||||
if (!m_selectionCount)
|
if (!m_selectionCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UTF8Iterator begin(m_textStr.cbegin());
|
UTF8Iterator begin(m_textStr.cbegin());
|
||||||
begin += m_selectionStart;
|
begin += m_selectionStart;
|
||||||
UTF8Iterator end(begin.iter());
|
UTF8Iterator end(begin.iter());
|
||||||
end += m_selectionCount;
|
end += m_selectionCount;
|
||||||
|
|
||||||
rootView().window()->clipboardCopy(boo::EClipboardType::UTF8String,
|
rootView().window()->clipboardCopy(boo::EClipboardType::UTF8String,
|
||||||
(uint8_t*)&*begin.iter(), end.iter() - begin.iter());
|
(uint8_t*)&*begin.iter(), end.iter() - begin.iter());
|
||||||
|
|
||||||
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_selectionStart).iter());
|
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_selectionStart).iter());
|
||||||
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_selectionStart + m_selectionCount).iter(), m_textStr.cend());
|
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_selectionStart + m_selectionCount).iter(), m_textStr.cend());
|
||||||
size_t selStart = m_selectionStart;
|
size_t selStart = m_selectionStart;
|
||||||
setText(newStr);
|
setText(newStr);
|
||||||
setCursorPos(selStart);
|
setCursorPos(selStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string SanitizeUTF8TextLine(const char* string, size_t len)
|
static std::string SanitizeUTF8TextLine(const char* string, size_t len)
|
||||||
{
|
{
|
||||||
const char* it = string;
|
const char* it = string;
|
||||||
@ -326,7 +326,7 @@ static std::string SanitizeUTF8TextLine(const char* string, size_t len)
|
|||||||
void TextField::clipboardPaste()
|
void TextField::clipboardPaste()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
|
|
||||||
size_t retSz;
|
size_t retSz;
|
||||||
std::unique_ptr<uint8_t[]> retData =
|
std::unique_ptr<uint8_t[]> retData =
|
||||||
rootView().window()->clipboardPaste(boo::EClipboardType::UTF8String, retSz);
|
rootView().window()->clipboardPaste(boo::EClipboardType::UTF8String, retSz);
|
||||||
@ -360,7 +360,7 @@ void TextField::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, boo
|
|||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
if (m_deferredMarkStr.size())
|
if (m_deferredMarkStr.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (key == boo::ESpecialKey::Left)
|
if (key == boo::ESpecialKey::Left)
|
||||||
{
|
{
|
||||||
if ((mods & boo::EModifierKey::Shift) != boo::EModifierKey::None)
|
if ((mods & boo::EModifierKey::Shift) != boo::EModifierKey::None)
|
||||||
@ -452,7 +452,7 @@ void TextField::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextField::hasMarkedText() const
|
bool TextField::hasMarkedText() const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
@ -514,7 +514,7 @@ std::string TextField::substringForRange(const std::pair<int,int>& range,
|
|||||||
void TextField::insertText(const std::string& str, const std::pair<int,int>& range)
|
void TextField::insertText(const std::string& str, const std::pair<int,int>& range)
|
||||||
{
|
{
|
||||||
std::string saniStr = SanitizeUTF8TextLine(str.data(), str.size());
|
std::string saniStr = SanitizeUTF8TextLine(str.data(), str.size());
|
||||||
|
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
size_t curLen = UTF8Iterator(m_deferredTextStr.cbegin()).countTo(m_deferredTextStr.cend());
|
size_t curLen = UTF8Iterator(m_deferredTextStr.cbegin()).countTo(m_deferredTextStr.cend());
|
||||||
if (range.first < 0 || range.first >= curLen)
|
if (range.first < 0 || range.first >= curLen)
|
||||||
@ -532,7 +532,7 @@ void TextField::insertText(const std::string& str, const std::pair<int,int>& ran
|
|||||||
unmarkText();
|
unmarkText();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string newStr(m_deferredTextStr.cbegin(), (UTF8Iterator(m_deferredTextStr.cbegin()) + range.first).iter());
|
std::string newStr(m_deferredTextStr.cbegin(), (UTF8Iterator(m_deferredTextStr.cbegin()) + range.first).iter());
|
||||||
newStr += saniStr;
|
newStr += saniStr;
|
||||||
size_t newSel = UTF8Iterator(newStr.cbegin()).countTo(newStr.cend());
|
size_t newSel = UTF8Iterator(newStr.cbegin()).countTo(newStr.cend());
|
||||||
@ -609,7 +609,7 @@ void TextField::think()
|
|||||||
|
|
||||||
m_errText->setMultiplyColor(errMult);
|
m_errText->setMultiplyColor(errMult);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
_setText();
|
_setText();
|
||||||
_setSelectionRange();
|
_setSelectionRange();
|
||||||
@ -633,7 +633,7 @@ void TextField::setActive(bool active)
|
|||||||
setSelectionRange(0, len);
|
setSelectionRange(0, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_reallySetCursorPos(size_t pos)
|
void TextField::_reallySetCursorPos(size_t pos)
|
||||||
{
|
{
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
@ -649,11 +649,11 @@ void TextField::_reallySetCursorPos(size_t pos)
|
|||||||
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
||||||
m_verts[31].m_color = selColor;
|
m_verts[31].m_color = selColor;
|
||||||
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
||||||
|
|
||||||
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
||||||
rootView().window()->claimKeyboardFocus(focusRect);
|
rootView().window()->claimKeyboardFocus(focusRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_setCursorPos()
|
void TextField::_setCursorPos()
|
||||||
{
|
{
|
||||||
if (m_hasCursorSet)
|
if (m_hasCursorSet)
|
||||||
@ -702,7 +702,7 @@ void TextField::clearErrorState()
|
|||||||
m_errText.reset();
|
m_errText.reset();
|
||||||
m_errorFrames = 360;
|
m_errorFrames = 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_reallySetSelectionRange(size_t start, size_t len)
|
void TextField::_reallySetSelectionRange(size_t start, size_t len)
|
||||||
{
|
{
|
||||||
ViewResources& res = rootView().viewRes();
|
ViewResources& res = rootView().viewRes();
|
||||||
@ -724,17 +724,17 @@ void TextField::_reallySetSelectionRange(size_t start, size_t len)
|
|||||||
glyphs[i].m_color = deselColor;
|
glyphs[i].m_color = deselColor;
|
||||||
}
|
}
|
||||||
m_text->updateGlyphs();
|
m_text->updateGlyphs();
|
||||||
|
|
||||||
m_verts[28].m_pos.assign(offset1, 18 * pf, 0);
|
m_verts[28].m_pos.assign(offset1, 18 * pf, 0);
|
||||||
m_verts[29].m_pos.assign(offset1, 4 * pf, 0);
|
m_verts[29].m_pos.assign(offset1, 4 * pf, 0);
|
||||||
m_verts[30].m_pos.assign(offset2, 18 * pf, 0);
|
m_verts[30].m_pos.assign(offset2, 18 * pf, 0);
|
||||||
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
||||||
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
||||||
|
|
||||||
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
||||||
rootView().window()->claimKeyboardFocus(focusRect);
|
rootView().window()->claimKeyboardFocus(focusRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_reallySetMarkRange(size_t start, size_t len)
|
void TextField::_reallySetMarkRange(size_t start, size_t len)
|
||||||
{
|
{
|
||||||
ViewResources& res = rootView().viewRes();
|
ViewResources& res = rootView().viewRes();
|
||||||
@ -744,7 +744,7 @@ void TextField::_reallySetMarkRange(size_t start, size_t len)
|
|||||||
std::vector<TextView::RenderGlyph>& glyphs = m_text->accessGlyphs();
|
std::vector<TextView::RenderGlyph>& glyphs = m_text->accessGlyphs();
|
||||||
offset1 += glyphs[start].m_pos[0][0];
|
offset1 += glyphs[start].m_pos[0][0];
|
||||||
offset2 += glyphs[start+len-1].m_pos[2][0];
|
offset2 += glyphs[start+len-1].m_pos[2][0];
|
||||||
|
|
||||||
const zeus::CColor& selColor = rootView().themeData().textfieldMarkSelection();
|
const zeus::CColor& selColor = rootView().themeData().textfieldMarkSelection();
|
||||||
m_verts[28].m_pos.assign(offset1, 18 * pf, 0);
|
m_verts[28].m_pos.assign(offset1, 18 * pf, 0);
|
||||||
m_verts[28].m_color = selColor;
|
m_verts[28].m_color = selColor;
|
||||||
@ -755,7 +755,7 @@ void TextField::_reallySetMarkRange(size_t start, size_t len)
|
|||||||
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
m_verts[31].m_pos.assign(offset2, 4 * pf, 0);
|
||||||
m_verts[31].m_color = selColor;
|
m_verts[31].m_color = selColor;
|
||||||
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
m_vertsBinding.load(m_verts, sizeof(m_verts));
|
||||||
|
|
||||||
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
int focusRect[2] = {subRect().location[0] + offset1, subRect().location[1]};
|
||||||
rootView().window()->claimKeyboardFocus(focusRect);
|
rootView().window()->claimKeyboardFocus(focusRect);
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ void TextField::_setSelectionRange()
|
|||||||
m_hasSelectionSet = false;
|
m_hasSelectionSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::setSelectionRange(size_t start, size_t count)
|
void TextField::setSelectionRange(size_t start, size_t count)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
@ -796,7 +796,7 @@ void TextField::_clearSelectionRange()
|
|||||||
{
|
{
|
||||||
m_selectionStart = 0;
|
m_selectionStart = 0;
|
||||||
m_selectionCount = 0;
|
m_selectionCount = 0;
|
||||||
|
|
||||||
const zeus::CColor& deselColor = m_error ? rootView().themeData().uiText() :
|
const zeus::CColor& deselColor = m_error ? rootView().themeData().uiText() :
|
||||||
rootView().themeData().fieldText();
|
rootView().themeData().fieldText();
|
||||||
|
|
||||||
@ -804,11 +804,11 @@ void TextField::_clearSelectionRange()
|
|||||||
for (size_t i=0 ; i<glyphs.size() ; ++i)
|
for (size_t i=0 ; i<glyphs.size() ; ++i)
|
||||||
glyphs[i].m_color = deselColor;
|
glyphs[i].m_color = deselColor;
|
||||||
m_text->updateGlyphs();
|
m_text->updateGlyphs();
|
||||||
|
|
||||||
m_hasSelectionClear = false;
|
m_hasSelectionClear = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::clearSelectionRange()
|
void TextField::clearSelectionRange()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f4dd896004d2a09b7671ab12d288cf888a2d901c
|
Subproject commit 0e491fc8f56f5ff0b06ddd4ec51ac73f8507a0c7
|
Loading…
x
Reference in New Issue
Block a user