Notings of Attention™
Acmlmboard 2 Released
Github/GIT | @acmlmboard
Chatting Places
Discord

Affiliates
Super Mario Bros. X | Kuribo64 | NeoRHDN
Views: 11,105,301
Main | FAQ | IRC chat | Memberlist | Active users | Latest posts | Stats | Ranks | Online users | Search
12-05-24 02:18 AM
Guest: Register | Login

0 users currently in msg db 'Computer Address',0xa | 1 bot

Main - msg db 'Computer Address',0xa - GUI systems design - a hypothetical scenario
Next newer thread | Next older thread


Kawa
Posted on 02-05-12 02:43 PM, in Link | ID: 5278
Retired Staff

Not okay
Prophet of Celestia
Level: 94


Posts: 478/2423
EXP: 8195131
Next: 161526

Since: 01-01-12
From: The Netherlands

Last post: 2251 days
Last view: 566 days
Imagine you're in an operating system development team, and you're in charge of designing how a given application would handle its windows and controls. Not the actual drawing of elements, but how to set up a window and react to events.


In Windows, the answers are a tree of objects, where things like buttons and input boxes are the same as the windows they are in, distinguished only by their class and styles, and events are done by a message pump -- the application spins a loop, checking for new system messages and responding to them.

For example, a button could be created by the CreateWindow system call, specifying that it needs to be a button by class, and returning the window handle for it. In the message pump, the message for being clicked is found, and the target handle matches the one CreateWindow returned, so we know that the button was clicked.

This system works fine for procedural languages, and can be mapped into OOP -- just look at MFC and .Net.


The question is, how would you do it? This is your OS, so anything goes. Surprise me.


Lili~ ♥
Posted on 02-05-12 02:47 PM, in Link | ID: 5284
Normal User
Queen Lesbian of Kafuka
Level: 161


Posts: 321/8412
EXP: 52986179
Next: 1126938

Since: 01-06-12

Last post: 2977 days
Last view: 1499 days
I'd do it similar to HTML/JavaScript - a resource script would set the layout of the user interface like in HTML, and the buttons and fields would be interacted with by specifying onhover/onclick/onkeypress statements similar to how JavaScript does it, which would then call functions in the code.


Kawa
Posted on 02-05-12 02:49 PM, in (rev. 2 of 02-05-12 03:13 PM by Kawa) Link | ID: 5287
Retired Staff

Not okay
Prophet of Celestia
Level: 94


Posts: 483/2423
EXP: 8195131
Next: 161526

Since: 01-01-12
From: The Netherlands

Last post: 2251 days
Last view: 566 days
So basically, the entire GUI is made of webpage?

Neat.


Update: we discussed this on IRC just now and I feel this should be posted for posterity's sake. To get a language-agnostic nature, I've suggested to replace the Javascript-style onFoo attributes with a Win32-inspired message pump. The application would spin around waiting for events as in Win32, and each event would specify its own nature (clicked, closed, paint, drag-drop stuff...) and the target, which could be either a vague identifier ("this window") or an element's ID attribute.

<window title="Test window" resizable="no">
<!-- Ignoring layout for clarity -->
<button id="increase">Increase power</button>
<label id="currentPower">Power: 0%</label>
</window>

...

while (true)
{
while (HaveEvents())
{
event e = CheckEvents();
switch (e.type)
{
case EV_CLICKED:
if (e.target == "increase")
{
power += 20;
//prepare the new text here some way, I dunno, sprintf?
SetText("currentPower", newText);
}
break;
case EV_CLOSING:
//no need to use target -- buttons and labels can't close, so this has to be the window.
e.cancel = true; //don't let them close the window because mine is an evil laugh.
break;
}
}
}



Cynthia
Posted on 02-05-12 06:46 PM, in Link | ID: 5350
Normal User
Bot Without Panties
Unofficial board mascot
Level: 25


Posts: 29/115
EXP: 84677
Next: 4943

Since: 01-08-12

Last post: 3755 days
Last view: 2528 days
XML window definitions are okay, but not as braindead as on the Android, please.


Kawa
Posted on 02-06-12 06:23 PM, in Link | ID: 5697
Retired Staff

Not okay
Prophet of Celestia
Level: 94


Posts: 551/2423
EXP: 8195131
Next: 161526

Since: 01-01-12
From: The Netherlands

Last post: 2251 days
Last view: 566 days
Here's a practical demonstration I came up with. The screenshot is a mockup, and is missing one element but whatever.

http://helmet.kafuka.org/liliwin_sample1.rar


NovaSquirrel
Posted on 02-12-12 03:12 PM, in Link | ID: 6340
Normal User

Goomba

Level: 14


Posts: 7/29
EXP: 10727
Next: 2344

Since: 01-04-12
From: Toasterland

Last post: 3798 days
Last view: 1510 days
I would most likely try to imitate Allegro's built-in GUI system, where the window is specified as a big array of functions to call in order (that get passed a signal number, like MSG_CLICK or MSG_DRAW and return a signal) with widget properties after it, like width, color, a generic pointer for labels and textboxes, colors and such. Widgets are extended by making a wrapper for another widget's function that traps messages or results.


Kawa
Posted on 02-12-12 03:14 PM, in Link | ID: 6341
Retired Staff

Not okay
Prophet of Celestia
Level: 94


Posts: 634/2423
EXP: 8195131
Next: 161526

Since: 01-01-12
From: The Netherlands

Last post: 2251 days
Last view: 566 days
Could you post a snippet of actual code? Also, how would you solve the problem of language-agnosticism?


NovaSquirrel
Posted on 02-12-12 04:02 PM, in Link | ID: 6344
Normal User

Goomba

Level: 14


Posts: 8/29
EXP: 10727
Next: 2344

Since: 01-04-12
From: Toasterland

Last post: 3798 days
Last view: 1510 days
Posted by Kawa
Could you post a snippet of actual code? Also, how would you solve the problem of language-agnosticism?


A popup that requests a line of text for a Conway's Life demo a long time ago:
DIALOG the_dialog[] = {
/* (dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
{ d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
{ d_ctext_proc, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, Popup_Question1, NULL, NULL },
{ d_ctext_proc, 0, 8, 200, 0, 0, 0, 0, 0, 0, 0, Popup_Question2, NULL, NULL },
{ d_edit_proc, 0, 24, 200, 8, 0, 0, 0, 0, LEN, 0, Popup_Response, NULL, NULL },
{ d_button_proc, 0, 48, 200, 20, 0, 0, 'q', D_EXIT, 0, 0, "Okay", NULL, NULL },
{ d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};


and the classical (I guess) "calls a function defined for the button when the button is clicked" thingy I always implement in every single program:
int my_button_proc(int msg, DIALOG *d, int c) { // calls dp3 as a function when clicked
int ret = d_button_proc(msg, d, c);
if (ret == D_CLOSE && d->dp3)
return ((int (*)(void))d->dp3)();
return ret;
}

that intercepts messages from a close button that tell the application to exit the menu and instead return the result of a function.


Kawa
Posted on 02-12-12 04:11 PM, in Link | ID: 6345
Retired Staff

Not okay
Prophet of Celestia
Level: 94


Posts: 635/2423
EXP: 8195131
Next: 161526

Since: 01-01-12
From: The Netherlands

Last post: 2251 days
Last view: 566 days
And the part where it doesn't have to be in C, which is what "languag-agnostic" means?


Minimalist theme mockup of the hypothetical LiliOS. I'm thinking, a given window ought to be able to change the theme it wants to use, but defaults to a system-wide setting. So in that shot, you might imagine opening the sample app's "Theme" menu and selecting a Motif theme, which would switch the whole window to an approximation of Motif, while bsnes and the rest of the system remain set to Minimal.


Next newer thread | Next older thread
Main - msg db 'Computer Address',0xa - GUI systems design - a hypothetical scenario


Acmlmboard v2.5.6 (06/11/2024)
© 2005-2024 Acmlm, Emuz, et al.

Page rendered in 0.071 seconds. (790KB of memory used)
MySQL - queries: 122, rows: 517/551, time: 0.054 seconds.