mirror of https://github.com/buggins/dlangui.git
editline fixes|
This commit is contained in:
parent
408c29aa95
commit
426acf5518
|
@ -738,11 +738,13 @@ class EditLine : EditWidgetBase {
|
|||
res.left = _measuredTextSize.x;
|
||||
else
|
||||
res.left = _measuredTextWidths[p.pos - 1];
|
||||
res.left -= _scrollPos.x;
|
||||
res.right = res.left + 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
override protected TextPosition clientToTextPos(Point pt) {
|
||||
pt.x += _scrollPos.x;
|
||||
TextPosition res;
|
||||
for (int i = 0; i < _measuredText.length; i++) {
|
||||
int x0 = i > 0 ? _measuredTextWidths[i - 1] : 0;
|
||||
|
@ -762,13 +764,13 @@ class EditLine : EditWidgetBase {
|
|||
Rect rc = textPosToClient(_caretPos);
|
||||
if (rc.left < 0) {
|
||||
// scroll left
|
||||
_scrollPos.x -= -rc.left + _clientRc.width / 4;
|
||||
_scrollPos.x -= -rc.left + _clientRc.width / 10;
|
||||
if (_scrollPos.x < 0)
|
||||
_scrollPos.x = 0;
|
||||
invalidate();
|
||||
} else if (rc.left >= _clientRc.width - 10) {
|
||||
// scroll right
|
||||
_scrollPos.x += (rc.left - _clientRc.width) + _clientRc.width / 4;
|
||||
_scrollPos.x += (rc.left - _clientRc.width) + _spaceWidth * 4;
|
||||
invalidate();
|
||||
}
|
||||
updateScrollbars();
|
||||
|
@ -866,7 +868,7 @@ class EditLine : EditWidgetBase {
|
|||
dstring txt = text;
|
||||
Point sz = font.textSize(txt);
|
||||
//applyAlign(rc, sz);
|
||||
font.drawText(buf, rc.left, rc.top + sz.y / 10, txt, textColor);
|
||||
font.drawText(buf, rc.left - _scrollPos.x, rc.top + sz.y / 10, txt, textColor);
|
||||
if (focused) {
|
||||
// draw caret
|
||||
Rect caretRc = textPosToClient(_caretPos);
|
||||
|
|
|
@ -714,7 +714,9 @@ Theme createDefaultTheme() {
|
|||
//listItem.createState(State.Enabled, 0).textColor(0x80000000); // half transparent text for disabled item
|
||||
|
||||
Style editLine = res.createSubstyle("EDIT_LINE").backgroundImageId("editbox_background").padding(Rect(5,6,5,6)).margins(Rect(2,2,2,2)).minWidth(40);
|
||||
editLine.fontFace("Courier New").fontFamily(FontFamily.MonoSpace);
|
||||
Style editBox = res.createSubstyle("EDIT_BOX").backgroundImageId("editbox_background").padding(Rect(5,6,5,6)).margins(Rect(2,2,2,2)).minWidth(100).minHeight(60);
|
||||
editBox.fontFace("Courier New").fontFamily(FontFamily.MonoSpace);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue