random fixes

This commit is contained in:
Adam D. Ruppe 2021-10-05 18:08:22 -04:00
parent 398f1a061e
commit be2a7a0b1b
3 changed files with 52 additions and 9 deletions

View File

@ -150,6 +150,8 @@
"importPaths": ["."], "importPaths": ["."],
"targetType": "library", "targetType": "library",
"dflags": ["-mv=arsd.simpleaudio=simpleaudio.d"], "dflags": ["-mv=arsd.simpleaudio=simpleaudio.d"],
"libs-windows": ["winmm"],
"libs-linux": ["asound"],
"sourceFiles": ["simpleaudio.d"] "sourceFiles": ["simpleaudio.d"]
}, },
{ {

View File

@ -3236,7 +3236,10 @@ private bool bicmp(in ubyte[] item, in char[] search) {
WebSocket client, based on the browser api, though also with other api options. WebSocket client, based on the browser api, though also with other api options.
--- ---
auto ws = new WebSocket(URI("ws://....")); import arsd.http2;
void main() {
auto ws = new WebSocket(Uri("ws://...."));
ws.onmessage = (in char[] msg) { ws.onmessage = (in char[] msg) {
ws.send("a reply"); ws.send("a reply");
@ -3245,6 +3248,7 @@ private bool bicmp(in ubyte[] item, in char[] search) {
ws.connect(); ws.connect();
WebSocket.eventLoop(); WebSocket.eventLoop();
}
--- ---
Symbol_groups: Symbol_groups:

View File

@ -1926,6 +1926,9 @@ abstract class ComboboxBase : Widget {
} }
version(custom_widgets) { version(custom_widgets) {
// FIXME: this should scroll if there's too many elements to reasonably fit on screen
SimpleWindow dropDown; SimpleWindow dropDown;
void popup() { void popup() {
auto w = width; auto w = width;
@ -3325,6 +3328,9 @@ class DataControllerWidget(T) : WidgetContainer {
w.addEventListener("change", (Event e) { genericSetValue(&__traits(getMember, this.datum, member), e.stringValue); } ); w.addEventListener("change", (Event e) { genericSetValue(&__traits(getMember, this.datum, member), e.stringValue); } );
} else static if(is(typeof(w.value) == int)) { } else static if(is(typeof(w.value) == int)) {
w.addEventListener("change", (Event e) { genericSetValue(&__traits(getMember, this.datum, member), e.intValue); } ); w.addEventListener("change", (Event e) { genericSetValue(&__traits(getMember, this.datum, member), e.intValue); } );
} else static if(is(typeof(w) == DropDownSelection)) {
// special case for this to kinda support enums and such. coudl be better though
w.addEventListener("change", (Event e) { genericSetValue(&__traits(getMember, this.datum, member), e.intValue); } );
} else { } else {
static assert(0, "unsupported type " ~ typeof(__traits(getMember, this.datum, member)).stringof ~ " " ~ typeof(w).stringof); static assert(0, "unsupported type " ~ typeof(__traits(getMember, this.datum, member)).stringof ~ " " ~ typeof(w).stringof);
} }
@ -4853,6 +4859,16 @@ abstract class Slider : Widget {
protected abstract int win32direction(); protected abstract int win32direction();
/++
Alias for [position] for better compatibility with generic code.
History:
Added October 5, 2021
+/
@property int value() {
return position;
}
/// ///
int position() { int position() {
return position_; return position_;
@ -7547,7 +7563,7 @@ class TableView : Widget {
} }
version(custom_widgets) version(custom_widgets)
class TableViewWidgetInner : Widget { private class TableViewWidgetInner : Widget {
// wrap this thing in a ScrollMessageWidget // wrap this thing in a ScrollMessageWidget
@ -7700,7 +7716,7 @@ class TabMessageWidget : Widget {
A line edit box with an associated label. A line edit box with an associated label.
History: History:
On May 17, the default internal layout was changed from horizontal to vertical. On May 17, 2021, the default internal layout was changed from horizontal to vertical.
``` ```
Old: ________ Old: ________
@ -7710,12 +7726,15 @@ class TabMessageWidget : Widget {
``` ```
To restore the old behavior, use `new LabeledLineEdit("label", TextAlignment.Right, parent);` To restore the old behavior, use `new LabeledLineEdit("label", TextAlignment.Right, parent);`
You can also use `new LabeledLineEdit("label", TextAlignment.Left, parent);` if you want a
horizontal label but left aligned. You may also consider a [GridLayout].
+/ +/
alias LabeledLineEdit = Labeled!LineEdit; alias LabeledLineEdit = Labeled!LineEdit;
/++ /++
History: History:
Added May 19, 2020 Added May 19, 2021
+/ +/
class Labeled(T) : Widget { class Labeled(T) : Widget {
/// ///
@ -7739,6 +7758,8 @@ class Labeled(T) : Widget {
auto hl = new L(this); auto hl = new L(this);
this.label = new TextLabel(label, alignment, hl); this.label = new TextLabel(label, alignment, hl);
this.lineEdit = new T(hl); this.lineEdit = new T(hl);
this.label.labelFor = this.lineEdit;
} }
private bool horizontal; private bool horizontal;
@ -9787,6 +9808,17 @@ class TextLabel : Widget {
string label_; string label_;
/++
Indicates which other control this label is here for. Similar to HTML `for` attribute.
In practice this means a click on the label will focus the `labelFor`. In future versions
it will also set screen reader hints but that is not yet implemented.
History:
Added October 3, 2021 (dub v10.4)
+/
Widget labelFor;
/// ///
@scriptable @scriptable
string label() { return label_; } string label() { return label_; }
@ -9813,6 +9845,11 @@ class TextLabel : Widget {
createWin32Window(this, "static"w, label, (alignment & TextAlignment.Center) ? SS_CENTER : 0, (alignment & TextAlignment.Right) ? WS_EX_RIGHT : WS_EX_LEFT); createWin32Window(this, "static"w, label, (alignment & TextAlignment.Center) ? SS_CENTER : 0, (alignment & TextAlignment.Right) ? WS_EX_RIGHT : WS_EX_LEFT);
} }
override void defaultEventHandler_click(scope ClickEvent ce) {
if(this.labelFor !is null)
this.labelFor.focus();
}
/++ /++
WARNING: this currently sets TextAlignment.Right as the default. That will change in a future version. WARNING: this currently sets TextAlignment.Right as the default. That will change in a future version.
For future-proofing of your code, if you rely on TextAlignment.Right, you MUST specify that explicitly. For future-proofing of your code, if you rely on TextAlignment.Right, you MUST specify that explicitly.