Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ThemeProvider.ImGui/ImGuiPaletteMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public IReadOnlyDictionary<ImGuiCol, Vector4> MapTheme(ISemanticTheme theme)
// Striped rows hold input frames, which are drawn in FrameBg with no border by default. A
// translucent stripe lands between the row and frame colors, so a frame in an odd row stays visible.
{ ImGuiCol.TableRowBgAlt, 0.50f },
// The overline marks the focused window's selected tab, so an unfocused window's selected tab
// draws none, as in ImGui's stock styles. Drawing it in both made every dock node look focused.
{ ImGuiCol.TabDimmedSelectedOverline, 0f },
};

// Convert the semantic colors to ImGui Vector4 format
Expand Down
20 changes: 20 additions & 0 deletions ThemeProvider.Test/ImGuiPaletteMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ public void MapTheme_SelectedTabsDifferFromTheirTabBar()
}
}

/// <summary>
/// ImGui draws TabSelectedOverline on the focused window's selected tab and TabDimmedSelectedOverline on
/// every unfocused one's. The overline is the cue for which window has focus, so only the focused one may
/// show it: the dimmed overline is transparent, as in ImGui's stock styles.
/// </summary>
[TestMethod]
public void MapTheme_OnlyTheFocusedSelectedTabHasAnOverline()
{
ImGuiPaletteMapper mapper = new();

foreach (ThemeRegistry.ThemeInfo info in ThemeRegistry.AllThemes)
{
IReadOnlyDictionary<ImGuiCol, Vector4> palette = mapper.MapTheme(info.CreateInstance());

Assert.AreEqual(1f, palette[ImGuiCol.TabSelectedOverline].W, $"{info.Name}: the focused tab's overline is not opaque");
Assert.AreEqual(0f, palette[ImGuiCol.TabDimmedSelectedOverline].W, $"{info.Name}: an unfocused window's selected tab draws an overline");
AssertDistinct(palette, ImGuiCol.TabDimmedSelectedOverline, ImGuiCol.TabSelectedOverline, info.Name);
}
}

private static void AssertDistinct(IReadOnlyDictionary<ImGuiCol, Vector4> palette, ImGuiCol first, ImGuiCol second, string themeName) =>
Assert.IsGreaterThan(1f / 255f, Vector4.Distance(palette[first], palette[second]), $"{themeName}: {first} is drawn in the {second} color");

Expand Down
Loading