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;
|
int len;
|
||||||
/// the wrapping points
|
/// the wrapping points
|
||||||
WrapPoint[] wrapPoints;
|
WrapPoint[] wrapPoints;
|
||||||
|
/// the wrapped text
|
||||||
dstring[] wrappedContent;
|
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 {
|
struct WrapPoint {
|
||||||
|
|
|
@ -1264,6 +1264,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
handleAction(ACTION_EDITOR_SELECT_ALL);
|
handleAction(ACTION_EDITOR_SELECT_ALL);
|
||||||
super.handleFocusChange(focused);
|
super.handleFocusChange(focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int _firstVisibleLine;
|
||||||
|
|
||||||
/// returns cursor rectangle
|
/// returns cursor rectangle
|
||||||
protected Rect caretRect() {
|
protected Rect caretRect() {
|
||||||
|
@ -1280,10 +1282,18 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_wordWrap)
|
if (_wordWrap)
|
||||||
|
{
|
||||||
|
_scrollPos.x = 0;
|
||||||
|
int wrapLine = findWrapLine(_caretPos);
|
||||||
|
int xOffset;
|
||||||
|
if (wrapLine > 0)
|
||||||
{
|
{
|
||||||
_scrollPos.x = 0;
|
LineSpan curSpan = getSpan(_caretPos.line);
|
||||||
caretRc.offset(_clientRect.left, _clientRect.top);
|
xOffset = curSpan.widthAccumulation(wrapLine);
|
||||||
}
|
}
|
||||||
|
auto yOffset = -1 * _lineHeight * (wrapsUpTo(_caretPos.line - _firstVisibleLine) + wrapLine);
|
||||||
|
caretRc.offset(_clientRect.left - xOffset, _clientRect.top - yOffset);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
caretRc.offset(_clientRect.left, _clientRect.top);
|
caretRc.offset(_clientRect.left, _clientRect.top);
|
||||||
return caretRc;
|
return caretRc;
|
||||||
|
@ -2470,7 +2480,7 @@ class EditBox : EditWidgetBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _firstVisibleLine;
|
//protected int _firstVisibleLine;
|
||||||
|
|
||||||
protected int _maxLineWidth;
|
protected int _maxLineWidth;
|
||||||
protected int _numVisibleLines; // number of lines visible in client area
|
protected int _numVisibleLines; // number of lines visible in client area
|
||||||
|
|
Loading…
Reference in New Issue