Bar icon dropdown: barMenu on plugin windows (API v95) #13
1 changed files with 8 additions and 8 deletions
Bar menu: place each icon at the parent's left edge
A pixel scan of the owner's screenshots showed the applied inset is the pushed 4 * s padding after all (+6 px before centring, -1 px after); the residual pixel is ImGui truncating the window position. Drop the measured inset and set each icon's x to the intended position (parent's left edge, or the clamped spot) before drawing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
82c5ec8aeb
|
|
@ -80,10 +80,7 @@ internal static class ImGuiBar
|
|||
// dropdown", the menu-bearing buttons' rects this frame, and when the timer was last fed (a gap
|
||||
// means the bar wasn't drawn: start from a closed dropdown).
|
||||
private static readonly BarMenuHover _menuHover = new();
|
||||
private static bool _overMenu;
|
||||
// The menu window's measured left inset (first icon x minus window x); -1 until measured. AC thread.
|
||||
private static float _menuInsetX = -1f;
|
||||
private static readonly List<(ButtonInfo Button, Vector2 Min, Vector2 Max)> _menuRects = new();
|
||||
private static bool _overMenu; private static readonly List<(ButtonInfo Button, Vector2 Min, Vector2 Max)> _menuRects = new();
|
||||
private const ImGuiWindowFlags MenuFlags = ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.AlwaysAutoResize
|
||||
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoDocking
|
||||
| ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav;
|
||||
|
|
@ -585,9 +582,7 @@ internal static class ImGuiBar
|
|||
|
||||
UI.Sections.SectionBarMenuItem[] items = owner.Menu;
|
||||
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
|
||||
// Where the menu's first icon starts inside its window, as last measured (the window padding
|
||||
// as ImGui actually applied it); 4 * s, the padding asked for, until the first measure.
|
||||
float inset = _menuInsetX >= 0f ? _menuInsetX : 4f * s;
|
||||
float inset = 4f * s; // WindowPadding (4, 3)
|
||||
float width = square.X + 2f * inset;
|
||||
float height = items.Length * square.Y + (items.Length - 1) * ButtonGap * s + 6f * s;
|
||||
float x = min.X - inset, y = max.Y; // icons straight under the parent
|
||||
|
|
@ -609,10 +604,15 @@ internal static class ImGuiBar
|
|||
// NoFocusOnAppearing leaves a re-shown menu behind a panel focused since: lift it
|
||||
// every frame (no focus change, so another window's text edit stays active).
|
||||
MenuToFront();
|
||||
_menuInsetX = ImGuiNET.ImGui.GetCursorScreenPos().X - ImGuiNET.ImGui.GetWindowPos().X;
|
||||
_overMenu = ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
||||
// ImGui truncates the window's position, which can leave the icons up to a pixel left of
|
||||
// the parent; put each one exactly where the placement meant (the parent's left edge
|
||||
// unless the viewport clamp moved the window). Each new line starts back at the window's
|
||||
// own content edge, so this is set per icon.
|
||||
float iconX = x + inset;
|
||||
foreach (UI.Sections.SectionBarMenuItem item in items)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(iconX, ImGuiNET.ImGui.GetCursorScreenPos().Y));
|
||||
bool letter = item.Icon.Length == 0;
|
||||
string glyph = letter ? FirstLetter(item.Tooltip) : item.Icon;
|
||||
if (IconButton(owner.Id + "_m_" + item.Id, letter ? letterFont : iconFont, glyph, square, RynthTheme.BarText))
|
||||
|
|
|
|||
Loading…
Reference in a new issue