Draggable left edge resize, part 1
This commit is contained in:
@@ -551,18 +551,11 @@ func screenSize() (int32, int32) {
|
||||
return int32(w), int32(h)
|
||||
}
|
||||
|
||||
// pillWidth is the width the bar needs: the wider of the two halves, doubled so
|
||||
// the bar stays a mirror image around the center, plus a little padding.
|
||||
// pillWidth is the width the bar needs: the left half plus the right half. By
|
||||
// default the left half is as long as the right one (a mirror image); pulling
|
||||
// the far left end changes that (see barwidth.go).
|
||||
func pillWidth() int32 {
|
||||
sw, _ := screenSize()
|
||||
left := startWidth() + int32(len(apps))*px(36)
|
||||
items := trayItems(0, 1)
|
||||
right := items[len(items)-1].r.Right
|
||||
half := max(left, right) + px(16)
|
||||
if limit := sw/2 - px(4); half > limit {
|
||||
half = limit
|
||||
}
|
||||
return half * 2
|
||||
return leftHalf() + rightHalf()
|
||||
}
|
||||
|
||||
// barGap is the space left under the pill so it stands off the screen edge.
|
||||
@@ -888,6 +881,7 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
|
||||
posFlags = mfGrayed
|
||||
}
|
||||
add(posFlags, menuResetPosID, "Reset position to bottom center")
|
||||
add(0, menuResetWidthID, "Reset bar width")
|
||||
var autoFlags uintptr
|
||||
if autostartEnabled() {
|
||||
autoFlags = mfChecked
|
||||
@@ -916,6 +910,10 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
|
||||
pDestroyWindow.Call(hwnd)
|
||||
case cmd == menuResetPosID:
|
||||
resetPos(hwnd)
|
||||
case cmd == menuResetWidthID:
|
||||
leftPref = 0
|
||||
saveLeftPref()
|
||||
redraw(hwnd)
|
||||
case handleColorCommand(cmd):
|
||||
redraw(hwnd)
|
||||
case cmd == menuOrientID:
|
||||
@@ -997,6 +995,10 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
case wmLButtonDown:
|
||||
previewSuppress()
|
||||
x := alongClient(lparam)
|
||||
if edgeZone(x) {
|
||||
beginResize(hwnd)
|
||||
return 0
|
||||
}
|
||||
if inStart(hwnd, x) {
|
||||
dragSeq, dragIsStart, dragStart, dragActive = slot(), true, x, false
|
||||
pSetCapture.Call(hwnd)
|
||||
@@ -1009,10 +1011,15 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
}
|
||||
return 0
|
||||
case wmCaptureChanged:
|
||||
resizing = false
|
||||
endIconDrag()
|
||||
dragTray, dragTrayActive = 0, false
|
||||
return 0
|
||||
case wmMouseMove:
|
||||
if resizing {
|
||||
moveResize(hwnd)
|
||||
return 0
|
||||
}
|
||||
x := alongClient(lparam)
|
||||
if dragSeq >= 0 && dragSeq <= len(apps) {
|
||||
if !dragActive && abs32(x-dragStart) > px(5) {
|
||||
@@ -1073,6 +1080,10 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
}
|
||||
return 0
|
||||
case wmLButtonUp:
|
||||
if resizing {
|
||||
endResize(hwnd)
|
||||
return 0
|
||||
}
|
||||
x := alongClient(lparam)
|
||||
if dragSeq >= 0 {
|
||||
// A press on the Start button or an app icon: a click if it never moved, otherwise the drag ends here.
|
||||
@@ -1125,10 +1136,16 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
var wr rect
|
||||
pGetWindowRect.Call(hwnd, uintptr(unsafe.Pointer(&wr)))
|
||||
x := alongScreen(lparam, wr)
|
||||
if inStart(hwnd, x) || appIndexAt(hwnd, x) >= 0 || trayAt(hwnd, x) != 0 {
|
||||
if edgeZone(x) || inStart(hwnd, x) || appIndexAt(hwnd, x) >= 0 || trayAt(hwnd, x) != 0 {
|
||||
return htClient
|
||||
}
|
||||
return htCaption
|
||||
case wmSetCursor:
|
||||
// The far end of the pill shows the resize arrow.
|
||||
if resizing || (uint16(lparam&0xFFFF) == htClient && overEdge(hwnd)) {
|
||||
pSetCursor.Call(sizeCursor())
|
||||
return 1
|
||||
}
|
||||
case wmNcLButtonDblClk:
|
||||
return 0 // a double click on the drag area must not maximize the pill
|
||||
case wmNcRButtonUp:
|
||||
@@ -1216,6 +1233,7 @@ func main() {
|
||||
loadStartSlot()
|
||||
loadTrayOrder()
|
||||
loadOrient()
|
||||
loadLeftPref()
|
||||
loadPinned()
|
||||
loadOrderKeys()
|
||||
loadIconMode()
|
||||
|
||||
Reference in New Issue
Block a user