aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ui/confview.go6
-rw-r--r--ui/iconprovider.go28
2 files changed, 17 insertions, 17 deletions
diff --git a/ui/confview.go b/ui/confview.go
index 09f0111b..6adfdb83 100644
--- a/ui/confview.go
+++ b/ui/confview.go
@@ -16,8 +16,6 @@ import (
"golang.zx2c4.com/wireguard/windows/service"
)
-const statusImageSize = 19
-
type widgetsLine interface {
widgets() (walk.Widget, walk.Widget)
}
@@ -80,7 +78,7 @@ func (lsl *labelStatusLine) widgets() (walk.Widget, walk.Widget) {
}
func (lsl *labelStatusLine) update(state service.TunnelState) {
- img, err := iconProvider.ImageForState(state, walk.Size{statusImageSize, statusImageSize})
+ img, err := iconProvider.ImageForState(state, walk.Rectangle{-4, -4, lsl.label.SizeHint().Height*3/4 + 4, lsl.label.SizeHint().Height*3/4 + 4})
if err == nil {
lsl.statusImage.SetImage(img)
}
@@ -117,6 +115,8 @@ func newLabelStatusLine(parent walk.Container) *labelStatusLine {
lsl.statusComposite.SetLayout(layout)
lsl.statusImage, _ = walk.NewImageView(lsl.statusComposite)
+ lsl.statusImage.SetMode(walk.ImageViewModeIdeal)
+
lsl.statusLabel, _ = walk.NewLineEdit(lsl.statusComposite)
win.SetWindowLong(lsl.statusLabel.Handle(), win.GWL_EXSTYLE, win.GetWindowLong(lsl.statusLabel.Handle(), win.GWL_EXSTYLE)&^win.WS_EX_CLIENTEDGE)
lsl.statusLabel.SetReadOnly(true)
diff --git a/ui/iconprovider.go b/ui/iconprovider.go
index da88e830..56b8cfbc 100644
--- a/ui/iconprovider.go
+++ b/ui/iconprovider.go
@@ -11,14 +11,14 @@ import (
"math"
)
-type sizeAndState struct {
- size walk.Size
+type rectAndState struct {
+ size walk.Rectangle
state service.TunnelState
}
type IconProvider struct {
baseIcon *walk.Icon
- imagesBySizeAndState map[sizeAndState]*walk.Bitmap
+ imagesByRectAndState map[rectAndState]*walk.Bitmap
iconsByState map[service.TunnelState]*walk.Icon
stoppedBrush *walk.SolidColorBrush
startingBrush *walk.SolidColorBrush
@@ -108,7 +108,7 @@ func darkColor(c walk.Color) walk.Color {
func NewIconProvider() (*IconProvider, error) {
tsip := &IconProvider{
- imagesBySizeAndState: make(map[sizeAndState]*walk.Bitmap),
+ imagesByRectAndState: make(map[rectAndState]*walk.Bitmap),
iconsByState: make(map[service.TunnelState]*walk.Icon),
}
@@ -158,11 +158,11 @@ func NewIconProvider() (*IconProvider, error) {
}
func (tsip *IconProvider) Dispose() {
- if tsip.imagesBySizeAndState != nil {
- for _, img := range tsip.imagesBySizeAndState {
+ if tsip.imagesByRectAndState != nil {
+ for _, img := range tsip.imagesByRectAndState {
img.Dispose()
}
- tsip.imagesBySizeAndState = nil
+ tsip.imagesByRectAndState = nil
}
if tsip.iconsByState != nil {
for _, icon := range tsip.iconsByState {
@@ -206,17 +206,17 @@ func (tsip *IconProvider) ImageForTunnel(tunnel *service.Tunnel, size walk.Size)
return nil, err
}
- return tsip.ImageForState(state, size)
+ return tsip.ImageForState(state, walk.Rectangle{0, 0, size.Width, size.Height})
}
-func (tsip *IconProvider) ImageForState(state service.TunnelState, size walk.Size) (*walk.Bitmap, error) {
- key := sizeAndState{size, state}
+func (tsip *IconProvider) ImageForState(state service.TunnelState, rect walk.Rectangle) (*walk.Bitmap, error) {
+ key := rectAndState{rect, state}
- if img, ok := tsip.imagesBySizeAndState[key]; ok {
+ if img, ok := tsip.imagesByRectAndState[key]; ok {
return img, nil
}
- img, err := walk.NewBitmapWithTransparentPixels(size)
+ img, err := walk.NewBitmapWithTransparentPixels(rect.Size())
if err != nil {
return nil, err
}
@@ -227,11 +227,11 @@ func (tsip *IconProvider) ImageForState(state service.TunnelState, size walk.Siz
}
defer canvas.Dispose()
- if err := tsip.PaintForState(state, canvas, walk.Rectangle{0, 0, size.Width, size.Height}); err != nil {
+ if err := tsip.PaintForState(state, canvas, rect); err != nil {
return nil, err
}
- tsip.imagesBySizeAndState[key] = img
+ tsip.imagesByRectAndState[key] = img
return img, nil
}