12 July 2021, 03:43 | #1 | |||
Registered User
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 301
|
Using a Custom Image for Amiga A Shortcut Key in Menus
I wanted to use an "A" image for the menu shortcuts that didn't look smushed on 1:1 (640x400 eg) screens.
In the end, I got it working, but I think I am "doing it wrong", at least part of the way. Process as I understood it: 1. Make an intuition image (image Struct*) with img.ImageData pointing to the custom image you want to use for shortcut. 2. When opening the window, set WA_AmigaKey, and point it at the image from step #1. (you also have to set WA_NewLookMenus=TRUE) 3. When laying out the menu, set GTMN_AmigaKey, and point it at the same image. (you also have to set GTMN_NewLookMenus =TRUE) ... 5. profit! Reality in my case: - The default "fat A" remained in place - The spacing allocated for the image did shrink up to match my image (I used 16 px, I think the default is something like 28). You can see this in the screenshot where the "Select All" bit overlaps the "A". So partially, anyway, it was getting the message about the image. Workaround: - I'm definitely not saying this is the right way to do it. - There is a reference to dri_AmigaKey in the screen's drawInfo struct. This is is what actually gets rendered (I take it), and is supposed to be a scaled version of the shortcut image. - I tested a bit, and found that if I pointed that at my intuition image from #1 above, BEFORE opening the window, the image would show up in the menus. - It doesn't scale of course. ... so what's the right away to have done it? References: https://wiki.amigaos.net/wiki/GadTools_Menus EAB post: Is there an app to change the workbench menu imagery? AutoDoc for OpenWindow Quote:
Quote:
Code:
// load the menu shortcut key image "A" boolean App_LoadShortCutKeyImage(void) { UBYTE* shortcut_path = "PROGDIR:resources/menu_shortcutw16_8c.iff"; global_app->shortcut_image_.LeftEdge = 0; global_app->shortcut_image_.TopEdge = 0; global_app->shortcut_image_.Width = 16; global_app->shortcut_image_.Height = 8; global_app->shortcut_image_.Depth = 3; global_app->shortcut_image_.ImageData = NULL; global_app->shortcut_image_.PlanePick = 0x07; global_app->shortcut_image_.PlaneOnOff = 0x00; global_app->shortcut_image_.NextImage = NULL; if (General_LoadIFFintoIntuitionImage(shortcut_path, &global_app->shortcut_image_, global_app->pref_depth_) == false) { LOG_ERR(("Window_MakeApp_LoadShortCutKeyImageSpeedBarList %d: loading IFF for menu shortcut key failed", __LINE__)); return false; } Quote:
Code:
// build the menus. returns false on any failure. boolean Menu_BuildMenus(WB2KWindow* the_surface) { struct Window* the_window = the_surface->window_; struct NewMenu the_menu[] = { { NM_TITLE, (const STRPTR)MSG_MenuWorkbench, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuWorkbenchAbout, 0, 0, 0, (APTR)&Menu_HandleWorkbenchAbout}, { NM_ITEM, (const STRPTR)MSG_Quit, "Q", 0, 0, (APTR)&App_Destroy}, { NM_TITLE, (const STRPTR)MSG_MenuFile, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileNewFolder, "N", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileNew, "M", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileOpen, "O", 0, 0, (APTR)&Menu_HandleFileOpen}, { NM_ITEM, (const STRPTR)MSG_MenuFileClose, "W", 0, 0, (APTR)&Menu_HandleFileClose}, { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileGetInfo, "I", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileRename, "R", 0, 0, (APTR)&Menu_HandleFileRename}, { NM_ITEM, (const STRPTR)MSG_MenuFileDuplicate, "E", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileDelete, "D", 0, 0, 0}, { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuFileFind, "F", 0, 0, 0}, { NM_TITLE, (const STRPTR)MSG_MenuEdit, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuEditCut, "X", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuEditCopy, "C", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuEditPaste, "V", 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuEditSelectAll, "A", 0, 0, 0}, { NM_TITLE, (const STRPTR)MSG_MenuView, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuViewAsColumns, "1", CHECKIT | MENUTOGGLE, 0x0006, 0}, { NM_ITEM, (const STRPTR)MSG_MenuViewAsList, "2", CHECKIT | MENUTOGGLE, 0x0005, 0}, { NM_ITEM, (const STRPTR)MSG_MenuViewAsIcons, "3", CHECKIT | MENUTOGGLE | CHECKED, 0x0003, 0}, { NM_TITLE, (const STRPTR)MSG_MenuWindow, 0, 0, 0, 0}, { NM_ITEM, (const STRPTR)MSG_MenuWindowPreviousWindow, "[", 0, 0, (APTR)&Window_HandlePreviousWindow}, { NM_ITEM, (const STRPTR)MSG_MenuWindowNextWindow, "]", 0, 0, (APTR)&Window_HandleNextWindow}, { NM_ITEM, (const STRPTR)MSG_MenuWindowIconize, "L", 0, 0, 0}, { NM_END, NULL, 0, 0, 0, 0}, }; if (the_window == NULL) { LOG_ERR(("Menu_BuildMenus %d: surface's window struct was NULL", __LINE__)); goto error; } if ((the_surface->menu_ = CreateMenus(the_menu, GTMN_FrontPen, 1, TAG_END)) == NULL) { LOG_ERR(("Menu_BuildMenus %d: CreateMenus failed", __LINE__)); goto error; } if (LayoutMenus(the_surface->menu_, global_app->visual_info_, GTMN_NewLookMenus, TRUE, GTMN_AmigaKey, &global_app->shortcut_image_, TAG_END) == false) { LOG_ERR(("Menu_BuildMenus %d: LayoutMenus failed", __LINE__)); goto error; } if (SetMenuStrip(the_window, the_surface->menu_) == false) { LOG_ERR(("Menu_BuildMenus %d: SetMenuStrip failedL", __LINE__)); goto error; } return true; error: return false; } |
|||
14 July 2021, 10:18 | #2 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
AFAIK:
* the GTMN_AmigaKey is only used to inform the menu that there is a custom image. * also set the MENU_IMAGE flag * let ItemFill point to an own struct Image |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FS-UAE 2.5.6dev Amiga Key (Windows key) pops up the start menu | Marskilla | support.FS-UAE | 3 | 23 September 2014 23:18 |
Cubo CD32 custom key maps | elenamancuso | support.WinUAE | 2 | 24 July 2014 00:03 |
Help ! Problems with user menus and start menus in Directory Opus 5.8 | beltrixx | support.Apps | 0 | 27 May 2009 08:30 |
JIT on/off key shortcut | jotd | support.WinUAE | 4 | 17 December 2008 20:51 |
Amiga games with good menus/shops | killergorilla | Retrogaming General Discussion | 52 | 17 May 2007 19:41 |
|
|