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.
|
// the current game-side channel.
|
||||||
internal sealed class InputBar
|
internal sealed class InputBar
|
||||||
{
|
{
|
||||||
public const float Height = 32f;
|
// Scaled: MainWindow and ChannelPopoutWindow both reserve against this, so
|
||||||
private const float PillHeight = 22f;
|
// they follow automatically. The pill's own metrics live in PillStyle now.
|
||||||
private const float PillPaddingX = 8f;
|
public static float Height => StyleEngine.Metrics.InputBarHeight;
|
||||||
private const int BufferCapacity = 500;
|
private const int BufferCapacity = 500;
|
||||||
private const float QuickButtonsReserve = 130f;
|
private const float QuickButtonsReserve = 130f;
|
||||||
|
|
||||||
@@ -257,19 +257,15 @@ internal sealed class InputBar
|
|||||||
private void DrawChannelPill(Tab? tab, bool isTell, uint pillAbgr, uint textAbgr)
|
private void DrawChannelPill(Tab? tab, bool isTell, uint pillAbgr, uint textAbgr)
|
||||||
{
|
{
|
||||||
var label = ResolvePillLabel(tab, isTell);
|
var label = ResolvePillLabel(tab, isTell);
|
||||||
var labelSize = ImGui.CalcTextSize(label);
|
var size = StyleEngine.Widgets.Pill.CalcSize(label, withDot: false);
|
||||||
var width = labelSize.X + PillPaddingX * 2;
|
|
||||||
var origin = ImGui.GetCursorScreenPos();
|
var origin = ImGui.GetCursorScreenPos();
|
||||||
var dl = ImGui.GetWindowDrawList();
|
|
||||||
var max = origin + new Vector2(width, PillHeight);
|
|
||||||
|
|
||||||
dl.AddRectFilled(origin, max, pillAbgr, 6f);
|
StyleEngine.Widgets.Pill.Draw(origin, label, pillAbgr, textAbgr);
|
||||||
dl.AddText(origin + new Vector2(PillPaddingX, 3f), textAbgr, label);
|
|
||||||
|
|
||||||
// Hit area over the rendered pill so a click opens the channel
|
// Hit area over the rendered pill so a click opens the channel
|
||||||
// picker. InvisibleButton both reserves the layout slot and gives
|
// picker. InvisibleButton both reserves the layout slot and gives
|
||||||
// the popup a stable anchor item.
|
// 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)
|
if (ImGui.IsItemClicked() && tab is not null)
|
||||||
ImGui.OpenPopup("##hellion-channel-picker");
|
ImGui.OpenPopup("##hellion-channel-picker");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user