Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/Stampeded/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@
<Style Selector="MenuItem">
<Setter Property="ToolTip.ShowOnDisabled" Value="True" />
</Style>
<!-- A scrollbar's thumb in a grey of its own. The Simple theme takes thumb and track from
two neighbouring palette brushes, which the quiet palette above leaves a shade apart -
and its pressed thumb is lighter than the track - so a list did not show that it
scrolls. Translucent, so the one grey stands out on the light track and the dark. -->
<Style Selector="ScrollBar /template/ Thumb#thumb">
<Setter Property="Background" Value="#70808080" />
</Style>
<Style Selector="ScrollBar /template/ Thumb#thumb:pointerover">
<Setter Property="Background" Value="#A0808080" />
</Style>
<Style Selector="ScrollBar /template/ Thumb#thumb:pressed">
<Setter Property="Background" Value="#C8808080" />
</Style>
<Style Selector="OverlayPopupHost">
<Setter Property="RenderTransformOrigin" Value="0%,0%" />
<Setter Property="RenderTransform" Value="{x:Static local:ZoomState.PopupScale}" />
Expand Down
11 changes: 9 additions & 2 deletions src/Stampeded/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,28 @@ public static class Images
// every icon one that lifts that single colour and leaves the coloured parts alone.
const string DarkCss = "[fill=\"#202020\"] { fill: #D4D4D4; } [stroke=\"#202020\"] { stroke: #D4D4D4; }";

// The same rule restating the colour the icons already have. Not null: an SvgImage whose
// stylesheet is cleared falls back to the one its source was last loaded with, so an icon
// that has been dark once would stay light-on-light.
const string LightCss = "[fill=\"#202020\"] { fill: #202020; } [stroke=\"#202020\"] { stroke: #202020; }";

static string ThemeCss => Themes.ThemeManager.Current.IsDarkTheme ? DarkCss : LightCss;

static readonly List<SvgImage> loaded = [];

static Images()
{
Themes.ThemeManager.Current.ThemeChanged += (_, _) => {
foreach (var image in loaded)
image.Css = Themes.ThemeManager.Current.IsDarkTheme ? DarkCss : null;
image.Css = ThemeCss;
};
}

static IImage LoadSvg(string name)
{
var image = new SvgImage {
Source = SvgSource.Load(AssetBase + name + ".svg", null),
Css = Themes.ThemeManager.Current.IsDarkTheme ? DarkCss : null,
Css = ThemeCss,
};
loaded.Add(image);
return image;
Expand Down
5 changes: 5 additions & 0 deletions src/Stampeded/ScreenshotWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ public static void Attach(Window mainWindow)
App.Workspace?.NavigateToFileLineAsync(parts[1], gotoLine, oldSide: false, record: false).HandleExceptions();
}
var size = new Avalonia.PixelSize((int)window.Bounds.Width, (int)window.Bounds.Height);
// A command above may have invalidated layout in this same tick - a theme switch
// does, for every text block. Rendering before the layout pass draws a text block
// built from inlines as empty, and its run cache then keeps the empty result for
// good: the capture would not just show the blank rows, it would cause them.
window.UpdateLayout();
using var bitmap = new RenderTargetBitmap(size, new Avalonia.Vector(96, 96));
bitmap.Render(window);
#pragma warning disable CS0618 // default PNG encoding is all this debug utility needs
Expand Down
Loading