2 Commits
8 changed files with 249 additions and 64 deletions
+2
View File
@@ -25,6 +25,8 @@ The real taskbar is hidden and a see-through pill takes its place. The pill is a
- "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. - "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.
- The weather, news and system stats panels are as see-through as the bar itself: set the bar to Clear and the panels go clear too, with only their text, pictures and outline staying solid. Untick "Panels match the bar's transparency" in the settings window to keep the panels solid.
- 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. - 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). - 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. - "Icon style" in the right-click menu: colorized or grayscale. It applies to the app icons and to the logo, clock and tray icons.
+14 -1
View File
@@ -36,12 +36,14 @@ func loadFeatures() {
showNews = on showNews = on
case "sys": case "sys":
showSys = on showSys = on
case "panelfade":
flyMatchBar = on
} }
} }
} }
func saveFeatures() { func saveFeatures() {
s := "weather=" + b01(showWeather) + "\nnews=" + b01(showNews) + "\nsys=" + b01(showSys) + "\n" s := "weather=" + b01(showWeather) + "\nnews=" + b01(showNews) + "\nsys=" + b01(showSys) + "\npanelfade=" + b01(flyMatchBar) + "\n"
_ = os.MkdirAll(dataDir(), 0o755) _ = os.MkdirAll(dataDir(), 0o755)
_ = os.WriteFile(featuresFile(), []byte(s), 0o644) _ = os.WriteFile(featuresFile(), []byte(s), 0o644)
} }
@@ -96,6 +98,17 @@ func setShowSys(on bool) {
featuresChanged() featuresChanged()
} }
// setFlyMatchBar is called by the settings window: should the panels be as
// see-through as the bar?
func setFlyMatchBar(on bool) {
if flyMatchBar == on {
return
}
flyMatchBar = on
saveFeatures()
flyRefreshAll()
}
func featuresChanged() { func featuresChanged() {
settingsZipStatusUpdate() settingsZipStatusUpdate()
redraw(hwndMain) redraw(hwndMain)
+42 -42
View File
@@ -106,7 +106,7 @@ func weatherInit(inst uintptr) {
wc.Size = uint32(unsafe.Sizeof(wc)) wc.Size = uint32(unsafe.Sizeof(wc))
pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc))) pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc)))
wxHwnd, _, _ = pCreateWindowEx.Call( wxHwnd, _, _ = pCreateWindowEx.Call(
wsExToolWindow|wsExTopmost|wsExNoActivate, wsExToolWindow|wsExTopmost|wsExNoActivate|wsExLayered,
uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(className)),
uintptr(unsafe.Pointer(u16(""))), uintptr(unsafe.Pointer(u16(""))),
wsPopup, wsPopup,
@@ -223,7 +223,7 @@ func weatherPlace() {
x = clampI(x, 0, sw-cw) x = clampI(x, 0, sw-cw)
y = clampI(y, 0, sh-ch) y = clampI(y, 0, sh-ch)
pSetWindowPos.Call(wxHwnd, hwndTopmost, uintptr(x), uintptr(y), uintptr(cw), uintptr(ch), swpNoActivate|swpShowWindow) pSetWindowPos.Call(wxHwnd, hwndTopmost, uintptr(x), uintptr(y), uintptr(cw), uintptr(ch), swpNoActivate|swpShowWindow)
pInvalidateRect.Call(wxHwnd, 0, 1) flyRefresh(wxHwnd)
} }
// weatherPoll closes the panel when a mouse button goes down anywhere outside // weatherPoll closes the panel when a mouse button goes down anywhere outside
@@ -302,44 +302,13 @@ func wxMakeFonts() {
func wxPaint(hwnd uintptr) { flyPaint(hwnd, wxDraw) } func wxPaint(hwnd uintptr) { flyPaint(hwnd, wxDraw) }
// flyPaint paints a panel at double size into a memory bitmap with the given // flyPaint answers a paint request: the panel is rendered see-through (see
// drawing function, then shrinks it onto the window. // flyrender.go) instead of being painted by Windows.
func flyPaint(hwnd uintptr, draw func(hdc uintptr, W, H int32)) { func flyPaint(hwnd uintptr, draw func(hdc uintptr, W, H int32)) {
var ps paintStruct var ps paintStruct
hdc, _, _ := pBeginPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps))) pBeginPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps)))
defer pEndPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps))) pEndPaint.Call(hwnd, uintptr(unsafe.Pointer(&ps)))
flyRender(hwnd, draw)
var rc rect
pGetClientRect.Call(hwnd, uintptr(unsafe.Pointer(&rc)))
W, H := rc.Right-rc.Left, rc.Bottom-rc.Top
if W <= 0 || H <= 0 {
return
}
const ss = 2
mem, _, _ := pCreateCompatibleDC.Call(hdc)
defer pDeleteDC.Call(mem)
bmi := bitmapInfoHeader{Width: W * ss, Height: -(H * ss), Planes: 1, BitCount: 32}
bmi.Size = uint32(unsafe.Sizeof(bmi))
var bits unsafe.Pointer
bmp, _, _ := pCreateDIBSection.Call(hdc, uintptr(unsafe.Pointer(&bmi)), 0, uintptr(unsafe.Pointer(&bits)), 0, 0)
if bmp == 0 || bits == nil {
return
}
defer pDeleteObject.Call(bmp)
old, _, _ := pSelectObject.Call(mem, bmp)
defer pSelectObject.Call(mem, old)
saved := scale
defer func() { scale = saved }()
scale *= ss
wxMakeFonts()
draw(mem, W*ss, H*ss)
scale = saved
pSetStretchBltMode.Call(hdc, halftone)
pSetBrushOrgEx.Call(hdc, 0, 0, 0)
pStretchBlt.Call(hdc, 0, 0, uintptr(W), uintptr(H), mem, 0, 0, uintptr(W*ss), uintptr(H*ss), srcCopy)
} }
var ( var (
@@ -362,8 +331,7 @@ func wxText(hdc uintptr, s string, r rect, font, col, flags uintptr) {
// here is a double size distance. // here is a double size distance.
func wxDraw(hdc uintptr, W, H int32) { func wxDraw(hdc uintptr, W, H int32) {
u := px u := px
fillRaw(hdc, rect{0, 0, W, H}, iconColor()) // the outline follows the tray icon color flyFrame(hdc, W, H) // outline in the tray icon color; the background is added when painting
fillRaw(hdc, rect{u(1), u(1), W - u(1), H - u(1)}, colBack)
pad := u(14) pad := u(14)
inner := W - 2*pad inner := W - 2*pad
@@ -512,8 +480,40 @@ func wxSunGlyph(hdc uintptr, cx, cy, s float64) {
} }
func wxCrescent(hdc uintptr, cx, cy, rad float64) { func wxCrescent(hdc uintptr, cx, cy, rad float64) {
wxCircle(hdc, cx, cy, rad, rgb(235, 232, 205)) brush, _, _ := pCreateSolidBrush.Call(rgb(235, 232, 205))
wxCircle(hdc, cx+0.45*rad, cy-0.25*rad, 0.85*rad, colBack) defer pDeleteObject.Call(brush)
ix, iy, ir := cx+0.45*rad, cy-0.25*rad, 0.85*rad // the circle that is cut out
top := int32(math.Round(cy))
r := int32(math.Ceil(rad))
for dy := -r; dy <= r; dy++ {
y := top + dy
oh2 := rad*rad - float64(dy)*float64(dy)
if oh2 <= 0 {
continue
}
oh := math.Sqrt(oh2)
x0, x1 := cx-oh, cx+oh
var segs [][2]float64
fy := float64(y) + 0.5 - iy
if ih2 := ir*ir - fy*fy; ih2 > 0 {
ih := math.Sqrt(ih2)
if l := ix - ih; l > x0 {
segs = append(segs, [2]float64{x0, math.Min(l, x1)})
}
if rr := ix + ih; rr < x1 {
segs = append(segs, [2]float64{math.Max(rr, x0), x1})
}
} else {
segs = append(segs, [2]float64{x0, x1})
}
for _, sg := range segs {
if sg[1]-sg[0] < 0.5 {
continue
}
line := rect{int32(math.Round(sg[0])), y, int32(math.Round(sg[1])), y + 1}
pFillRect.Call(hdc, uintptr(unsafe.Pointer(&line)), brush)
}
}
} }
// wxIcon draws the picture for a kind of weather inside the square r. // wxIcon draws the picture for a kind of weather inside the square r.
+166
View File
@@ -0,0 +1,166 @@
package main
// Painting the three panels (weather, news, system stats) as see-through
// windows that follow the bar's own background opacity. The panels are painted
// the same way the bar is: the content (text, pictures, lines) is drawn twice at
// double size, once on black and once on white; comparing the two copies shows
// how solid every pixel is. The panel's background color is then added back at
// the bar's see-through level, and the result is handed to Windows as a layered
// window with a transparency value for every pixel.
import (
"unsafe"
)
// flyMatchBar is the "panels match the bar's transparency" setting. When it is
// off the panels are solid, as they were before.
var flyMatchBar = true
func flyBgAlpha() uint32 {
if flyMatchBar {
return uint32(bgAlpha)
}
return 255
}
// flyFrame draws the one pixel outline around a panel, in the tray icon color.
// The background inside it is not painted here; flyRender adds it.
func flyFrame(hdc uintptr, W, H int32) {
t, col := px(1), iconColor()
fillRaw(hdc, rect{0, 0, W, t}, col)
fillRaw(hdc, rect{0, H - t, W, H}, col)
fillRaw(hdc, rect{0, 0, t, H}, col)
fillRaw(hdc, rect{W - t, 0, W, H}, col)
}
// flyLayer paints the content onto a flat color and returns its pixels.
func flyLayer(screen uintptr, w, h int32, base uintptr, draw func(hdc uintptr, W, H int32)) []uint32 {
mem, _, _ := pCreateCompatibleDC.Call(screen)
defer pDeleteDC.Call(mem)
bmi := bitmapInfoHeader{Width: w, Height: -h, Planes: 1, BitCount: 32}
bmi.Size = uint32(unsafe.Sizeof(bmi))
var bits unsafe.Pointer
bmp, _, _ := pCreateDIBSection.Call(screen, uintptr(unsafe.Pointer(&bmi)), 0, uintptr(unsafe.Pointer(&bits)), 0, 0)
if bmp == 0 || bits == nil {
return nil
}
defer pDeleteObject.Call(bmp)
old, _, _ := pSelectObject.Call(mem, bmp)
defer pSelectObject.Call(mem, old)
fillRaw(mem, rect{0, 0, w, h}, base)
draw(mem, w, h)
pGdiFlush.Call()
out := make([]uint32, int(w)*int(h))
copy(out, unsafe.Slice((*uint32)(bits), len(out)))
return out
}
// flyRender paints one panel and puts it on the screen.
func flyRender(hwnd uintptr, draw func(hdc uintptr, W, H int32)) {
if hwnd == 0 {
return
}
if v, _, _ := pIsWindowVisible.Call(hwnd); v == 0 {
return
}
var rc rect
pGetClientRect.Call(hwnd, uintptr(unsafe.Pointer(&rc)))
W, H := rc.Right-rc.Left, rc.Bottom-rc.Top
if W <= 0 || H <= 0 {
return
}
const ss = 2
screen, _, _ := pGetDC.Call(0)
defer pReleaseDC.Call(0, screen)
saved := scale
scale *= ss
wxMakeFonts()
onBlack := flyLayer(screen, W*ss, H*ss, rgb(0, 0, 0), draw)
onWhite := flyLayer(screen, W*ss, H*ss, rgb(255, 255, 255), draw)
scale = saved
n := int(W) * int(H)
if len(onBlack) != n*ss*ss || len(onWhite) != len(onBlack) {
return
}
mem, _, _ := pCreateCompatibleDC.Call(screen)
defer pDeleteDC.Call(mem)
bmi := bitmapInfoHeader{Width: W, Height: -H, Planes: 1, BitCount: 32}
bmi.Size = uint32(unsafe.Sizeof(bmi))
var bits unsafe.Pointer
bmp, _, _ := pCreateDIBSection.Call(screen, uintptr(unsafe.Pointer(&bmi)), 0, uintptr(unsafe.Pointer(&bits)), 0, 0)
if bmp == 0 || bits == nil {
return
}
defer pDeleteObject.Call(bmp)
old, _, _ := pSelectObject.Call(mem, bmp)
defer pSelectObject.Call(mem, old)
pix := unsafe.Slice((*uint32)(bits), n)
a := flyBgAlpha()
bgR, bgG, bgB := uint32(28)*a/255, uint32(28)*a/255, uint32(34)*a/255 // colBack at its see-through level
stride := int(W) * ss
for i := range pix {
x, y := i%int(W), i/int(W)
var br, bg, bb, wr, wg, wb uint32
for dy := 0; dy < ss; dy++ {
for dx := 0; dx < ss; dx++ {
k := (y*ss+dy)*stride + x*ss + dx
c, w := onBlack[k], onWhite[k]
br += c >> 16 & 0xFF
bg += c >> 8 & 0xFF
bb += c & 0xFF
wr += w >> 16 & 0xFF
wg += w >> 8 & 0xFF
wb += w & 0xFF
}
}
const cnt = ss * ss
br, bg, bb, wr, wg, wb = br/cnt, bg/cnt, bb/cnt, wr/cnt, wg/cnt, wb/cnt
d := (sub0(wr, br) + sub0(wg, bg) + sub0(wb, bb)) / 3
fa := 255 - min(d, 255) // how solid the content is here
fr, fg, fb := min(br, fa), min(bg, fa), min(bb, fa)
inv := 255 - fa
oa := fa + a*inv/255
pix[i] = oa<<24 | (fr+bgR*inv/255)<<16 | (fg+bgG*inv/255)<<8 | (fb + bgB*inv/255)
}
var wr rect
pGetWindowRect.Call(hwnd, uintptr(unsafe.Pointer(&wr)))
dst := point{wr.Left, wr.Top}
sz := size{W, H}
src := point{0, 0}
blend := blendFunction{Op: 0, Flags: 0, Alpha: 255, Format: 1} // AC_SRC_OVER, AC_SRC_ALPHA
pUpdateLayeredWindow.Call(hwnd, screen,
uintptr(unsafe.Pointer(&dst)), uintptr(unsafe.Pointer(&sz)),
mem, uintptr(unsafe.Pointer(&src)), 0,
uintptr(unsafe.Pointer(&blend)), ulwAlpha)
}
// flyRefresh repaints one of the panels.
func flyRefresh(hwnd uintptr) {
switch hwnd {
case wxHwnd:
flyRender(hwnd, wxDraw)
case newsHwnd:
flyRender(hwnd, newsDraw)
case sysHwnd:
flyRender(hwnd, sysDraw)
}
}
// flyRefreshAll repaints whichever panel is open (after a setting changed).
func flyRefreshAll() {
if wxShown {
flyRefresh(wxHwnd)
}
if newsShown {
flyRefresh(newsHwnd)
}
if sysShown {
flyRefresh(sysHwnd)
}
}
+4 -5
View File
@@ -65,7 +65,7 @@ func newsInit(inst uintptr) {
wc.Size = uint32(unsafe.Sizeof(wc)) wc.Size = uint32(unsafe.Sizeof(wc))
pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc))) pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc)))
newsHwnd, _, _ = pCreateWindowEx.Call( newsHwnd, _, _ = pCreateWindowEx.Call(
wsExToolWindow|wsExTopmost|wsExNoActivate, wsExToolWindow|wsExTopmost|wsExNoActivate|wsExLayered,
uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(className)),
uintptr(unsafe.Pointer(u16(""))), uintptr(unsafe.Pointer(u16(""))),
wsPopup, wsPopup,
@@ -168,7 +168,7 @@ func newsPlace() {
lh = newsHead + float64(newsVisible)*newsRow + newsFoot lh = newsHead + float64(newsVisible)*newsRow + newsFoot
} }
flyPlace(newsHwnd, trayAnchor(trayNews), px(newsW), px(lh)) flyPlace(newsHwnd, trayAnchor(trayNews), px(newsW), px(lh))
pInvalidateRect.Call(newsHwnd, 0, 1) flyRefresh(newsHwnd)
} }
// newsDone runs when a download finishes. // newsDone runs when a download finishes.
@@ -202,7 +202,7 @@ func newsPoll() {
} }
if h != newsHover { if h != newsHover {
newsHover = h newsHover = h
pInvalidateRect.Call(newsHwnd, 0, 0) flyRefresh(newsHwnd)
} }
} }
@@ -248,8 +248,7 @@ func newsClick(x, y int32) {
func newsDraw(hdc uintptr, W, H int32) { func newsDraw(hdc uintptr, W, H int32) {
u := px u := px
fillRaw(hdc, rect{0, 0, W, H}, iconColor()) // the outline follows the tray icon color flyFrame(hdc, W, H) // outline in the tray icon color; the background is added when painting
fillRaw(hdc, rect{u(1), u(1), W - u(1), H - u(1)}, colBack)
pad := u(14) pad := u(14)
s := newsSnapshot() s := newsSnapshot()
+1 -2
View File
@@ -37,8 +37,7 @@ func radarAdvance() {
} }
rdHold = 0 rdHold = 0
rdIdx = (rdIdx + 1) % n rdIdx = (rdIdx + 1) % n
rc := rect{px(14), px(226), px(14 + 312), px(226 + 150)} flyRefresh(wxHwnd)
pInvalidateRect.Call(wxHwnd, uintptr(unsafe.Pointer(&rc)), 0)
} }
func radarBox(hdc uintptr, r rect) { func radarBox(hdc uintptr, r rect) {
+14 -7
View File
@@ -71,6 +71,7 @@ const (
idShowWeather = 213 idShowWeather = 213
idShowNews = 214 idShowNews = 214
idShowSys = 215 idShowSys = 215
idPanelFade = 216
) )
var ( var (
@@ -81,7 +82,7 @@ var (
ctlAlpha, ctlAlphaValue, ctlLogo, ctlClock, ctlTrayIcons, ctlStyle uintptr ctlAlpha, ctlAlphaValue, ctlLogo, ctlClock, ctlTrayIcons, ctlStyle uintptr
ctlVertical, ctlAutostart uintptr ctlVertical, ctlAutostart uintptr
ctlZip, ctlZipStatus uintptr ctlZip, ctlZipStatus uintptr
ctlShowWeather, ctlShowNews, ctlShowSys uintptr ctlShowWeather, ctlShowNews, ctlShowSys, ctlPanelFade uintptr
zipSyncing bool // true while the program itself is filling in the ZIP box zipSyncing bool // true while the program itself is filling in the ZIP box
) )
@@ -133,7 +134,7 @@ func openSettings() {
settingsFont = makeFont(px(13), 400) settingsFont = makeFont(px(13), 400)
} }
r := rect{0, 0, px(400), px(460)} r := rect{0, 0, px(400), px(488)}
pAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(&r)), wsWindowFrame, 0, 0) pAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(&r)), wsWindowFrame, 0, 0)
ow, oh := r.Right-r.Left, r.Bottom-r.Top ow, oh := r.Right-r.Left, r.Bottom-r.Top
sw, sh := screenSize() sw, sh := screenSize()
@@ -183,12 +184,13 @@ func openSettings() {
ctlShowWeather = makeControl(hw, inst, "BUTTON", "Show weather on the bar", bsAutoCheckBox|wsTabStop, 16, 262, 368, 22, idShowWeather) 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) 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) 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) ctlPanelFade = makeControl(hw, inst, "BUTTON", "Panels match the bar's transparency", bsAutoCheckBox|wsTabStop, 16, 346, 368, 22, idPanelFade)
ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 374, 368, 22, idAutostart) ctlVertical = makeControl(hw, inst, "BUTTON", "Stand the bar up at the right edge (vertical)", bsAutoCheckBox|wsTabStop, 16, 374, 368, 22, idVertical)
ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 402, 368, 22, idAutostart)
makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 414, 116, 28, idResetPos) makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 442, 116, 28, idResetPos)
makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 414, 116, 28, idResetWidth) makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 442, 116, 28, idResetWidth)
makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 414, 92, 28, idClose) makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 442, 92, 28, idClose)
hwndSettings = hw hwndSettings = hw
settingsSync() settingsSync()
@@ -210,6 +212,7 @@ func settingsSync() {
pSendMessage.Call(ctlShowWeather, bmSetCheck, boolWP(showWeather), 0) pSendMessage.Call(ctlShowWeather, bmSetCheck, boolWP(showWeather), 0)
pSendMessage.Call(ctlShowNews, bmSetCheck, boolWP(showNews), 0) pSendMessage.Call(ctlShowNews, bmSetCheck, boolWP(showNews), 0)
pSendMessage.Call(ctlShowSys, bmSetCheck, boolWP(showSys), 0) pSendMessage.Call(ctlShowSys, bmSetCheck, boolWP(showSys), 0)
pSendMessage.Call(ctlPanelFade, bmSetCheck, boolWP(flyMatchBar), 0)
pSendMessage.Call(ctlVertical, bmSetCheck, boolWP(vertical), 0) pSendMessage.Call(ctlVertical, bmSetCheck, boolWP(vertical), 0)
pSendMessage.Call(ctlAutostart, bmSetCheck, boolWP(autostartEnabled()), 0) pSendMessage.Call(ctlAutostart, bmSetCheck, boolWP(autostartEnabled()), 0)
@@ -289,6 +292,7 @@ func settingsCommand(id, note uintptr) {
} }
saveColors() saveColors()
redraw(hwndMain) redraw(hwndMain)
flyRefreshAll()
case idStyle: case idStyle:
if note != cbnSelChange { if note != cbnSelChange {
return return
@@ -309,6 +313,8 @@ func settingsCommand(id, note uintptr) {
setShowNews(checked(ctlShowNews)) setShowNews(checked(ctlShowNews))
case idShowSys: case idShowSys:
setShowSys(checked(ctlShowSys)) setShowSys(checked(ctlShowSys))
case idPanelFade:
setFlyMatchBar(checked(ctlPanelFade))
case idVertical: case idVertical:
vertical = checked(ctlVertical) vertical = checked(ctlVertical)
saveOrient() saveOrient()
@@ -343,6 +349,7 @@ func settingsProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
bgAlpha = n bgAlpha = n
pSetWindowText.Call(ctlAlphaValue, uintptr(unsafe.Pointer(u16(strconv.Itoa(bgAlpha*100/255)+"%")))) pSetWindowText.Call(ctlAlphaValue, uintptr(unsafe.Pointer(u16(strconv.Itoa(bgAlpha*100/255)+"%"))))
redraw(hwndMain) redraw(hwndMain)
flyRefreshAll()
} }
if wparam&0xFFFF == tbEndTrack { if wparam&0xFFFF == tbEndTrack {
saveAlpha() saveAlpha()
+6 -7
View File
@@ -66,7 +66,7 @@ func sysInit(inst uintptr) {
wc.Size = uint32(unsafe.Sizeof(wc)) wc.Size = uint32(unsafe.Sizeof(wc))
pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc))) pRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc)))
sysHwnd, _, _ = pCreateWindowEx.Call( sysHwnd, _, _ = pCreateWindowEx.Call(
wsExToolWindow|wsExTopmost|wsExNoActivate, wsExToolWindow|wsExTopmost|wsExNoActivate|wsExLayered,
uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(className)),
uintptr(unsafe.Pointer(u16(""))), uintptr(unsafe.Pointer(u16(""))),
wsPopup, wsPopup,
@@ -91,7 +91,7 @@ func sysProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
case wmTimer: case wmTimer:
if wparam == sysRefreshTimerID { if wparam == sysRefreshTimerID {
sysRows = sysGather() // uptime and memory move sysRows = sysGather() // uptime and memory move
pInvalidateRect.Call(sysHwnd, 0, 0) flyRefresh(sysHwnd)
return 0 return 0
} }
sysPoll() sysPoll()
@@ -172,7 +172,7 @@ func sysPlace() {
} }
lh := sysHead + float64(len(sysRows))*sysRow_ + sysFoot lh := sysHead + float64(len(sysRows))*sysRow_ + sysFoot
flyPlace(sysHwnd, trayAnchor(traySys), px(sysW), px(lh)) flyPlace(sysHwnd, trayAnchor(traySys), px(sysW), px(lh))
pInvalidateRect.Call(sysHwnd, 0, 1) flyRefresh(sysHwnd)
} }
// sysRowAt is the line under a height in the panel (real pixels), or -1. // sysRowAt is the line under a height in the panel (real pixels), or -1.
@@ -214,7 +214,7 @@ func sysPoll() {
changed = true changed = true
} }
if changed { if changed {
pInvalidateRect.Call(sysHwnd, 0, 0) flyRefresh(sysHwnd)
} }
} }
@@ -225,7 +225,7 @@ func sysCopy(text, what string) {
sysCopied = "Copy failed" sysCopied = "Copy failed"
} }
sysCopiedAt = time.Now() sysCopiedAt = time.Now()
pInvalidateRect.Call(sysHwnd, 0, 0) flyRefresh(sysHwnd)
} }
func sysClick(x, y int32) { func sysClick(x, y int32) {
@@ -242,8 +242,7 @@ func sysClick(x, y int32) {
func sysDraw(hdc uintptr, W, H int32) { func sysDraw(hdc uintptr, W, H int32) {
u := px u := px
fillRaw(hdc, rect{0, 0, W, H}, iconColor()) // the outline follows the tray icon color flyFrame(hdc, W, H) // outline in the tray icon color; the background is added when painting
fillRaw(hdc, rect{u(1), u(1), W - u(1), H - u(1)}, colBack)
pad := u(14) pad := u(14)
line := uintptr(dtLeft | dtVCenter | dtSingleLine | dtEndEllipsis) line := uintptr(dtLeft | dtVCenter | dtSingleLine | dtEndEllipsis)