Skip to content

feat(bags): keep the layout while taking items out - #3579

Merged
EllesmereGaming merged 2 commits into
EllesmereGaming:mainfrom
tester617:bags-hold-layout
Nov 24, 2026
Merged

EllesmereGaming merged 2 commits into
EllesmereGaming:mainfrom
tester617:bags-hold-layout

Conversation

@tester617

Copy link
Copy Markdown
Contributor

I went straight to a PR instead of opening a feature request first, so the change is ready to try. If you would prefer a different approach, a smaller scope (for example bags only) or other names and placement for the options, tell me and I will gladly rework it.

What does this PR do?

Problem. When you sell at a vendor or move items between bags and bank, every removed item re-lays out the window. In Compact a block that lost one item can get narrower, and the planner moves other blocks into another band, so a category jumps from bottom left to top right. In Grid every category below shifts up when one loses a row or empties. The mouse stays where it was, so the next right-click can hit an item of a different category, and it is easy to sell the wrong thing.

Change. Two new switches, both off by default, named "Keep Layout While Taking Items Out": one for the bags (Layout section) and one for the bank (last row of Grouping). While a switch is on, the window you take items out of keeps every category, sub-group (armory slots, expansions, type splits), Pinned, Recent Items and the bank's Empty Slots group at its place and size. Items inside a group still close up left to right as today. The freed slots at the group's end stay empty, and a group that empties stays as an empty block with "(0)". The window items go into sorts as today.

There are two switches because the two windows have separate option pages and the bank hold needs the bank's grouping. The bank hold works in OneBank and OneWarbank with Nest by Expansion or Group by Category. Its toggle is greyed out in List or without grouping (the tooltip says why). In per-tab views and while a search or a sidebar category is selected it has no effect. In the bags the hold covers Grid and Compact (All Items, group view, single category, virtual views). In OneBag and MultiBag only the Pinned and Recent Items quickviews hold, and the bag sections keep slot order as today. List is untouched in both windows.

When the held layout resets.

  • The window closes. Every bank hide closes the bank (upstream behaviour), so the bank hold ends there, also with Alt-Z. The bags keep their hold across Alt-Z.
  • For the bags: a vendor, bank, guild bank, the mailbox's Send Mail tab, trade or the auction house opens or closes.
  • The search text changes.
  • Sort is clicked (any sort). Passes during a sort record but never hold.
  • New items come in: a quantity above what the window held since the hold started. Buying back what you just sold, or putting back what you just took, refills its old slot instead.
  • A held group needs more cells than it held (for example a stack split, or an item reclassified into a full or new group). In the bank also when there are fewer free slots than gaps to fill. The window then re-lays out at once.
  • Any refresh that is not an item event (view, category, setting, pin/assign, column count).

How it works. A small state module, EUI_Bags_Hold.lua, records per window each group's cell count and planned label width while items leave. Only refreshes that come from item events keep the hold: the existing debounced bag/bank refresh (including the v9.9.2 tint retry), the combat-end replays, and the Pawn and search repaints set one flag. Every other refresh releases it. Held passes draw at least the recorded cells per group. The bags fill the gaps with the existing empty-slot pad frames (mouse off, never secure buttons), the bank with real empty slots of the view. In Compact a held pass hands CompactPack identical inputs, so its memo hits and the bands are not replanned. While held, Auto-Size with Shrink keeps the column count. Labels are planned with a small fixed reserve per count digit (0.35 of the font size), so "(1)" turning into "(0)" (wider in proportional fonts) does not cut the label.

Cost. Each cell is garbage per pass / Lua VM instructions per pass, measured at this commit against upstream v9.9.2.

Pass Bags Grid Bags Compact Bank Compact Bank Grid
Upstream v9.9.2 13,705 B / 16,274 12,700 B / 14,943 336,979 B / 40,774 334,851 B / 24,629
Switch off 13,657 B / 16,464 12,604 B / 15,206 337,019 B / 40,931 334,891 B / 24,754
Switch on, held pass 13,657 B / 20,678 12,604 B / 20,108 337,019 B / 50,473 334,891 B / 33,370
Taking 30 items out, per pass, upstream 13,073 B / 16,027 11,807 B / 292,360 330,487 B / 482,470 328,275 B / 23,915
Taking 30 items out, per pass, switch on 13,546 B / 20,760 12,661 B / 20,327 330,578 B / 50,318 328,367 B / 33,215

These are deterministic counts from a Lua 5.1 harness that loads the real addon files with stubbed WoW APIs. They are not timings taken in the game client, and the client's own work behind API calls such as SetText or SetPoint is not included. No in-game timing was taken.

  • Measured: the hold lines of RefreshInventory, RenderGridView, the Compact collector, CompactBagsPlace and CompactPack for the bags; the grouped layout, ToCompactLayout and the planner for the bank; the hold module.
  • Not measured: the gather loop, classification, sorting and button rendering.
  • World: bags with 103 items in 15 categories with armory slot groups, Grid at 13 columns; bank with 300 slots, 225 items, 15 categories, 16 columns.
  • Garbage: the byte figures cover the whole stubbed pass, including harness allocations, so only the differences between rows belong to this PR.

Reading the numbers:

  • Off: no event, hook, OnUpdate, ticker or frame. Per refresh pass one profile read and a few flag checks (+0.4 % to +1.8 % of the measured code) and no Hold call. Outside the passes there are one or two Hold calls that return at the first check per window close, panel change, search change and bank or MultiBag sort click, and one flag write per event refresh. State and scratch tables are created on the first pass with the switch on. At load only the module's functions and a few small tables exist. No new allocation site: the bank's +40 B per pass are five existing per-pass closures in RefreshBank that capture one more upvalue, and the bags allocate slightly less than upstream (the pad pool's get-or-create moved to file scope).
  • On, nothing changing: a held pass costs about +4k to +5k instructions in the bags and +8k to +10k in the bank, that is +24 % to +35 % of the measured code. The hold code allocates no tables, also with emptied groups (stand-ins reuse the last bucket table).
  • On, taking items out: in Compact the held pass skips the band planning, so a pass runs about 272k (bags) and 432k (bank) fewer instructions than upstream. In Grid there is no planner to skip, so the hold costs about +30 % (bags) and +39 % (bank) of the measured code per take pass. The few hundred extra bytes per take pass come from the labels and pads of emptied groups, which still draw, while the upstream pass shrinks.
  • Refactor: the only upstream refactor is the empty-pad pool's get-or-create, moved to file scope so Compact can share it (one counter for both displays). The upstream placement lines are unchanged.
  • Sort timer: the sort suspension of the MultiBag and bank sorts ends with the existing sort lock timers (UnlockSort after 3 s, UnlockBankSort). The timer only blocks holding, nothing waits on it, and no new timer is added. The Grid/Compact sort needs no suspension: its event passes are off during the run, and its final repaint is not an item event.

By design.

  • Sell Junk, QoL's auto-sell junk and the bank's "Deposit Reagents" and "Deposit Warbound Items" buttons take items out of the bags, so the bags keep their layout and the gaps (for example "Junk (0)") until the vendor or bank closes. These buttons sell or move many items one after another over up to about 2 seconds, so releasing the hold after such a sweep would re-lay out the bags at a moment when the player may already be clicking again by hand, which is exactly the misclick this feature prevents.
  • The bank's "Empty Slots (N)" counts all empty slots, including those that fill held groups, so the number keeps showing the bank's real free space.
  • Empty pads ignore the mouse, so a pad can never become the target of a misclick. Left-dragging a pad therefore drags the window, as with today's row-filler pads.
  • With the switch on, labels carry the digit reserve on every pass, so Compact and the armory slot rows can pack slightly differently than with the switch off. The reserve is what keeps "(0)" from cutting the label or widening a block.

Known limits.

  • A stack merge from a server-side sort that lands after the 3 s lock, or a late bag update right after a sort, can leave a pad until the next reset. The hold reuses the existing sort lock timer instead of adding a timer of its own.
  • An item that late item info or an equipment-set change moves into another held group that still has a free slot fills that slot, and the emptied cell in its old group stays until the next reset. Tracking every slot's group would cost work on every pass, and the gap is cosmetic because buttons always show their real item.

How was it tested?

  • In game on WoW Forever 1.60.1.71037 with 9.9.2: selling one by one in Grid (13 columns, armory slot groups) and Compact, emptying a category and an armory slot bucket, Recent Items, buyback, Sell Junk, right-click deposits and withdrawals, bank grouped by category in Compact, a nearly full bank, sort, pin/assign, close/reopen, Alt-Z, switch off. Not yet tested on Retail.
  • Stub harnesses (git-ignored, not part of this PR) for the hold state, wiring, Grid, Compact, bank and option texts, plus random take/split/merge/buyback/reclassification sequences at this commit: the clicked cell never shows a different item and nothing outside the clicked group moves (468,000 passes across Grid, Compact and bank, 0 findings). With the switch off every pass draws exactly like upstream (410,400 passes, 0 differences).
  • python3 .tools/guardrails.py OK. extract-locale-keys.sh leaves _keys.txt unchanged (option texts are localised at runtime). deDE strings added.

Screenshots

image image

Before moving items:
image

After moving items:
image

Checklist

  • New settings default OFF (no behavior change without opt-in): both switches default off.
  • Zero cost while disabled: no events registered, no polling, no hooks doing work, no tickers; nothing built beyond an inert event frame or combat queue: no event, hook, ticker or frame is added. Except: one profile read and a few flag checks per refresh pass, and one or two early-returning Hold calls per close, panel, search and sort click (see Cost).
  • Cheap while enabled: event-driven (no polling, no timer-based logic, no per-frame allocations): no new timer and no per-pass table allocation in the hold code. The existing sort lock timers end the sort suspension and only block holding.
  • No writes onto Blizzard-owned frames (weak-table pattern used); HookScript/hooksecurefunc only, never SetScript on Blizzard frames: only EllesmereUI's own frames are touched, with one line inside the existing EUI_Bags:HookScript("OnHide") and one inside the bank's own OnHide.
  • Tested in-game on live; no version gates or pre-Midnight APIs added: no version gates or pre-Midnight APIs. Tested on WoW Forever, not yet on Retail.

tester617 and others added 2 commits November 22, 2026 10:57
New opt-in switches "Keep Layout While Taking Items Out" for the bags (Layout section) and the bank (last row of Grouping, needs Nest by Expansion or Group by Category), both off by default. While on, the window items are taken out of keeps every category, sub-group, Pinned, Recent Items and the bank's Empty Slots group at its place and size: items close up inside their group, the freed slots at its end stay empty, and an emptied group stays as an empty block. The window items go into sorts as before. The bags fill the gaps with the existing empty-slot pad frames, the bank with the real empty slots the taken items left, so no secure button is involved.

Only item-event refreshes keep the hold; any other refresh releases it, as do closing the window (every bank hide closes the bank), opening or closing an item panel, a search change, a sort (counted suspension; passes during a sort never hold) and new items coming in (a quantity above its running maximum since the hold began). Group keys use category identity through named prefixes, so equal labels never share a held size.

A held Compact pass feeds CompactPack the held cell counts and label widths, so its memo hits and the bands are not replanned. Labels are planned with a small fixed reserve per count digit, so a count that drops to 0 never cuts the label. A held pass allocates no tables in the hold code. With both switches off the hold adds no event, hook, timer, frame or allocation site; its tables are created on first enable. The empty-pad pool's get-or-create moved to file scope so Grid and Compact share one pool and counter; the upstream pad placement lines are unchanged.
@EllesmereGaming
EllesmereGaming merged commit 3141802 into EllesmereGaming:main Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants