mirror of https://github.com/buggins/dlangui.git
CaretRect in progress
This commit is contained in:
parent
72187063bd
commit
d39fadd1d0
|
@ -452,8 +452,22 @@ struct LineSpan {
|
|||
int len;
|
||||
/// the wrapping points
|
||||
WrapPoint[] wrapPoints;
|
||||
|
||||
/// the wrapped text
|
||||
dstring[] wrappedContent;
|
||||
|
||||
int widthAccumulation(int wrapLine)
|
||||
{
|
||||
int widthTotal;
|
||||
for (int i; i < wrapLine; i++)
|
||||
{
|
||||
if (i < this.wrapPoints.length - 1)
|
||||
{
|
||||
int curWidth = this.wrapPoints[i].wrapWidth;
|
||||
widthTotal += curWidth;
|
||||
}
|
||||
}
|
||||
return widthTotal;
|
||||
}
|
||||
}
|
||||
|
||||
struct WrapPoint {
|
||||
|
|
|
@ -1264,6 +1264,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
handleAction(ACTION_EDITOR_SELECT_ALL);
|
||||
super.handleFocusChange(focused);
|
||||
}
|
||||
|
||||
protected int _firstVisibleLine;
|
||||
|
||||
/// returns cursor rectangle
|
||||
protected Rect caretRect() {
|
||||
|
@ -1280,10 +1282,18 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
}
|
||||
}
|
||||
if (_wordWrap)
|
||||
{
|
||||
_scrollPos.x = 0;
|
||||
int wrapLine = findWrapLine(_caretPos);
|
||||
int xOffset;
|
||||
if (wrapLine > 0)
|
||||
{
|
||||
_scrollPos.x = 0;
|
||||
caretRc.offset(_clientRect.left, _clientRect.top);
|
||||
LineSpan curSpan = getSpan(_caretPos.line);
|
||||
xOffset = curSpan.widthAccumulation(wrapLine);
|
||||
}
|
||||
auto yOffset = -1 * _lineHeight * (wrapsUpTo(_caretPos.line - _firstVisibleLine) + wrapLine);
|
||||
caretRc.offset(_clientRect.left - xOffset, _clientRect.top - yOffset);
|
||||
}
|
||||
else
|
||||
caretRc.offset(_clientRect.left, _clientRect.top);
|
||||
return caretRc;
|
||||
|
@ -2470,7 +2480,7 @@ class EditBox : EditWidgetBase {
|
|||
}
|
||||
}
|
||||
|
||||
protected int _firstVisibleLine;
|
||||
//protected int _firstVisibleLine;
|
||||
|
||||
protected int _maxLineWidth;
|
||||
protected int _numVisibleLines; // number of lines visible in client area
|
||||
|
|
Loading…
Reference in New Issue