more tags meow

This commit is contained in:
2025-12-11 16:31:44 +09:00
parent 09b78e1896
commit 0671c46e5d
3 changed files with 58 additions and 67 deletions

View File

@@ -281,7 +281,7 @@ public partial class EditProfileUi : WindowMediatorSubscriberBase
using var panelBorder = ImRaii.PushColor(ImGuiCol.ChildBg, accentBorder);
ImGui.PushStyleVar(ImGuiStyleVar.ChildRounding, 4f * scale);
if (ImGui.BeginChild("##ProfileEditorCanvas", -Vector2.One, true, ImGuiWindowFlags.NoScrollbar))
if (ImGui.BeginChild("##ProfileEditorCanvas", -Vector2.One, true))
{
DrawGuidelinesSection(scale);
ImGui.Dummy(new Vector2(0f, 4f * scale));
@@ -432,30 +432,6 @@ public partial class EditProfileUi : WindowMediatorSubscriberBase
ImGui.PopStyleVar();
}
ImGui.Dummy(new Vector2(0f, 4f * scale));
ImGui.TextColored(UIColors.Get("LightlessBlue"), "Saved Tags");
var savedTags = ProfileTagService.ResolveTags(_profileTagIds);
if (savedTags.Count == 0)
{
ImGui.TextDisabled("-- No tags set --");
}
else
{
bool first = true;
for (int i = 0; i < savedTags.Count; i++)
{
if (!savedTags[i].HasContent)
continue;
if (!first)
ImGui.SameLine(0f, 6f * scale);
first = false;
using (ImRaii.PushId($"snapshot-tag-{i}"))
DrawTagPreview(savedTags[i], scale, "##snapshotTagPreview");
}
if (!first)
ImGui.NewLine();
}
}
private void DrawProfileImageControls(LightlessUserProfileData profile, float scale)
@@ -943,17 +919,6 @@ public partial class EditProfileUi : WindowMediatorSubscriberBase
return _bannerImage.Length > 0 ? Convert.ToBase64String(_bannerImage) : null;
}
private void DrawTagPreview(ProfileTagDefinition tag, float scale, string id)
{
var style = ImGui.GetStyle();
var defaultTextColorU32 = ImGui.GetColorU32(ImGuiCol.Text);
var tagSize = ProfileTagRenderer.MeasureTag(tag, scale, style, _tagBackgroundColor, _tagBorderColor, defaultTextColorU32, _tagPreviewSegments, ResolveIconWrap, _logger);
ImGui.InvisibleButton(id, tagSize);
var rectMin = ImGui.GetItemRectMin();
var drawList = ImGui.GetWindowDrawList();
ProfileTagRenderer.RenderTag(tag, rectMin, scale, drawList, style, _tagBackgroundColor, _tagBorderColor, defaultTextColorU32, _tagPreviewSegments, ResolveIconWrap, _logger);
}
private static bool IsSupportedImageFormat(IImageFormat? format)
{
@@ -1150,12 +1115,18 @@ public partial class EditProfileUi : WindowMediatorSubscriberBase
var drawList = ImGui.GetWindowDrawList();
var textSize = ImGui.CalcTextSize(seString.TextValue);
float minWidth = 160f * ImGuiHelpers.GlobalScale;
float bgWidth = Math.Max(textSize.X + 20f * ImGuiHelpers.GlobalScale, minWidth);
float paddingY = 5f * ImGuiHelpers.GlobalScale;
float paddingX = 10f * ImGuiHelpers.GlobalScale;
float bgWidth = Math.Max(textSize.X + paddingX * 2f, minWidth);
var style = ImGui.GetStyle();
var fontHeight = monoFont.FontSize > 0f ? monoFont.FontSize : ImGui.GetFontSize();
float frameHeight = fontHeight + style.FramePadding.Y * 2f;
float textBlockHeight = MathF.Max(frameHeight, textSize.Y);
var cursor = ImGui.GetCursorScreenPos();
var rectMin = cursor;
var rectMax = rectMin + new Vector2(bgWidth, textSize.Y + paddingY * 2f);
var rectMax = rectMin + new Vector2(bgWidth, textBlockHeight + paddingY * 2f);
float boost = Luminance.ComputeHighlight(previewTextColor, previewGlowColor);
@@ -1166,8 +1137,8 @@ public partial class EditProfileUi : WindowMediatorSubscriberBase
drawList.AddRectFilled(rectMin, rectMax, ImGui.GetColorU32(bgColor), 5f);
drawList.AddRect(rectMin, rectMax, ImGui.GetColorU32(borderColor), 5f, ImDrawFlags.None, 1.2f);
var textPos = new Vector2(rectMin.X + (bgWidth - textSize.X) * 0.5f, rectMin.Y + paddingY);
SeStringUtils.RenderSeStringWithHitbox(seString, textPos, monoFont);
var textOrigin = new Vector2(rectMin.X + (bgWidth - textSize.X) * 0.5f, rectMin.Y + paddingY);
SeStringUtils.RenderSeStringWithHitbox(seString, textOrigin, monoFont);
ImGui.Dummy(new Vector2(0f, 1.5f));
}