aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/confview.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-08 11:52:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-08 12:16:49 +0200
commit4835f350ffe6b4fa589748e808fb84cc7c53e103 (patch)
treee0a3488aa1447bd741735037a9b347963b428d1d /ui/confview.go
parentinstaller: smarter detection of SYSTEM profile folder (diff)
downloadwireguard-windows-4835f350ffe6b4fa589748e808fb84cc7c53e103.tar.xz
wireguard-windows-4835f350ffe6b4fa589748e808fb84cc7c53e103.zip
ui: get correctly sized system iconsv0.0.1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/confview.go')
-rw-r--r--ui/confview.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/ui/confview.go b/ui/confview.go
index 515cadde..dbbe0ab4 100644
--- a/ui/confview.go
+++ b/ui/confview.go
@@ -79,17 +79,17 @@ func (lsl *labelStatusLine) widgets() (walk.Widget, walk.Widget) {
}
func (lsl *labelStatusLine) update(state service.TunnelState) {
- icon, err := iconProvider.IconForState(state)
+ margin := lsl.label.DPI() / 48 //TODO: Do some sort of dynamic DPI calculation here
+ labelSize := lsl.label.SizeHint()
+ imageRect := walk.Rectangle{0, 0, labelSize.Height, labelSize.Height}
+ img, _ := walk.NewBitmapWithTransparentPixels(imageRect.Size())
+ canvas, _ := walk.NewCanvasFromImage(img)
+ imageRect.X += margin
+ imageRect.Y += margin * 2 //TODO: the *2 here fixes weird alignment bugs. Why?
+ imageRect.Height -= margin * 2
+ imageRect.Width -= margin * 2
+ icon, err := iconForState(state, imageRect.Size().Width)
if err == nil {
- margin := lsl.label.DPI() / 48 //TODO: Do some sort of dynamic DPI calculation here
- labelSize := lsl.label.SizeHint()
- imageRect := walk.Rectangle{0, 0, labelSize.Height, labelSize.Height}
- img, _ := walk.NewBitmapWithTransparentPixels(imageRect.Size())
- canvas, _ := walk.NewCanvasFromImage(img)
- imageRect.X += margin
- imageRect.Y += margin * 2 //TODO: the *2 here fixes weird alignment bugs. Why?
- imageRect.Height -= margin * 2
- imageRect.Width -= margin * 2
canvas.DrawImageStretched(icon, imageRect)
icon.Dispose()
canvas.Dispose()
@@ -99,7 +99,11 @@ func (lsl *labelStatusLine) update(state service.TunnelState) {
prior.Dispose()
}
} else {
+ prior := lsl.statusImage.Image()
lsl.statusImage.SetImage(nil)
+ if prior != nil {
+ prior.Dispose()
+ }
}
s, e := lsl.statusLabel.TextSelection()
switch state {