Is UI interesting for us?
Adam D Ruppe
destructionator at gmail.com
Sat Mar 25 11:56:25 UTC 2023
On Saturday, 25 March 2023 at 10:03:29 UTC, Ikey Doherty wrote:
> Is there general interest in UI within the D community?
As in most fields, I've done my own thing in my minigui.d. My
general strategy has been on Windows, it uses the native controls
where possible so things just work there, then the Linux version
is 100% custom (and almost all self-contained, since I don't
wanna bring in annoying outside libs).
This has some interesting effects: some surface level things are
easier to do on linux but the deeper things are... more possible
but less realistic.
Accessibility is one example, on Windows it mostly just works. I
tested it with nvda and such, the basic classes - being built on
native controls - work fine. Custom widgets of course nothing
yet. On Linux, it just plain doesn't work at all. I expect it'd
be possible to tie into gtk's api or something but i just have
zero familiarity with it. I've glanced down the docs, I think I
can do it, but that's as far as I've gotten.
But doing things myself on linux has also been interesting. I'm
told that doing per-monitor fractional scaling is completely
impossible. Gtk does not seem to support it. I do. It wasn't even
that hard, so I don't get what the fuss is about...
On the other hand, it took me *ages* to get mixed font text
layout right (and I still haven't done all the bidi stuff yet
though I'm pretty confident my newer api will work fine for
it).... and surprisingly, I found getting scroll bars right was a
huge pain. Maybe that's just me, but between font bugs and scroll
bugs, my text edit control, well, sure it worked, but it was a
bit of an embarrassment for *years* on linux. Whereas on Windows,
of course, it Just Worked from day one thanks to the OS providing
it.
Then there's the case of the API and this is one place where we
can innovate a little in D, though I've mostly been keeping it
actually more-or-less a clone of the web dom api in javascript
<http://dpldocs.info/experimental-docs/arsd.minigui.Event.html#details>. But a few fun things like reflecting over a struct to generate accessors that trigger updates automatically:
http://dpldocs.info/this-week-in-d/Blog.Posted_2020_11_02.html#the-user-side
Or dialog boxes and menus and such pulled out of simple function
definitions (which I've been doing for websites for... golly 12
years now lol):
http://dpldocs.info/this-week-in-d/Blog.Posted_2023_01_16.html#batch-programs
Which I've been very happy with sprinkling around, even while
keeping the core a very traditional oop class set. It is nice
when you just do like
---
@menu("&Edit") {
void Envelope_Patterns() {
auto e = new Window("Envelope
Patterns", 70 * 4, 70 * 4);
new EnvelopeChooser(e);
e.show();
}
@accelerator("F1")
void Speed_Down() {
auto sid =
chooser.getSelection()-1;
auto sd =
editableData.songData(sid, 0);
sd[2] = cast(ubyte) --speed; //
speed
Update();
}
@accelerator("F2")
void Speed_Up() {
auto sid =
chooser.getSelection()-1;
auto sd =
editableData.songData(sid, 0);
sd[2] = cast(ubyte) ++speed; //
speed
Update();
}
static string lastMidiFile;
@menu("Track") {
void
Import_From_Midi(FileName!(lastMidiFile, ["Midi
files\0*.mid;*.midi;*.rmi"]) file) {
.........
---
and it magically creates the appropriate windows and dialog
boxes. Or calling a function:
---
dialog((NewSpecies ns) {
// use the ns var here
});
---
saves a bunch of boilerplate.
More information about the Digitalmars-d
mailing list