Skip to content

Window Title Bar and Menus #59

@JohnDog3112

Description

@JohnDog3112

As we talked about, I've been doing some research on how different programs/operating systems handle the title bar for a window. Here's what I have found so far:

Windows

2 main approaches:

  • simple:
    • Icon, title bar, and colors can be changed
  • extended:
    • The draw area for the window is expanded to include the title bar
    • Space is reserved for the icon in the top left and close/minimize/maximize buttons in the top right
    • The program sets a drag area that a user can click on to drag the window around
    • The program sets "interactive" areas in the drag area to add exceptions and to get user interaction
  • both:
    • In both cases, the application is responsible for drawing and handling any menus it wants to provide. For the simple approach, the menus might be below the title bar while the extended one allows them to be part of it.
    • Windows does provide some builtin frameworks/libraries for this however such as:
      • Win32 API
        • text (buttons), seperaters, checkboxes, radio items, submenus, owner-drawn items (items drawn by the application itself)
      • Microsoft Foundation Classes (MFC)
        • Seems to be an abstraction over the Win32 API
        • In addition, it seems to emphasize defining that majority of the menu structure and layout in a menu resource file (.rc)

MacOS

  • Menu is at the very top of the screen; icon, caption, close/minimize on window
  • The menu seems to use a widget like system
    • From what I can find, it seems like a limited(?) widget system
    • Main elements:
      • Menus, submenus, buttons, check boxes, radio (select 1 from group)
    • example:
      • On macos, vscode seems to place the search bar at the top of the window rather than with the rest of the buttons like file, edit, selection, etc. that are placed at the menu bar at the top left of the screen.

Electron

  • Seems to use a very similar system to MacOS and will adapt it to the two methods talked about above depending on the OS it is running on.
  • Available types:
    • normal, separator, submenu, checkbox or radio (select 1 from group)

Amiga

  • Menus are part of the application title bar, but are hidden until right clicked by default
  • Seems to use a similar system to MacOs and Electron:
    • Text (buttons), submenus, seperators
      • checkboxes and radio elements can be simulated by adding characters like [X] and [ ] that are appended to the front of the button text and changed when clicked.

twr-wasm implementation

  • I believe it would be better to do one of the simpler options like how MacOS, Electron, Amiga, and the Win32 API do it rather than windows full system for the extended title bar.
  • As for the placement of the menu bars, I think it depends on the "supported" targets. For instance, if the only target is desktops I think having them as part of the title bar would work just fine. However, if devices like tablets or phones were included, it might be better to hide it like Amiga or have it centralized at the top like MacOS.
  • keyboard shortcuts:
    • I didn't really talk about this above, but it seems like Windows, MacOS, and Electron call keyboard shortcuts accelerators. From what I can find, it seems like they have general functions for setting up shortcuts, but some menu APIs allow you to attach shortcuts directly to menu items.
    • I believe both should be implemented where the menu API simply uses the underlying shortcut registration function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions