Expand description
The window’s own frame, as a plugin (FramePlugin, opt-in): the
application draws its title bar (in the zones::TITLE zone, above
the menu bar) and its resize edges, instead of the system, as VS Code
does. A setting (window.frame) switches between the application’s
frame and the system’s; the system’s comes back at once.
The bar holds, from the start edge, the blocks of the
zones::CAPTION_START zone (by default BLOCK_MENU: a button
opening the system menu, also Alt+Space and a right click on the
caption, then the application’s logo when it gave one
(FramePlugin::logo) and its name), the window’s title, the blocks
of the zones::CAPTION zone (the application’s buttons) and the
minimize, maximize and close buttons. Its hit regions are published
per window (egui_pop_core::frame::HitTable) and shown by the debug
bridge’s frame collector.
In full screen the bar stays, with its zones (the menus and the
application’s items live there): close stays, minimize goes, and a
button leaving full screen (the frame.exit_fullscreen step) takes
maximize’s place. The bar no longer moves the window and a double
click on it does nothing (the way out is that button, or F11); the
resize edges go. A setting (window.bar_in_fullscreen, on by default)
turns this off: then in full screen the bar is not drawn and publishes
no caption, and the window plugin’s strip at the top edge is the way
out.
VS Code’s layout controls come at the end of the bar, before the
window’s buttons, when the application asks
(FramePlugin::own().layout_controls(true)): a “Customize layout”
button opening the layout menu, and a toggle per area (the primary
side bar, the panel, the secondary side bar), filled while the area
shows; see crate::layout_controls.
An application puts its logo at the start of the bar by replacing the
menu block; the bar itself (BLOCK_TITLE) still follows the
setting:
ctx.block(
zones::CAPTION_START,
Block::replace(frame::BLOCK_MENU, BlockId::from_static("app.logo"), |ui, app| {
frame::menu_button(ui, app);
ui.strong_text("My app");
}),
);Steps (ADR 0011), each with a default a plugin may veto or replace:
| Step | Arguments | Default |
|---|---|---|
frame.minimize | {} | minimizes the window |
frame.maximize | { "maximized": bool } (the state asked for) | maximizes or restores |
frame.close | { "viewport": "root" } | closes the window: the main one’s pop.window.close; an application window’s close request, its content may refuse, then its pop.window.close |
frame.system_menu | { "x", "y" } (points) | opens the system menu there |
frame.exit_fullscreen | { "viewport": "root" } | leaves full screen |
frame.hit_test | { "viewport": "root", "install": bool } | on Windows, takes over the window’s hit testing (or gives it back) |
§Windows: the system’s hit test
winit cannot answer WM_NCHITTEST (see docs/upstream.md), so on
Windows, when the application draws the frame, the plugin subclasses
the main window through egui-pop-win32 and answers it from the
published regions: the caption moves the window natively (Aero Snap),
the maximize button shows Snap Layouts, the edges resize. Clicks on
the buttons, a double click and a right click on the caption come back
as the usual requests, so the steps above still run. In full screen the
caption is answered as client area (the system must not move the
window), and the button leaving full screen is client area too: Snap
Layouts never show in full screen. The handle comes
from eframe when the application is started with
AppBuilder::run_native (or run_native_with); an application
starting eframe itself gives it with set_native_window. Only the
main window is subclassed for now.
§Corners
A window without the system’s decorations has square corners on
Windows 11; the plugin asks the system for the kit’s window.corners
(round, small or square) when it draws the frame, again when
the theme changes it, and gives the system’s default back with the
system’s frame. Windows 10 refuses, harmlessly. The outcome is in the
frame collector (corners), never silent. Elsewhere nothing is
asked: no other system has a portable request for a window’s
corners (Wayland and X11 leave them to the compositor or the window
manager, macOS rounds its own windows), so egui-pop draws them:
every window it decorates gets a line around it (the kit’s
window.rest.border-*, dimmer while another window has the focus)
and, where it is built transparent (AppBuilder::rounded_windows, by
default on Wayland), rounded corners while it floats free
(egui_pop_core::frame::Placement): square when maximized, in full
screen or on a side against a screen’s edge. Wayland does not tell a
tiled window (no position, and winit 0.30 keeps the tiled states):
there one keeps its rounded corners.
Structs§
- Frame
Plugin - The plugin:
FramePlugin::own()draws the frame by default,FramePlugin::system()leaves it to the system until the setting says otherwise.
Constants§
- BLOCK_
MENU - The start of the title bar, in the
zones::CAPTION_STARTzone: the system menu button and the application’s name. - BLOCK_
TITLE - The title bar, in the
zones::TITLEzone: it keeps the window’s decorations in line with the setting, so it is better wrapped or extended than replaced. - CMD_
CLOSE - CMD_
MAXIMIZE - CMD_
MINIMIZE - CMD_
SYSTEM_ MENU - MENU_
SYSTEM - The system menu (restore, minimize, maximize, close); plugins may add to it.
- SETTING_
BAR_ IN_ FULLSCREEN - The setting: whether the application’s title bar stays in full screen (on by default).
- SETTING_
FRAME - The setting:
own(the application draws the frame) orsystem. - STEP_
CLOSE - STEP_
EXIT_ FULLSCREEN - STEP_
HIT_ TEST - STEP_
MAXIMIZE - STEP_
MINIMIZE - STEP_
SYSTEM_ MENU
Functions§
- bar_
in_ fullscreen - Whether the application’s title bar stays in full screen
(
window.bar_in_fullscreen). - forget_
native_ window - Forgets the handle recorded for
viewport(set_native_window), once its window is gone. - menu_
button - The button opening the system menu (the
BLOCK_MENUblock draws it); an application replacing that block calls it to keep the menu. A click asks for the menu through theframe.system_menustep. - own_
frame - Whether the application draws the window’s frame now.
- record_
native_ window - Records the main window’s native handle from eframe’s creation context:
the
HWNDon Windows (set_native_window), the X11 id on Linux’s X11 (set_x11_window), and the window itself, which the system’s file chooser asked from it is attached to (files::set_parent_window).AppBuilder::run_nativecalls it; an application starting eframe itself calls it from its creation context. - request
- Asks the frame’s step for a request, with its default.
- set_
native_ window - Records a window’s native handle (an
HWNDon Windows), for the frame’s hit testing.AppBuilder::run_nativedoes it for the main window; an application starting eframe itself calls it from its creation context. - set_
x11_ window - Records the main window’s X11 id (Linux, the window on X11 or Xwayland):
what a native view inside it, such as the viewer’s web view, is made a
child of.
AppBuilder::run_nativedoes it; an application starting eframe itself callsrecord_native_window. - x11_
window - The main window’s X11 id, when it is an X11 window: none on Wayland, on other systems, headless, or when it was not recorded.
Type Aliases§
- Logo
- The application’s logo in the title bar: its image, asked each frame
(
FramePlugin::logo).