Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: implement "query back" interface and "checked" menu items for Windows and GTK (for Mac it's another issue now!) #200

Closed
lgblgblgb opened this issue Sep 25, 2020 · 8 comments

Comments

@lgblgblgb
Copy link
Owner

lgblgblgb commented Sep 25, 2020

DO NOT USE INFORMATION FROM THIS ISSUE BUT ONLY FROM ISSUE #227 BECAUSE THIS ONE HERE CAN BE OUTDATED ALREADY

For Windows, I've already written this. The task is to create similar functionality for Mac and GTK UIs too. See mega65's ui.c as an example:

{ "System console", XEMUGUI_MENUID_CALLABLE | XEMUGUI_MENUFLAG_QUERYBACK, xemugui_cb_sysconsole, NULL }

So the key is to use XEMUGUI_MENUFLAG_QUERYBACK to specify such a functionality for a given defined menu point. The callback then should looks like something like this:

void xemugui_cb_sysconsole ( const struct menu_st *m, int *query )
{
    if (query)
        *query |= (sysconsole_is_open ? XEMUGUI_MENUFLAG_CHECKED : XEMUGUI_MENUFLAG_UNCHECKED);
    else
        sysconsole_toggle(-1);
}

According the callback, the UI core should render the "checked sign" or not. For example xemu/gui/windows.c:

if ((type & XEMUGUI_MENUFLAG_CHECKED))
    CheckMenuItem(menu, xemuwinmenu.num_of_items, MF_CHECKED);

So basically a callback is called when it's activated, BUT if it's a menu point marked with XEMUGUI_MENUFLAG_QUERYBACK, then it must be also called on building the menusystem itself to query if it should be checked or not. The query callback happens on the time building of the menu itself. Note, that in theory the callback even can sets other flags to alter menu, but currently that's not implemented (eg: there is radio buttons in the windows GUI version by me, but never used by emulation target UIs ...). See the example above in general with the sysconsole example, how a callback knows if it's a query call to itself, or an activation call. Basically checking query pointer, if it's not NULL, it's a query call only, *query must be altered and callback should return. Otherwise if it's NULL, it's a call because of the user clicked on the menu itself.

A minor part, not too much related:

XEMUGUI_MENUFLAG_SEPARATOR or'ed to the type in the menu definition should cause to have a separator line AFTER THAT menu item.

For examples see this commit

Commit 5f0f6d8 for issues #200 and #201 for GTK and Windows UI.

Please see the vic branch for now: https://github.com/lgblgblgb/xemu/tree/vic

Other similar issue

Issue #201

@lgblgblgb
Copy link
Owner Author

As far as I can see, I hope I can do it myself for GTK (it's interesting that I implemented this for Windows, but not for GTK ...), but I'm sure I have no idea how to do this for Mac UI.

@hernandp
Copy link
Contributor

I will take this for macOS.

@lgblgblgb
Copy link
Owner Author

Thanks! I've updated the first comment here a bit to better explain how it works.

@lgblgblgb
Copy link
Owner Author

I'll take care about the GTK part.

@lgblgblgb
Copy link
Owner Author

lgblgblgb commented Sep 25, 2020

One important point! Just browsing the sources, it seems windows is not so much consistent with the GTK implementation. That is, the callback SHOULD set either of XEMUGUI_MENUFLAG_CHECKED or XEMUGUI_MENUFLAG_UNCHECKED or query request, it's maybe not enough in every case to set only checked. And be careful not to set both, since it's possible just the result is hmmm unknown :) Honestly my GUI layer is not the best. The problem here that on Windows you can mark a menu item checked later. On GTK you need to create as checkable ... Thus if we don't have CHECKED or UNCHECKED the GTK version won't know that it's a checkable item if it's not checked, so no way to check it by the user ... I should create a better abstraction in the future, but I wouldn't rewrite everything in the GUI as well ... :-/

@lgblgblgb
Copy link
Owner Author

Done for Windows and GTK.

lgblgblgb added a commit that referenced this issue Nov 2, 2020
Though MacOS still lacks of these ... TODO
@lgblgblgb
Copy link
Owner Author

I hacked the MacOS UI implementation to have query-back, but it does not do too much, as the UI code should be aware to render the "checkbox" status to be really useful, what I have no idea about how to do. I tested it with my hackintosh-VM on my Linux box, it still seems to work, so maybe I haven't messed up at least ;)

@lgblgblgb lgblgblgb changed the title UI: implement "query back" interface and "checked" menu items for Mac and GTK UIs UI: implement "query back" interface and "checked" menu items for Mac and GTK UI Jan 9, 2021
@lgblgblgb
Copy link
Owner Author

This problem is moved into issue #227

@lgblgblgb lgblgblgb changed the title UI: implement "query back" interface and "checked" menu items for Mac and GTK UI UI: implement "query back" interface and "checked" menu items for Windows and GTK (for Mac it's another issue now!) Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants