diff options
author | lawl <github@dumbinter.net> | 2020-12-13 06:28:00 +0100 |
---|---|---|
committer | lawl <github@dumbinter.net> | 2020-12-13 06:28:00 +0100 |
commit | d8be27d86e8c8068f08b7e7cef8a2f255b1714fd (patch) | |
tree | b071985bd96c0dd4719a339e37813ab58e683b0e /ui.go | |
parent | 595b8ab9b4feaa3f4eb1bb5064737c7b2ce13473 (diff) | |
download | noisetorch-d8be27d86e8c8068f08b7e7cef8a2f255b1714fd.tar.gz noisetorch-d8be27d86e8c8068f08b7e7cef8a2f255b1714fd.zip |
Make patreon call to action look nicer
Diffstat (limited to 'ui.go')
-rw-r--r-- | ui.go | 44 |
1 files changed, 38 insertions, 6 deletions
@@ -1,8 +1,12 @@ package main import ( + "bytes" "fmt" + "image" "image/color" + "image/draw" + "image/png" "log" "os/exec" "time" @@ -33,6 +37,8 @@ var green = color.RGBA{34, 187, 69, 255} var red = color.RGBA{255, 70, 70, 255} var orange = color.RGBA{255, 140, 0, 255} +var patreonImg *image.RGBA + func updatefn(ctx *ntcontext, w *nucular.Window) { if !ctx.paClient.Connected() { @@ -57,7 +63,7 @@ func updatefn(ctx *ntcontext, w *nucular.Window) { w.MenubarBegin() - w.Row(10).Dynamic(2) + w.Row(10).Dynamic(1) if w := w.Menu(label.TA("About", "LC"), 120, nil); w != nil { w.Row(10).Dynamic(1) if w.MenuItem(label.T("Licenses")) { @@ -71,13 +77,17 @@ func updatefn(ctx *ntcontext, w *nucular.Window) { ctx.versionScreen = true } } - if w := w.Menu(label.TA("Support NoiseTorch on PATREON", "RC"), 120, nil); w != nil { - exec.Command("xdg-open", "https://patreon.com/lawl").Run() - w.Close() - } + w.MenubarEnd() - w.Row(15).Dynamic(1) + w.Row(25).Dynamic(2) + if patreonImg == nil { + patreonImg = loadPatreonImg() + } + + if imageButton(w, patreonImg) { + exec.Command("xdg-open", "https://patreon.com/lawl").Run() + } if ctx.noiseSupressorState == loaded { w.LabelColored("NoiseTorch active", "RC", green) @@ -284,3 +294,25 @@ func resetUI(ctx *ntcontext) { (*ctx.masterWindow).Changed() } } + +func loadPatreonImg() *image.RGBA { + var pat *image.RGBA + img, _ := png.Decode(bytes.NewReader(patreonPNG)) + pat = image.NewRGBA(img.Bounds()) + draw.Draw(pat, img.Bounds(), img, image.Point{}, draw.Src) + return pat +} + +func imageButton(w *nucular.Window, img *image.RGBA) bool { + style := w.Master().Style() + origButtonStyle := style.Button + style.Button.Border = 0 + style.Button.Normal.Data.Color = style.NormalWindow.Background + style.Button.Hover.Data.Color = style.NormalWindow.Background + style.Button.Active.Data.Color = style.NormalWindow.Background + + defer (func() { style.Button = origButtonStyle })() + + return w.Button(label.I(patreonImg), false) + +} |