refactor(input): move the channel pill onto the pill widget
The pill was already hand-drawn here -- filled rect, rounding 6, a frozen 3px text offset and an InvisibleButton over the top. That is the Pill widget, built before the widget existed, so it becomes the widget's first consumer. Its text now centres against the measured line height instead of the frozen offset. InputBar.Height moves to Metrics as well. MainWindow and ChannelPopoutWindow both reserve their body height against it, so both follow without changes. It had to happen in the same commit: the pill inside the bar now scales, and a bar that did not would have clipped it at 150%.
This commit is contained in:
@@ -26,9 +26,9 @@ namespace HellionChat.Ui.Components;
|
||||
// the current game-side channel.
|
||||
internal sealed class InputBar
|
||||
{
|
||||
public const float Height = 32f;
|
||||
private const float PillHeight = 22f;
|
||||
private const float PillPaddingX = 8f;
|
||||
// Scaled: MainWindow and ChannelPopoutWindow both reserve against this, so
|
||||
// they follow automatically. The pill's own metrics live in PillStyle now.
|
||||
public static float Height => StyleEngine.Metrics.InputBarHeight;
|
||||
private const int BufferCapacity = 500;
|
||||
private const float QuickButtonsReserve = 130f;
|
||||
|
||||
@@ -257,19 +257,15 @@ internal sealed class InputBar
|
||||
private void DrawChannelPill(Tab? tab, bool isTell, uint pillAbgr, uint textAbgr)
|
||||
{
|
||||
var label = ResolvePillLabel(tab, isTell);
|
||||
var labelSize = ImGui.CalcTextSize(label);
|
||||
var width = labelSize.X + PillPaddingX * 2;
|
||||
var size = StyleEngine.Widgets.Pill.CalcSize(label, withDot: false);
|
||||
var origin = ImGui.GetCursorScreenPos();
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
var max = origin + new Vector2(width, PillHeight);
|
||||
|
||||
dl.AddRectFilled(origin, max, pillAbgr, 6f);
|
||||
dl.AddText(origin + new Vector2(PillPaddingX, 3f), textAbgr, label);
|
||||
StyleEngine.Widgets.Pill.Draw(origin, label, pillAbgr, textAbgr);
|
||||
|
||||
// Hit area over the rendered pill so a click opens the channel
|
||||
// picker. InvisibleButton both reserves the layout slot and gives
|
||||
// the popup a stable anchor item.
|
||||
ImGui.InvisibleButton("##hellion-pill", new Vector2(width, PillHeight));
|
||||
ImGui.InvisibleButton("##hellion-pill", size);
|
||||
if (ImGui.IsItemClicked() && tab is not null)
|
||||
ImGui.OpenPopup("##hellion-channel-picker");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user