MirrorBar+ part 1: weather radar, outline color, show/hide switches, README
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# MirrorBar
|
||||
# MirrorBar+
|
||||
|
||||
A small Windows 11 taskbar replacement, one exe, no installer, no dependencies.
|
||||
MirrorBar+ is a small Windows 11 taskbar replacement, one exe, no installer, no dependencies.
|
||||
|
||||
The real taskbar is hidden and a see-through pill takes its place. The pill is a mirror image around its center line. To the left of center is the Start button, with your open apps as small icon-only buttons stretching further left. To the right of center is the clock (time and date on one line), then a little storm cloud for the weather, battery, volume, wifi and the ^ hidden-icons arrow stretching further right.
|
||||
The real taskbar is hidden and a see-through pill takes its place. The pill is a mirror image around its center line. To the left of center is the Start button, with your open apps as small icon-only buttons stretching further left. To the right of center is the clock (time and date on one line), then a little sun-and-cloud for the weather, a little newspaper for local news, a little monitor for system stats, battery, volume, wifi and the ^ hidden-icons arrow stretching further right.
|
||||
|
||||
## What it does
|
||||
|
||||
@@ -17,9 +17,15 @@ The real taskbar is hidden and a see-through pill takes its place. The pill is a
|
||||
- Right-click an app icon and choose "Pin to MirrorBar" to keep it on the bar. A pinned app that isn't running shows as a launcher: click it to start the program, and when its window opens it takes that spot. Pinning works for normal programs; Store apps can't be pinned.
|
||||
- "Open notification center" is in the right-click menu.
|
||||
- Drag files from Explorer onto an app icon and that program opens them, running or pinned.
|
||||
- "MirrorBar settings..." in the right-click menu opens one window for background opacity, the three colors, icon style, the weather ZIP code, vertical mode, start with Windows, and resetting the position and width. Changes apply as you make them.
|
||||
- "MirrorBar settings..." in the right-click menu opens one window for background opacity, the three colors, icon style, the ZIP code, tickboxes to show or hide the weather, the local news and the system stats, vertical mode, start with Windows, and resetting the position and width. Changes apply as you make them.
|
||||
- Smooth, outline-free icons and text, even when the pill is see-through.
|
||||
- Click the storm cloud and a weather panel opens above the bar: the temperature in Fahrenheit, what it feels like, the high and low, humidity, wind, chance of rain, sunrise, sunset, UV index, the moon phase, and the next five days. Click the cloud again, or click anywhere else, and it closes. It needs a ZIP code: type it in "MirrorBar settings..." (a 5 digit US ZIP code) and the weather turns on at once. The forecast comes from Open-Meteo (open-meteo.com, free, no account), and MirrorBar only goes to the internet when a ZIP code is set. The cloud can be dragged along the right row like the other icons.
|
||||
- Click the storm cloud and a weather panel opens above the bar: the temperature in Fahrenheit, what it feels like, the high and low, humidity, wind, chance of rain, sunrise, sunset, UV index, the moon phase, a looping radar picture of the last hour or so centered on your ZIP code, and the next five days. Click the cloud again, or click anywhere else, and it closes. It needs a ZIP code: type it in "MirrorBar settings..." (a 5 digit US ZIP code) and the weather turns on at once. The forecast comes from Open-Meteo (open-meteo.com, free, no account), the radar map comes from RainViewer and Esri and is only downloaded when you open the panel, and MirrorBar only goes to the internet when a ZIP code is set. The cloud can be dragged along the right row like the other icons.
|
||||
|
||||
- Click the newspaper and a panel of local headlines opens above the bar, newest first, with the outlet and how long ago each ran. Click a headline and it opens in your default browser. It uses the same ZIP code as the weather: the ZIP code is turned into a town name and the headlines are Google News' feed for that town, so someone in 43220 gets Columbus stations and papers and someone in 46750 gets Fort Wayne and Huntington ones. The headlines are only downloaded when a ZIP code is set. Small towns have fewer stories than cities.
|
||||
|
||||
- "Show weather on the bar" and "Show local news on the bar" in the settings window turn either feature off. The icon leaves the bar and nothing is downloaded for it; tick the box again and it comes back.
|
||||
|
||||
- Click the little monitor and a panel opens with the usual neofetch information: OS, host, kernel, uptime, resolution, CPU, GPU, memory, each fixed disk, battery and local IP. Click any line to copy it to the clipboard, or click the top of the panel to copy everything as plain text you can paste into other programs. Nothing leaves your PC; it is all read from Windows.
|
||||
- Pick the color of the Windows logo, the clock, and the battery/volume/wifi/arrow icons from the right-click menu (white, blue, sky blue, green, yellow, orange, red, pink, purple, black).
|
||||
- "Icon style" in the right-click menu: colorized or grayscale. It applies to the app icons and to the logo, clock and tray icons.
|
||||
- Background see-through level: Clear, Light, Medium or Solid.
|
||||
@@ -36,7 +42,7 @@ The real taskbar is hidden and a see-through pill takes its place. The pill is a
|
||||
|
||||
## Download
|
||||
|
||||
Grab `mirrorbar.zip` from the Releases page. If Windows shows a "protected your PC" warning, right-click the zip, choose Properties, check Unblock, and unzip it after that.
|
||||
Grab `MirrorBarPlus.zip` from the Releases page. If Windows shows a "protected your PC" warning, right-click the zip, choose Properties, check Unblock, and unzip it after that.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -47,3 +53,4 @@ GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-H=windowsgui -s -w"
|
||||
```
|
||||
|
||||
Settings are kept in `%LOCALAPPDATA%\MirrorBar`.
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@ var (
|
||||
const (
|
||||
wxLayoutW = 340.0 // panel width, in 96 dpi units
|
||||
wxFullH = 428.0 // panel height when there is a forecast to show
|
||||
wxRadarH = 158.0 // extra height when the radar picture fits on the screen
|
||||
wxShortH = 150.0 // panel height for the "add a ZIP code" and error messages
|
||||
|
||||
wxPollTimerID = 1
|
||||
wxAnimTimerID = 2
|
||||
vkRButton = 0x02
|
||||
srcCopy = 0x00CC0020
|
||||
halftone = 4
|
||||
@@ -42,7 +44,9 @@ var (
|
||||
wxPrevBtn bool // a mouse button was down at the last look
|
||||
|
||||
wxFontsMade bool
|
||||
fBig, fMed, fText, fBold, fSmall uintptr
|
||||
fBig, fMed, fText, fBold, fSmall, fTiny uintptr
|
||||
|
||||
rdHold int // how many beats the newest radar frame has been held for
|
||||
)
|
||||
|
||||
// ---------- the button on the bar ----------
|
||||
@@ -125,6 +129,10 @@ func weatherProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
wxPaint(hwnd)
|
||||
return 0
|
||||
case wmTimer:
|
||||
if wparam == wxAnimTimerID {
|
||||
radarAdvance()
|
||||
return 0
|
||||
}
|
||||
weatherPoll()
|
||||
return 0
|
||||
case wmLButtonUp:
|
||||
@@ -141,15 +149,19 @@ func weatherToggle() {
|
||||
weatherHide()
|
||||
return
|
||||
}
|
||||
if wxHwnd == 0 {
|
||||
if wxHwnd == 0 || !showWeather {
|
||||
return
|
||||
}
|
||||
previewHide()
|
||||
newsHide() // one panel at a time
|
||||
sysHide()
|
||||
weatherRefresh(false)
|
||||
wxShown = true
|
||||
wxPrevBtn = true // ignore a button that is still held from the click that opened this
|
||||
weatherPlace()
|
||||
pSetTimer.Call(wxHwnd, wxPollTimerID, 80, 0)
|
||||
pSetTimer.Call(wxHwnd, wxAnimTimerID, 450, 0)
|
||||
radarEnsure(false)
|
||||
}
|
||||
|
||||
func weatherHide() {
|
||||
@@ -158,6 +170,7 @@ func weatherHide() {
|
||||
}
|
||||
wxShown = false
|
||||
pKillTimer.Call(wxHwnd, wxPollTimerID)
|
||||
pKillTimer.Call(wxHwnd, wxAnimTimerID)
|
||||
pShowWindow.Call(wxHwnd, swHide)
|
||||
}
|
||||
|
||||
@@ -170,21 +183,7 @@ func weatherShutdown() {
|
||||
}
|
||||
|
||||
// weatherAnchor is where the cloud sits on the screen.
|
||||
func weatherAnchor() rect {
|
||||
var wr rect
|
||||
pGetWindowRect.Call(hwndMain, uintptr(unsafe.Pointer(&wr)))
|
||||
w, h := clientSize(hwndMain)
|
||||
for _, it := range trayItems(w, h) {
|
||||
if it.kind == trayWeather {
|
||||
r := it.r
|
||||
if vertical {
|
||||
r = mapRect(r, h)
|
||||
}
|
||||
return rect{wr.Left + r.Left, wr.Top + r.Top, wr.Left + r.Right, wr.Top + r.Bottom}
|
||||
}
|
||||
}
|
||||
return wr
|
||||
}
|
||||
func weatherAnchor() rect { return trayAnchor(trayWeather) }
|
||||
|
||||
// weatherPlace sizes the panel for what it has to show and puts it next to the
|
||||
// cloud: above a horizontal bar, to the left of a vertical one.
|
||||
@@ -196,6 +195,9 @@ func weatherPlace() {
|
||||
lh := wxShortH
|
||||
if s.ok && wxZip != "" {
|
||||
lh = wxFullH
|
||||
if wxRadarFits() {
|
||||
lh += wxRadarH
|
||||
}
|
||||
}
|
||||
cw, ch := px(wxLayoutW), px(lh)
|
||||
|
||||
@@ -257,8 +259,10 @@ func weatherClick() {
|
||||
|
||||
// weatherDone runs when a lookup finishes.
|
||||
func weatherDone() {
|
||||
newsDone()
|
||||
if wxShown {
|
||||
weatherPlace()
|
||||
radarEnsure(false)
|
||||
}
|
||||
settingsZipStatusUpdate()
|
||||
}
|
||||
@@ -292,10 +296,15 @@ func wxMakeFonts() {
|
||||
fText = makeFont(px(13), 400)
|
||||
fBold = makeFont(px(13), 600)
|
||||
fSmall = makeFont(px(11), 400)
|
||||
fTiny = makeFont(px(9), 400)
|
||||
wxFontsMade = true
|
||||
}
|
||||
|
||||
func wxPaint(hwnd uintptr) {
|
||||
func wxPaint(hwnd uintptr) { flyPaint(hwnd, wxDraw) }
|
||||
|
||||
// flyPaint paints a panel at double size into a memory bitmap with the given
|
||||
// drawing function, then shrinks it onto the window.
|
||||
func flyPaint(hwnd uintptr, draw func(hdc uintptr, W, H int32)) {
|
||||
var ps paintStruct
|
||||
hdc, _, _ := pBeginPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps)))
|
||||
defer pEndPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps)))
|
||||
@@ -325,7 +334,7 @@ func wxPaint(hwnd uintptr) {
|
||||
defer func() { scale = saved }()
|
||||
scale *= ss
|
||||
wxMakeFonts()
|
||||
wxDraw(mem, W*ss, H*ss)
|
||||
draw(mem, W*ss, H*ss)
|
||||
scale = saved
|
||||
|
||||
pSetStretchBltMode.Call(hdc, halftone)
|
||||
@@ -335,7 +344,6 @@ func wxPaint(hwnd uintptr) {
|
||||
|
||||
var (
|
||||
colBack = rgb(28, 28, 34)
|
||||
colEdge = rgb(78, 78, 92)
|
||||
colRule = rgb(52, 52, 62)
|
||||
colText = rgb(240, 240, 245)
|
||||
colDim = rgb(150, 150, 165)
|
||||
@@ -354,7 +362,7 @@ func wxText(hdc uintptr, s string, r rect, font, col, flags uintptr) {
|
||||
// here is a double size distance.
|
||||
func wxDraw(hdc uintptr, W, H int32) {
|
||||
u := px
|
||||
fillRaw(hdc, rect{0, 0, W, H}, colEdge)
|
||||
fillRaw(hdc, rect{0, 0, W, H}, iconColor()) // the outline follows the tray icon color
|
||||
fillRaw(hdc, rect{u(1), u(1), W - u(1), H - u(1)}, colBack)
|
||||
|
||||
pad := u(14)
|
||||
@@ -431,6 +439,15 @@ func wxDraw(hdc uintptr, W, H int32) {
|
||||
cell(2, 1, "UV index", strconv.Itoa(int(math.Round(today.uv))))
|
||||
rule(u(218))
|
||||
|
||||
// Radar, when the panel is tall enough to have room for it. Everything below it
|
||||
// is drawn the same way, just moved down.
|
||||
if H >= u(wxFullH+wxRadarH-1) {
|
||||
radarDraw(hdc, rect{pad, u(226), W - pad, u(226) + u(150)})
|
||||
rule(u(382))
|
||||
pSetViewportOrgEx.Call(hdc, 0, uintptr(u(wxRadarH)), 0)
|
||||
defer pSetViewportOrgEx.Call(hdc, 0, 0, 0)
|
||||
}
|
||||
|
||||
// Moon.
|
||||
moon := moonAt(time.Now())
|
||||
wxMoonDraw(hdc, pad+u(24), u(254), u(22), moon, s.lat >= 0)
|
||||
|
||||
@@ -1188,6 +1188,8 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
case wmDestroy:
|
||||
previewShutdown()
|
||||
weatherShutdown()
|
||||
newsShutdown()
|
||||
sysShutdown()
|
||||
abd := appBarData{Hwnd: hwnd}
|
||||
appBar(abmRemove, &abd)
|
||||
pKillTimer.Call(hwnd, timerID)
|
||||
@@ -1249,6 +1251,7 @@ func main() {
|
||||
loadOrderKeys()
|
||||
loadIconMode()
|
||||
loadZip()
|
||||
loadFeatures()
|
||||
|
||||
hdc, _, _ := pGetDC.Call(0)
|
||||
dpi, _, _ := pGetDeviceCaps.Call(hdc, logPixelsX)
|
||||
@@ -1303,6 +1306,8 @@ func main() {
|
||||
hwndMain = hwnd
|
||||
previewInit(inst)
|
||||
weatherInit(inst)
|
||||
newsInit(inst)
|
||||
sysInit(inst)
|
||||
enableFileDrop(hwnd)
|
||||
refreshAutostartPath()
|
||||
|
||||
@@ -1332,6 +1337,7 @@ func main() {
|
||||
positionBar(hwnd)
|
||||
pSetTimer.Call(hwnd, timerID, 250, 0)
|
||||
weatherRefresh(false) // have the forecast ready before the cloud is first clicked
|
||||
newsRefresh(false)
|
||||
|
||||
var m msg
|
||||
for {
|
||||
|
||||
@@ -233,6 +233,10 @@ func renderLayer(screen uintptr, w, h int32, fills, fg bool, base uintptr) []uin
|
||||
drawChevron(memV, r)
|
||||
case trayWeather:
|
||||
drawWeatherIcon(memV, r)
|
||||
case trayNews:
|
||||
drawNewsIcon(memV, r)
|
||||
case traySys:
|
||||
drawSysIcon(memV, r)
|
||||
}
|
||||
}
|
||||
pGdiFlush.Call()
|
||||
|
||||
+24
-8
@@ -68,6 +68,9 @@ const (
|
||||
idClose = 210
|
||||
idZip = 211
|
||||
idZipStatus = 212
|
||||
idShowWeather = 213
|
||||
idShowNews = 214
|
||||
idShowSys = 215
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -78,6 +81,7 @@ var (
|
||||
ctlAlpha, ctlAlphaValue, ctlLogo, ctlClock, ctlTrayIcons, ctlStyle uintptr
|
||||
ctlVertical, ctlAutostart uintptr
|
||||
ctlZip, ctlZipStatus uintptr
|
||||
ctlShowWeather, ctlShowNews, ctlShowSys uintptr
|
||||
zipSyncing bool // true while the program itself is filling in the ZIP box
|
||||
)
|
||||
|
||||
@@ -129,7 +133,7 @@ func openSettings() {
|
||||
settingsFont = makeFont(px(13), 400)
|
||||
}
|
||||
|
||||
r := rect{0, 0, px(400), px(376)}
|
||||
r := rect{0, 0, px(400), px(460)}
|
||||
pAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(&r)), wsWindowFrame, 0, 0)
|
||||
ow, oh := r.Right-r.Left, r.Bottom-r.Top
|
||||
sw, sh := screenSize()
|
||||
@@ -171,17 +175,20 @@ func openSettings() {
|
||||
pSendMessage.Call(ctlStyle, cbAddString, 0, uintptr(unsafe.Pointer(u16(n))))
|
||||
}
|
||||
|
||||
label("Weather ZIP code", 204)
|
||||
label("ZIP code", 204)
|
||||
ctlZip = makeControl(hw, inst, "EDIT", "", esNumber|esAutoHScroll|wsBorder|wsTabStop, 170, 204, 90, 24, idZip)
|
||||
pSendMessage.Call(ctlZip, emSetLimitText, 5, 0)
|
||||
ctlZipStatus = makeControl(hw, inst, "STATIC", "", 0, 16, 236, 368, 20, idZipStatus)
|
||||
|
||||
ctlVertical = makeControl(hw, inst, "BUTTON", "Stand the bar up at the right edge (vertical)", bsAutoCheckBox|wsTabStop, 16, 262, 368, 22, idVertical)
|
||||
ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 290, 368, 22, idAutostart)
|
||||
ctlShowWeather = makeControl(hw, inst, "BUTTON", "Show weather on the bar", bsAutoCheckBox|wsTabStop, 16, 262, 368, 22, idShowWeather)
|
||||
ctlShowNews = makeControl(hw, inst, "BUTTON", "Show local news on the bar", bsAutoCheckBox|wsTabStop, 16, 290, 368, 22, idShowNews)
|
||||
ctlShowSys = makeControl(hw, inst, "BUTTON", "Show system stats on the bar", bsAutoCheckBox|wsTabStop, 16, 318, 368, 22, idShowSys)
|
||||
ctlVertical = makeControl(hw, inst, "BUTTON", "Stand the bar up at the right edge (vertical)", bsAutoCheckBox|wsTabStop, 16, 346, 368, 22, idVertical)
|
||||
ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 374, 368, 22, idAutostart)
|
||||
|
||||
makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 330, 116, 28, idResetPos)
|
||||
makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 330, 116, 28, idResetWidth)
|
||||
makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 330, 92, 28, idClose)
|
||||
makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 414, 116, 28, idResetPos)
|
||||
makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 414, 116, 28, idResetWidth)
|
||||
makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 414, 92, 28, idClose)
|
||||
|
||||
hwndSettings = hw
|
||||
settingsSync()
|
||||
@@ -200,6 +207,9 @@ func settingsSync() {
|
||||
pSendMessage.Call(ctlClock, cbSetCurSel, uintptr(clockIdx), 0)
|
||||
pSendMessage.Call(ctlTrayIcons, cbSetCurSel, uintptr(iconIdx), 0)
|
||||
pSendMessage.Call(ctlStyle, cbSetCurSel, uintptr(iconMode), 0)
|
||||
pSendMessage.Call(ctlShowWeather, bmSetCheck, boolWP(showWeather), 0)
|
||||
pSendMessage.Call(ctlShowNews, bmSetCheck, boolWP(showNews), 0)
|
||||
pSendMessage.Call(ctlShowSys, bmSetCheck, boolWP(showSys), 0)
|
||||
pSendMessage.Call(ctlVertical, bmSetCheck, boolWP(vertical), 0)
|
||||
pSendMessage.Call(ctlAutostart, bmSetCheck, boolWP(autostartEnabled()), 0)
|
||||
|
||||
@@ -224,7 +234,7 @@ func settingsZipStatusUpdate() {
|
||||
if hwndSettings == 0 || ctlZipStatus == 0 {
|
||||
return
|
||||
}
|
||||
pSetWindowText.Call(ctlZipStatus, uintptr(unsafe.Pointer(u16(weatherStatusText()))))
|
||||
pSetWindowText.Call(ctlZipStatus, uintptr(unsafe.Pointer(u16(zipStatusText()))))
|
||||
}
|
||||
|
||||
// zipEdited runs each time the ZIP box changes. Five digits turn the weather on
|
||||
@@ -293,6 +303,12 @@ func settingsCommand(id, note uintptr) {
|
||||
if note == enChange && !zipSyncing {
|
||||
zipEdited()
|
||||
}
|
||||
case idShowWeather:
|
||||
setShowWeather(checked(ctlShowWeather))
|
||||
case idShowNews:
|
||||
setShowNews(checked(ctlShowNews))
|
||||
case idShowSys:
|
||||
setShowSys(checked(ctlShowSys))
|
||||
case idVertical:
|
||||
vertical = checked(ctlVertical)
|
||||
saveOrient()
|
||||
|
||||
Reference in New Issue
Block a user