client/systray: support several different color themes
Currently we only have a dark theme icon with white and grey dots over a black background. For some desktops, a logo with black and grey dots over a white background might be preferable. And for desktops where the bar is *almost* black or white, but not quite, an option to render the logo with dots only and no background can look really nice. Add a new -theme flag to the systray command with the default staying the same as it is today. Updates #18303 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
+42
-4
@@ -11,6 +11,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"log"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -204,12 +205,49 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
bg = color.NRGBA{0, 0, 0, 255}
|
||||
fg = color.NRGBA{255, 255, 255, 255}
|
||||
gray = color.NRGBA{255, 255, 255, 102}
|
||||
red = color.NRGBA{229, 111, 74, 255}
|
||||
black = color.NRGBA{0, 0, 0, 255}
|
||||
white = color.NRGBA{255, 255, 255, 255}
|
||||
darkGray = color.NRGBA{102, 102, 102, 255}
|
||||
lightGray = color.NRGBA{153, 153, 153, 255}
|
||||
red = color.NRGBA{229, 111, 74, 255}
|
||||
transparent = color.NRGBA{}
|
||||
|
||||
// default values to dark theme
|
||||
bg = black
|
||||
fg = white
|
||||
gray = darkGray
|
||||
)
|
||||
|
||||
// SetTheme sets the color theme of the systray icon.
|
||||
//
|
||||
// Supported themes are:
|
||||
// - dark - white and gray dots over black background
|
||||
// - dark:nobg - white and grey dots over transparent background
|
||||
// - light - black and gray dots over white background
|
||||
// - light:nobg - black and grey dots over transparent background
|
||||
func SetTheme(theme string) {
|
||||
switch theme {
|
||||
case "dark":
|
||||
bg = black
|
||||
fg = white
|
||||
gray = darkGray
|
||||
case "dark:nobg":
|
||||
bg = transparent
|
||||
fg = white
|
||||
gray = darkGray
|
||||
case "light":
|
||||
bg = white
|
||||
fg = black
|
||||
gray = lightGray
|
||||
case "light:nobg":
|
||||
bg = transparent
|
||||
fg = black
|
||||
gray = lightGray
|
||||
default:
|
||||
log.Printf("unknown theme: %q", theme)
|
||||
}
|
||||
}
|
||||
|
||||
// render returns a PNG image of the logo.
|
||||
func (logo tsLogo) render() *bytes.Buffer {
|
||||
const borderUnits = 1
|
||||
|
||||
Reference in New Issue
Block a user