mirror of https://github.com/buggins/dlangui.git
close #282
This commit is contained in:
parent
83045cc1d8
commit
f4741bf297
|
@ -433,6 +433,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
hlayout.addChild((new TextWidget()).text("in horizontal layout"));
|
hlayout.addChild((new TextWidget()).text("in horizontal layout"));
|
||||||
hlayout.addChild((new ImageWidget()).drawableId("exit").padding(Rect(5,5,5,5)).alignment(Align.Center));
|
hlayout.addChild((new ImageWidget()).drawableId("exit").padding(Rect(5,5,5,5)).alignment(Align.Center));
|
||||||
hlayout.addChild((new EditLine("editline", "Some text to edit"d)).popupMenu(editPopupItem).alignment(Align.Center).layoutWidth(FILL_PARENT));
|
hlayout.addChild((new EditLine("editline", "Some text to edit"d)).popupMenu(editPopupItem).alignment(Align.Center).layoutWidth(FILL_PARENT));
|
||||||
|
hlayout.addChild((new EditLine("passwd", "Password"d)).passwordChar('*').popupMenu(editPopupItem).alignment(Align.Center).layoutWidth(FILL_PARENT));
|
||||||
//hlayout.addChild((new Button()).text(">>")); //.textColor(0x40FF4000)
|
//hlayout.addChild((new Button()).text(">>")); //.textColor(0x40FF4000)
|
||||||
hlayout.backgroundColor = 0x8080C0;
|
hlayout.backgroundColor = 0x8080C0;
|
||||||
layout.addChild(hlayout);
|
layout.addChild(hlayout);
|
||||||
|
|
|
@ -1832,6 +1832,17 @@ class EditLine : EditWidgetBase {
|
||||||
protected int[] _measuredTextWidths;
|
protected int[] _measuredTextWidths;
|
||||||
protected Point _measuredTextSize;
|
protected Point _measuredTextSize;
|
||||||
|
|
||||||
|
protected dchar _passwordChar = 0;
|
||||||
|
/// password character - 0 for normal editor, some character, e.g. '*' to hide text by replacing all characters with this char
|
||||||
|
@property dchar passwordChar() { return _passwordChar; }
|
||||||
|
@property EditLine passwordChar(dchar ch) {
|
||||||
|
if (_passwordChar != ch) {
|
||||||
|
_passwordChar = ch;
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
override protected Rect textPosToClient(TextPosition p) {
|
override protected Rect textPosToClient(TextPosition p) {
|
||||||
Rect res;
|
Rect res;
|
||||||
res.bottom = _clientRect.height;
|
res.bottom = _clientRect.height;
|
||||||
|
@ -1879,10 +1890,19 @@ class EditLine : EditWidgetBase {
|
||||||
updateScrollBars();
|
updateScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected dstring applyPasswordChar(dstring s) {
|
||||||
|
if (!_passwordChar || s.length == 0)
|
||||||
|
return s;
|
||||||
|
dchar[] ss = s.dup;
|
||||||
|
foreach(ref ch; ss)
|
||||||
|
ch = _passwordChar;
|
||||||
|
return cast(dstring)ss;
|
||||||
|
}
|
||||||
|
|
||||||
override protected Point measureVisibleText() {
|
override protected Point measureVisibleText() {
|
||||||
FontRef font = font();
|
FontRef font = font();
|
||||||
//Point sz = font.textSize(text);
|
//Point sz = font.textSize(text);
|
||||||
_measuredText = text;
|
_measuredText = applyPasswordChar(text);
|
||||||
_measuredTextWidths.length = _measuredText.length;
|
_measuredTextWidths.length = _measuredText.length;
|
||||||
int charsMeasured = font.measureText(_measuredText, _measuredTextWidths, int.max, tabSize);
|
int charsMeasured = font.measureText(_measuredText, _measuredTextWidths, int.max, tabSize);
|
||||||
_measuredTextSize.x = charsMeasured > 0 ? _measuredTextWidths[charsMeasured - 1]: 0;
|
_measuredTextSize.x = charsMeasured > 0 ? _measuredTextWidths[charsMeasured - 1]: 0;
|
||||||
|
@ -1985,7 +2005,7 @@ class EditLine : EditWidgetBase {
|
||||||
applyPadding(rc);
|
applyPadding(rc);
|
||||||
auto saver = ClipRectSaver(buf, rc, alpha);
|
auto saver = ClipRectSaver(buf, rc, alpha);
|
||||||
FontRef font = font();
|
FontRef font = font();
|
||||||
dstring txt = text;
|
dstring txt = applyPasswordChar(text);
|
||||||
Point sz = font.textSize(txt);
|
Point sz = font.textSize(txt);
|
||||||
//applyAlign(rc, sz);
|
//applyAlign(rc, sz);
|
||||||
Rect lineRect = _clientRect;
|
Rect lineRect = _clientRect;
|
||||||
|
|
Loading…
Reference in New Issue