UI design question
Posted: Fri Jun 18, 2004 6:44 am
I'm designing the UI portion of the preferred application format, which of course should become the easiest way to do it. I've been thinking about an XML based format for the GUI layout, but the GUI layout is tightly coupled with a code file implementing the actual code behind it. I'm searching for new ways to do this. Up to now I've tried to use the C++ code inline with the XML, while escaping the quotation marks, but this looks icky and isn't nice. Anybody have any ideas?
The current idea is like:
which in itself, together with a PassChecking module would be a login screen (including the preferences I have for my login stuff). There is, of course, the obvious way:
I've omitted the allocation of passmodule, since it's something I haven't thought about yet.
Anyone have an idea similar to this, or an improvement? I'm thinking most about the second one, but it has an obvious difficulty with children and functions.
The current idea is like:
Code: Select all
<xml>
<window style="fullscreen" bgcolor="#0010B7" transparency="179"
onclick="if (!isLogin) { exit(); } else { child.hide(); }"
classname="SSABackground" onSysKeyPress="
if (key == SYS_KEY_HOME) {
child.show();
} else {
if (!isLogin) {
exit();
}
}
">
<bool name="isLogin" value="false" />
<module type="SYS_MOD_PASSWORD" />
<window classname="SSAWindow" name="child" style="static">
<label caption="Username:" x="8" y="8" width="104" height="16" />
<textbox x="112" y="8" width="104" height="16" name="Username"/>
<label caption="Password:" x="8" y="32" width="104" height="16" />
<textbox x="112" y="32" width="104" height="16" name="Password" />
<button caption="Login" x="72" y="56" width="72" height="24" onClick="
passmodule.switch(parent.Username.text, parent.Password.text);
// if it gets here, it didn't switch, so one of two is wrong
MessageBox(\"Username or password incorrect.\", \"Error logging in\");
" />
</window>
<label location="centered" caption="Press ctrl-alt-home to login" />
</window>
</xml>
Code: Select all
<xml>
<window classname="SSAWindow" style="static">
<label caption="Username:" x="8" y="8" width="104" height="16" />
<textbox x="112" y="8" width="104" height="16" name="Username"/>
<label caption="Password:" x="8" y="32" width="104" height="16" />
<textbox x="112" y="32" width="104" height="16" name="Password" />
<button caption="Login" x="72" y="56" width="72" height="24" name="LoginButton" />
</window>
<window style="fullscreen" bgcolor="#0010B7" transparency="179"
classname="SSABackground">
<window classname="SSAWindow" name="child" />
<bool name="isLogin" value="false" />
<module type="SYS_MOD_PASSWORD" />
<label location="centered" caption="Press ctrl-alt-home to login" />
</window>
</xml>
-- snip, file something.code starts
SSABackground::onSysKeyPress () {
if (key == SYS_KEY_HOME) {
child.show();
} else {
if (!isLogin) {
exit();
}
}
}
SSAWindow::onClick() {
if (!isLogin) {
exit();
} else {
child.hide();
}
}
SSAWindow::LoginButton::onClick() {
passmodule.switch(parent.Username.text, parent.Password.text);
// if it gets here, it didn't switch, so one of two is wrong
MessageBox(\"Username or password incorrect.\", \"Error logging in\");
}
Anyone have an idea similar to this, or an improvement? I'm thinking most about the second one, but it has an obvious difficulty with children and functions.