The Overview address list built all N rows on every frame (icons, labels, balances, buttons, an InvisibleButton and a context-menu check per address) and allocated a vector of N row positions, however few rows fit on screen; the edge mask then walked all their vertices. An ImGuiListClipper now submits only the rows that intersect the list's clip rect, plus: - one guard row on each side, so dividers and anti-aliased edges at the clip boundary are drawn as before; - the row being dragged and the row whose context menu is open, so drag-to-reorder and the menu keep working when they scroll away; - the rows keyboard navigation targets (kept by the clipper itself). Before each row the cursor is put back exactly where the unclipped loop left it, so the density-scaled spacing, which depends on the cursor position, and every row's geometry are unchanged. Row tops are computed from the index, so the per-frame vector is gone, and the scroll extent is the same. The row model (sort, filter) is still rebuilt over all addresses each frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
2.8 KiB
C++
81 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include "data/wallet_state.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dragonx {
|
|
namespace ui {
|
|
|
|
struct AddressListInput {
|
|
const AddressInfo* info = nullptr;
|
|
bool isZ = false;
|
|
bool hidden = false;
|
|
bool favorite = false;
|
|
bool mining = false;
|
|
std::string label;
|
|
std::string icon;
|
|
int sortOrder = -1;
|
|
};
|
|
|
|
struct AddressListRow {
|
|
const AddressInfo* info = nullptr;
|
|
bool isZ = false;
|
|
bool hidden = false;
|
|
bool favorite = false;
|
|
bool mining = false;
|
|
std::string label;
|
|
std::string icon;
|
|
int sortOrder = -1;
|
|
};
|
|
|
|
struct AddressRowRect {
|
|
float x = 0.0f;
|
|
float y = 0.0f;
|
|
float width = 0.0f;
|
|
float height = 0.0f;
|
|
};
|
|
|
|
struct AddressRowLayout {
|
|
float contentStartX = 0.0f;
|
|
float contentStartY = 0.0f;
|
|
float labelX = 0.0f;
|
|
float contentRight = 0.0f;
|
|
float buttonSize = 0.0f;
|
|
AddressRowRect favoriteButton;
|
|
AddressRowRect visibilityButton;
|
|
};
|
|
|
|
bool AddressListMatchesFilter(const AddressListInput& input, const std::string& filter);
|
|
std::vector<AddressListRow> BuildAddressListRows(const std::vector<AddressListInput>& inputs,
|
|
const std::string& filter,
|
|
bool hideZeroBalances,
|
|
bool showHidden);
|
|
AddressRowLayout ComputeAddressRowLayout(float rowX,
|
|
float rowY,
|
|
float rowWidth,
|
|
float rowHeight,
|
|
float rowPadLeft,
|
|
float rowIconSize,
|
|
float spacingMd,
|
|
float spacingSm,
|
|
float spacingXs);
|
|
std::string FormatAddressUsdValue(double balance, double priceUsd);
|
|
|
|
// ---- Overview address-list clipping (fixed row pitch rowH from startY) ----
|
|
// [begin, end) = the rows intersecting [clipMinY, clipMaxY) plus ONE guard row on each side (a row draws its
|
|
// divider / AA fringe just past its own slot), clamped to [0, rowCount). Non-finite input -> every row.
|
|
struct AddressRowWindow {
|
|
int begin = 0;
|
|
int end = 0;
|
|
};
|
|
AddressRowWindow ComputeAddressRowWindow(float clipMinY, float clipMaxY, float startY, float rowH, int rowCount);
|
|
// Cursor y the unclipped row loop had when row i's body ran: row 0 = startY; row i > 0 = where ImGui::ItemSize
|
|
// (imgui 1.92.6) leaves it after row i-1's InvisibleButton(h = rowH) placed at startY + (i-1)*rowH, i.e.
|
|
// IM_TRUNC(top + rowH + ItemSpacing.y). Replaying it keeps the cursor-dependent Layout::spacing*() exact.
|
|
float AddressRowEntryCursorY(int i, float startY, float rowH, float itemSpacingY);
|
|
|
|
} // namespace ui
|
|
} // namespace dragonx
|