aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/confview.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-06 18:13:51 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-07 07:30:36 +0200
commit317e0df0e466356fd2787aea547e90b3fb1adf08 (patch)
treee7fbbd65401176ea338893ff68ccab1d00e0f350 /ui/confview.go
parentui: confview should be more picky about which tunnel (diff)
downloadwireguard-windows-317e0df0e466356fd2787aea547e90b3fb1adf08.tar.xz
wireguard-windows-317e0df0e466356fd2787aea547e90b3fb1adf08.zip
ui: move things out of iconprovider
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--ui/confview.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/ui/confview.go b/ui/confview.go
index ad5e89b9..518164ca 100644
--- a/ui/confview.go
+++ b/ui/confview.go
@@ -79,11 +79,27 @@ func (lsl *labelStatusLine) widgets() (walk.Widget, walk.Widget) {
}
func (lsl *labelStatusLine) update(state service.TunnelState) {
- labelSize := lsl.label.SizeHint()
- imageRect := walk.Rectangle{0, 0, labelSize.Height, labelSize.Height}
- img, err := iconProvider.ImageForState(state, imageRect)
+ icon, err := iconProvider.IconForState(state)
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()
+ prior := lsl.statusImage.Image()
lsl.statusImage.SetImage(img)
+ if prior != nil {
+ prior.Dispose()
+ }
+ } else {
+ lsl.statusImage.SetImage(nil)
}
s, e := lsl.statusLabel.TextSelection()
switch state {