MirrorBar Plus 11: clock font, more colors and logo shapes, charging color, emoji button
Clock font picker (16 fonts), 8 more bar colors, 8 more logo/tray/clock colors, 6 new Windows logo shapes, battery charging color picker, and an emoji panel button (Win+.) on the bar with a show/hide tickbox and right-click item. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JW57Zw8fvgzpeDkbUYT7sG
This commit is contained in:
@@ -10,9 +10,13 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var pRoundRect = gdi32.NewProc("RoundRect")
|
||||
var (
|
||||
pRoundRect = gdi32.NewProc("RoundRect")
|
||||
pGetTextExtentW = gdi32.NewProc("GetTextExtentPoint32W")
|
||||
)
|
||||
|
||||
// ---------- the color of the bar ----------
|
||||
|
||||
@@ -31,6 +35,14 @@ var barPalette = []barColor{
|
||||
{"Navy", 16, 36, 92},
|
||||
{"Purple", 72, 38, 112},
|
||||
{"Gray", 92, 92, 100},
|
||||
{"Charcoal", 44, 44, 50},
|
||||
{"Slate", 52, 64, 80},
|
||||
{"Burgundy", 92, 24, 40},
|
||||
{"Forest", 30, 56, 30},
|
||||
{"Brown", 84, 52, 30},
|
||||
{"Teal", 16, 82, 86},
|
||||
{"Olive", 74, 80, 32},
|
||||
{"Midnight", 10, 14, 40},
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -38,6 +50,10 @@ var (
|
||||
logoStyle = 0
|
||||
clockSizeIx = 0
|
||||
clockBold = false
|
||||
clockFontIx = 0
|
||||
chargeIx = 0
|
||||
|
||||
clockMeasured int32 // the width the time and date need in a font other than Segoe UI
|
||||
)
|
||||
|
||||
var logoStyleNames = []string{
|
||||
@@ -48,6 +64,63 @@ var logoStyleNames = []string{
|
||||
"Tilted left",
|
||||
"Diamonds",
|
||||
"Waving flag",
|
||||
"Single circle",
|
||||
"Hexagon",
|
||||
"Plus sign",
|
||||
"Three bars",
|
||||
"Pills",
|
||||
"Triangle",
|
||||
}
|
||||
|
||||
// The clock fonts. New ones go on the end so a saved choice keeps meaning the same font.
|
||||
// A font that is not installed on this PC quietly shows as a default font.
|
||||
var clockFonts = []string{
|
||||
"Segoe UI",
|
||||
"Tahoma",
|
||||
"Verdana",
|
||||
"Arial",
|
||||
"Calibri",
|
||||
"Cambria",
|
||||
"Consolas",
|
||||
"Cascadia Mono",
|
||||
"Courier New",
|
||||
"Georgia",
|
||||
"Trebuchet MS",
|
||||
"Bahnschrift",
|
||||
"Tw Cen MT",
|
||||
"Segoe Script",
|
||||
"Impact",
|
||||
"Comic Sans MS",
|
||||
}
|
||||
|
||||
// The color of the filled part of the battery icon while it charges. New ones go on the end.
|
||||
type chargeChoice struct {
|
||||
name string
|
||||
r, g, b int
|
||||
}
|
||||
|
||||
var chargeColors = []chargeChoice{
|
||||
{"Bright green (default)", 90, 205, 120},
|
||||
{"Soft green", 105, 165, 120},
|
||||
{"Dark green", 40, 115, 70},
|
||||
{"Muted teal", 80, 145, 150},
|
||||
{"Slate blue", 110, 135, 170},
|
||||
{"Dim gold", 190, 160, 80},
|
||||
{"Gray", 150, 150, 158},
|
||||
{"Same as the icon color", -1, -1, -1},
|
||||
}
|
||||
|
||||
// chargeColor is the fill color of the battery icon while it is charging or plugged in.
|
||||
func chargeColor() uintptr {
|
||||
i := chargeIx
|
||||
if i < 0 || i >= len(chargeColors) {
|
||||
i = 0
|
||||
}
|
||||
c := chargeColors[i]
|
||||
if c.r < 0 {
|
||||
return iconColor()
|
||||
}
|
||||
return rgb(c.r, c.g, c.b)
|
||||
}
|
||||
|
||||
type clockSizeChoice struct {
|
||||
@@ -102,6 +175,9 @@ func clockPx() int {
|
||||
|
||||
// clockWidth is the room the time and date need, which grows with the text.
|
||||
func clockWidth() int32 {
|
||||
if clockFontIx > 0 && clockMeasured > 0 {
|
||||
return clockMeasured + px(24)
|
||||
}
|
||||
w := 140.0 * float64(clockPx()) / 13.0
|
||||
if clockBold {
|
||||
w *= 1.08
|
||||
@@ -116,11 +192,16 @@ func rebuildClockFonts() {
|
||||
if clockBold {
|
||||
weight = 700
|
||||
}
|
||||
face := clockFonts[0]
|
||||
if clockFontIx > 0 && clockFontIx < len(clockFonts) {
|
||||
face = clockFonts[clockFontIx]
|
||||
}
|
||||
oldA, oldB := fontTime, fontTime2
|
||||
fontTime = makeFont(px(float64(clockPx())), weight)
|
||||
fontTime = makeFontFace(face, px(float64(clockPx())), weight)
|
||||
scale *= superSample
|
||||
fontTime2 = makeFont(px(float64(clockPx())), weight)
|
||||
fontTime2 = makeFontFace(face, px(float64(clockPx())), weight)
|
||||
scale /= superSample
|
||||
clockMeasured = measureClockText()
|
||||
if oldA != 0 {
|
||||
pDeleteObject.Call(oldA)
|
||||
}
|
||||
@@ -129,6 +210,21 @@ func rebuildClockFonts() {
|
||||
}
|
||||
}
|
||||
|
||||
// measureClockText is how wide the longest time and date are in the clock font, in real pixels.
|
||||
func measureClockText() int32 {
|
||||
hdc, _, _ := pGetDC.Call(0)
|
||||
if hdc == 0 {
|
||||
return 0
|
||||
}
|
||||
old, _, _ := pSelectObject.Call(hdc, fontTime)
|
||||
var sz struct{ cx, cy int32 }
|
||||
sample := "12:59 PM 12/30/2026"
|
||||
pGetTextExtentW.Call(hdc, uintptr(unsafe.Pointer(u16(sample))), uintptr(len(sample)), uintptr(unsafe.Pointer(&sz)))
|
||||
pSelectObject.Call(hdc, old)
|
||||
pReleaseDC.Call(0, hdc)
|
||||
return sz.cx
|
||||
}
|
||||
|
||||
// ---------- remembering the choices ----------
|
||||
|
||||
func lookFile() string { return filepath.Join(dataDir(), "look.txt") }
|
||||
@@ -162,6 +258,14 @@ func loadLook() {
|
||||
}
|
||||
case "clockbold":
|
||||
clockBold = n != 0
|
||||
case "clockfont":
|
||||
if n >= 0 && n < len(clockFonts) {
|
||||
clockFontIx = n
|
||||
}
|
||||
case "chargecolor":
|
||||
if n >= 0 && n < len(chargeColors) {
|
||||
chargeIx = n
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +274,9 @@ func saveLook() {
|
||||
s := "barcolor=" + strconv.Itoa(barIdx) +
|
||||
"\nlogostyle=" + strconv.Itoa(logoStyle) +
|
||||
"\nclocksize=" + strconv.Itoa(clockSizeIx) +
|
||||
"\nclockbold=" + b01(clockBold) + "\n"
|
||||
"\nclockbold=" + b01(clockBold) +
|
||||
"\nclockfont=" + strconv.Itoa(clockFontIx) +
|
||||
"\nchargecolor=" + strconv.Itoa(chargeIx) + "\n"
|
||||
_ = os.MkdirAll(dataDir(), 0o755)
|
||||
_ = os.WriteFile(lookFile(), []byte(s), 0o644)
|
||||
}
|
||||
@@ -215,6 +321,34 @@ func setClockBold(on bool) {
|
||||
positionBar(hwndMain)
|
||||
}
|
||||
|
||||
func setClockFont(i int) {
|
||||
if i < 0 || i >= len(clockFonts) || i == clockFontIx {
|
||||
return
|
||||
}
|
||||
clockFontIx = i
|
||||
rebuildClockFonts()
|
||||
saveLook()
|
||||
positionBar(hwndMain)
|
||||
}
|
||||
|
||||
func setChargeColor(i int) {
|
||||
if i < 0 || i >= len(chargeColors) || i == chargeIx {
|
||||
return
|
||||
}
|
||||
chargeIx = i
|
||||
saveLook()
|
||||
redraw(hwndMain)
|
||||
}
|
||||
|
||||
func setShowEmoji(on bool) {
|
||||
if showEmoji == on {
|
||||
return
|
||||
}
|
||||
showEmoji = on
|
||||
saveFeatures()
|
||||
positionBar(hwndMain)
|
||||
}
|
||||
|
||||
func setShowBattery(on bool) {
|
||||
if showBattery == on {
|
||||
return
|
||||
@@ -321,5 +455,30 @@ func drawLogoStyle(hdc uintptr, r rect) {
|
||||
for _, f := range offs {
|
||||
polygon(hdc, pane(f[0], f[1], wave), c)
|
||||
}
|
||||
case 7: // single circle
|
||||
circleRaw(hdc, cx, cy, px(9), c)
|
||||
case 8: // hexagon
|
||||
pts := make([]point, 6)
|
||||
for k := range pts {
|
||||
a := (float64(k)*60 - 30) * math.Pi / 180
|
||||
pts[k] = point{cx + int32(math.Round(float64(px(10))*math.Cos(a))), cy + int32(math.Round(float64(px(10))*math.Sin(a)))}
|
||||
}
|
||||
polygon(hdc, pts, c)
|
||||
case 9: // plus sign
|
||||
l, t := px(10), px(3)
|
||||
fillRaw(hdc, rect{cx - l, cy - t, cx + l, cy + t}, c)
|
||||
fillRaw(hdc, rect{cx - t, cy - l, cx + t, cy + l}, c)
|
||||
case 10: // three bars
|
||||
for _, dy := range []int32{-px(6), 0, px(6)} {
|
||||
fillRaw(hdc, rect{cx - px(9), cy + dy - px(1.5), cx + px(9), cy + dy + px(1.5)}, c)
|
||||
}
|
||||
case 11: // pills, two by two
|
||||
for _, ox := range []int32{-px(10), px(1)} {
|
||||
for _, oy := range []int32{-px(7), px(1)} {
|
||||
roundRectRaw(hdc, cx+ox, cy+oy, cx+ox+px(9), cy+oy+px(6), px(3), c)
|
||||
}
|
||||
}
|
||||
case 12: // triangle
|
||||
polygon(hdc, []point{{cx, cy - px(9)}, {cx + px(10), cy + px(8)}, {cx - px(10), cy + px(8)}}, c)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user