A tab dragged out of its bar (ui.Tab_Out)
One machine for every program that has tabs: the person drags a tab along its bar, onto another window's bar, or out to a window of its own, and sees on every system what follows the pointer and where the tab lands. The design is in src/md/features/tab-drag-out.md.
Setting up
One ui.Tab_Out for the program (all its windows):
Formula
app.tab_out = ui.Tab_Out{
program = {
payload = tab_payload, // fills a system drag's data: the program's own MIME type and the tab's id
open = tab_window, // makes a window holding the tab alone (or the source window, for its only tab), and the grab
frame = draw_windows, // draws the program's windows while a system drag holds the thread
ended = tab_ended, // acts on the end: Moved, New_Window, Taken, Cancelled
user = app,
},
renderer = &app.renderer, // the drag icon's picture (nil: a plate of the tab's size)
}In each build of a bar
Formula
for t, i in tabs {
b := build_tab(t, i)
b.fixed_pos.x += ui.tab_out_shift(&app.tab_out, win, BAR, i) // the room for the marker
if ui.tab_out_signal(&app.tab_out, win, BAR, i, t.id, ui.signal(b)) { /* the carried tab: dim it */ }
}
ui.tab_out_marker(&app.tab_out, win, BAR) // a faint tab with the accent's border at the gap
ui.tab_out_bar(&app.tab_out, win, BAR, bar.rect, edges, vertical) // edges: n + 1 values, client pixelsedgesare the tabs' leading edges and the last one's trailing edge, as laid out without the drag.tab_out_barof the source window also reads the pointer, the button and Escape, once a build.announceholds a sentence for a screen reader after each change: give it to the window's live region.
Between frames
Formula
ui.tab_out_run(&app.tab_out) // starts the transport of a tab that left its bar (a system drag blocks here)
ui.tab_out_window_gone(&app.tab_out, w) // a window closes: its bars go, a drag it held endsThe ends
| End | The program |
|---|---|
Moved{to} | moves the tab to to.gap of bar to.bar of to.window (the gap counts the tab in its own bar); closes window when it was made for the tab |
New_Window{window, at} | keeps window, or opens one (at: where, when the system gives positions) |
Taken | another program took the tab (a move): closes it here |
Cancelled | closes window when it was made for the tab; the tab stays where it was |
tab_out_command() is the text of the command "Move tab to new window": list it in the palette and the tab's menu.
ui.tab_out_icon makes the drag icon from a window's picture (it is public for a program that runs its own drag).