Make patreon call to action look nicer

pull/81/head
lawl 3 years ago
parent 595b8ab9b4
commit d8be27d86e

3
.gitignore vendored

@ -1,4 +1,5 @@
bin/
librnnoise.go
version.go
licenses.go
licenses.go
patreon.go

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

@ -19,7 +19,8 @@ import (
"github.com/aarzilli/nucular/style"
)
//go:generate go run scripts/embedlibrnnoise.go
//go:generate go run scripts/embedbinary.go librnnoise_ladspa/bin/ladspa/librnnoise_ladspa.so librnnoise.go libRNNoise
//go:generate go run scripts/embedbinary.go assets/patreon.png patreon.go patreonPNG
//go:generate go run scripts/embedversion.go
//go:generate go run scripts/embedlicenses.go

@ -1,6 +1,7 @@
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
@ -8,15 +9,17 @@ import (
)
func main() {
b, err := ioutil.ReadFile("librnnoise_ladspa/bin/ladspa/librnnoise_ladspa.so")
flag.Parse()
args := flag.Args()
b, err := ioutil.ReadFile(args[0])
if err != nil {
fmt.Printf("Couldn't read librnnoise_ladspa.so: %v\n", err)
fmt.Printf("Couldn't read '%s': %v\n", args[0], err)
os.Exit(1)
}
out, _ := os.Create("librnnoise.go")
out, _ := os.Create(args[1])
defer out.Close()
out.Write([]byte("package main \n\n//THIS FILE IS AUTOMATICALLY GENERATED BY `go generate` DO NOT EDIT!\n\nvar libRNNoise = []byte{\n"))
out.Write([]byte("package main \n\n//THIS FILE IS AUTOMATICALLY GENERATED BY `go generate` DO NOT EDIT!\n\nvar " + args[2] + " = []byte{\n"))
for i, c := range b {
out.Write([]byte(strconv.Itoa(int(c))))
out.Write([]byte(","))

44
ui.go

@ -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)
}

Loading…
Cancel
Save