Update release

This commit is contained in:
Zihan Chen
2018-07-09 05:09:09 -07:00
parent 032c06a5ea
commit 8d629f60ff
22 changed files with 4452 additions and 2883 deletions
+103 -54
View File
@@ -3692,8 +3692,7 @@ text::CharMeasurer
***********************************************************************/
CharMeasurer::CharMeasurer(vint _rowHeight)
:oldRenderTarget(0)
,rowHeight(_rowHeight)
:rowHeight(_rowHeight)
{
memset(widths, 0, sizeof(widths));
}
@@ -3712,14 +3711,26 @@ text::CharMeasurer
}
}
vint CharMeasurer::MeasureWidth(wchar_t character)
vint CharMeasurer::MeasureWidth(UnicodeCodePoint codePoint)
{
vint w=widths[character];
if(w==0)
vuint32_t index = codePoint.GetCodePoint();
if (0 <= index && index < 65536)
{
widths[character]=w=MeasureWidthInternal(character, oldRenderTarget);
vint w = widths[index];
if (w == 0)
{
widths[index] = w = MeasureWidthInternal(codePoint, oldRenderTarget);
}
return w;
}
else if (index < 0x110000)
{
return MeasureWidthInternal(codePoint, oldRenderTarget);
}
else
{
return 0;
}
return w;
}
vint CharMeasurer::GetRowHeight()
@@ -4014,7 +4025,7 @@ text::TextLines
lines[i].availableOffsetCount = 0;
}
tabWidth = tabSpaceCount * (charMeasurer ? charMeasurer->MeasureWidth(L' ') : 1);
tabWidth = tabSpaceCount * (charMeasurer ? charMeasurer->MeasureWidth({ L' ' }) : 1);
if (tabWidth == 0)
{
tabWidth = 1;
@@ -4043,33 +4054,46 @@ text::TextLines
void TextLines::MeasureRow(vint row)
{
TextLine& line=lines[row];
vint offset=0;
if(line.availableOffsetCount)
TextLine& line = lines[row];
vint offset = 0;
if (line.availableOffsetCount)
{
offset=line.att[line.availableOffsetCount-1].rightOffset;
offset = line.att[line.availableOffsetCount - 1].rightOffset;
}
for(vint i=line.availableOffsetCount;i<line.dataLength;i++)
for (vint i = line.availableOffsetCount; i < line.dataLength; i++)
{
CharAtt& att=line.att[i];
wchar_t c=line.text[i];
vint width=0;
if(passwordChar)
CharAtt& att = line.att[i];
wchar_t c = line.text[i];
vint width = 0;
vint passwordWidth = 0;
if (passwordChar)
{
width = charMeasurer ? charMeasurer->MeasureWidth(passwordChar) : 1;
passwordWidth = charMeasurer ? charMeasurer->MeasureWidth({ passwordChar }) : 1;
}
else if(c==L'\t')
if (c == L'\t')
{
width=tabWidth-offset%tabWidth;
width = tabWidth - offset % tabWidth;
}
#if defined VCZH_MSVC
else if (UTF16SPFirst(c) && (i + 1 < line.dataLength) && UTF16SPSecond(line.text[i + 1]))
{
width = passwordChar ? passwordWidth : (charMeasurer ? charMeasurer->MeasureWidth({ c, line.text[i + 1] }) : 1);
offset += width;
att.rightOffset = (int)offset;
line.att[i + 1].rightOffset = (int)offset;
i++;
continue;
}
#endif
else
{
width = charMeasurer ? charMeasurer->MeasureWidth(line.text[i]) : 1;
width = passwordChar ? passwordWidth : (charMeasurer ? charMeasurer->MeasureWidth({ c }) : 1);
}
offset+=width;
att.rightOffset=(int)offset;
offset += width;
att.rightOffset = (int)offset;
}
line.availableOffsetCount=line.dataLength;
line.availableOffsetCount = line.dataLength;
}
vint TextLines::GetRowWidth(vint row)
@@ -4151,6 +4175,12 @@ text::TextLines
p1=p;
}
}
#if defined VCZH_MSVC
if (UTF16SPSecond(line.text[i1]) && i1 > 0 && UTF16SPFirst(line.text[i1 - 1]))
{
i1--;
}
#endif
return TextPos(row, i1);
}
@@ -4397,6 +4427,7 @@ GuiColorizedTextElement
}
}
/***********************************************************************
.\NATIVEWINDOW\GUINATIVEWINDOW.CPP
***********************************************************************/
@@ -24263,65 +24294,83 @@ GuiTextBoxCommonInterface
void GuiTextBoxCommonInterface::Move(TextPos pos, bool shift)
{
TextPos oldBegin=textElement->GetCaretBegin();
TextPos oldEnd=textElement->GetCaretEnd();
TextPos oldBegin = textElement->GetCaretBegin();
TextPos oldEnd = textElement->GetCaretEnd();
pos=textElement->GetLines().Normalize(pos);
if(!shift)
#if defined VCZH_MSVC
if (0 <= pos.row && pos.row < textElement->GetLines().GetCount())
{
TextLine& line = textElement->GetLines().GetLine(pos.row);
if (pos.column > 0 && UTF16SPFirst(line.text[pos.column - 1]) && UTF16SPSecond(line.text[pos.column]))
{
if (pos < oldBegin)
{
pos.column--;
}
else if (pos > oldBegin)
{
pos.column++;
}
}
}
#endif
pos = textElement->GetLines().Normalize(pos);
if (!shift)
{
textElement->SetCaretBegin(pos);
}
textElement->SetCaretEnd(pos);
if(textControl)
if (textControl)
{
GuiGraphicsHost* host=textComposition->GetRelatedGraphicsHost();
if(host)
GuiGraphicsHost* host = textComposition->GetRelatedGraphicsHost();
if (host)
{
if(host->GetFocusedComposition()==textControl->GetFocusableComposition())
if (host->GetFocusedComposition() == textControl->GetFocusableComposition())
{
textElement->SetCaretVisible(true);
}
}
}
Rect bounds=textElement->GetLines().GetRectFromTextPos(pos);
Rect view=Rect(textElement->GetViewPosition(), textComposition->GetBounds().GetSize());
Point viewPoint=view.LeftTop();
Rect bounds = textElement->GetLines().GetRectFromTextPos(pos);
Rect view = Rect(textElement->GetViewPosition(), textComposition->GetBounds().GetSize());
Point viewPoint = view.LeftTop();
if(view.x2>view.x1 && view.y2>view.y1)
if (view.x2 > view.x1 && view.y2 > view.y1)
{
if(bounds.x1<view.x1)
if (bounds.x1 < view.x1)
{
viewPoint.x=bounds.x1;
viewPoint.x = bounds.x1;
}
else if(bounds.x2>view.x2)
else if (bounds.x2 > view.x2)
{
viewPoint.x=bounds.x2-view.Width();
viewPoint.x = bounds.x2 - view.Width();
}
if(bounds.y1<view.y1)
if (bounds.y1 < view.y1)
{
viewPoint.y=bounds.y1;
viewPoint.y = bounds.y1;
}
else if(bounds.y2>view.y2)
else if (bounds.y2 > view.y2)
{
viewPoint.y=bounds.y2-view.Height();
viewPoint.y = bounds.y2 - view.Height();
}
}
callback->ScrollToView(viewPoint);
UpdateCaretPoint();
TextPos newBegin=textElement->GetCaretBegin();
TextPos newEnd=textElement->GetCaretEnd();
if(oldBegin!=newBegin || oldEnd!=newEnd)
TextPos newBegin = textElement->GetCaretBegin();
TextPos newEnd = textElement->GetCaretEnd();
if (oldBegin != newBegin || oldEnd != newEnd)
{
ICommonTextEditCallback::TextCaretChangedStruct arguments;
arguments.oldBegin=oldBegin;
arguments.oldEnd=oldEnd;
arguments.newBegin=newBegin;
arguments.newEnd=newEnd;
arguments.editVersion=editVersion;
for(vint i=0;i<textEditCallbacks.Count();i++)
arguments.oldBegin = oldBegin;
arguments.oldEnd = oldEnd;
arguments.newBegin = newBegin;
arguments.newEnd = newEnd;
arguments.editVersion = editVersion;
for (vint i = 0; i < textEditCallbacks.Count(); i++)
{
textEditCallbacks[i]->TextCaretChanged(arguments);
}
@@ -35337,7 +35386,7 @@ IGuiInstanceResourceManager
return instanceResources.Values()[index];
}
void UnloadResource(const WString& name)
void UnloadResource(const WString& name)override
{
vint index = resources.Keys().IndexOf(name);
if (index != -1)