refurbished 'View.ahk', removed some unnecessary functions (one-liners)

This commit is contained in:
joten 2012-10-04 20:05:17 +02:00
parent 2021de2e7b
commit 177019b927
2 changed files with 32 additions and 37 deletions

View file

@ -836,7 +836,7 @@ Manager_unmanage(wndId)
{ {
If (Manager_#%wndId%_tags & 1 << A_Index - 1) If (Manager_#%wndId%_tags & 1 << A_Index - 1)
{ {
View_delWnd(Manager_aMonitor, A_Index, wndId) StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %wndId%`;,
Bar_updateView(Manager_aMonitor, A_Index) Bar_updateView(Manager_aMonitor, A_Index)
} }
} }

View file

@ -86,29 +86,22 @@ View_activateWindow(d)
} }
} }
View_updateLayout(m, v) { View_addWnd(m, v, wndId)
Local fn, l, wndIds {
l := View_#%m%_#%v%_layout_#1 Local i, l, msplit, n, replace, search, wndId0, wndIds
fn := Config_layoutFunction_#%l%
View_updateLayout_%fn%(m, v)
}
; Add a window to the view in question.
View_addWnd(m, v, wndId) {
Local l, msplit, i, wndIds, n
l := View_#%m%_#%v%_layout_#1 l := View_#%m%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) { If (Config_layoutFunction_#%l% = "tile") And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop"))
{
n := View_getTiledWndIds(m, v, wndIds) n := View_getTiledWndIds(m, v, wndIds)
msplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY msplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
If ( msplit = 1 And Config_newWndPosition="masterBottom" ) { If (msplit = 1 And Config_newWndPosition = "masterBottom")
View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds
} Else If ((Config_newWndPosition = "masterBottom" And n < msplit) Or (Config_newWndPosition = "stackTop" And n <= msplit))
Else If ( (Config_newWndPosition="masterBottom" And n < msplit) Or (Config_newWndPosition="stackTop" And n <= msplit) ) {
View_#%m%_#%v%_wndIds .= wndId ";" View_#%m%_#%v%_wndIds .= wndId ";"
} Else
Else { {
If (Config_newWndPosition="masterBottom") If (Config_newWndPosition = "masterBottom")
i := msplit - 1 i := msplit - 1
Else Else
i := msplit i := msplit
@ -124,40 +117,33 @@ View_addWnd(m, v, wndId) {
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
} }
View_ghostWnd(m, v, bodyWndId, ghostWndId) { View_arrange(m, v)
Local search, replace {
search := bodyWndId ";"
replace := search ghostWndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
; Remove a window from the view in question.
View_delWnd(m, v, wndId) {
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %wndId%`;,
}
View_arrange(m, v) {
Local fn, l, wndIds Local fn, l, wndIds
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1) Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
; All window actions are performed on independent windows. A delay won't help.
;; All window actions are performed on independent windows. A delay won't help.
SetWinDelay, 0 SetWinDelay, 0
l := View_#%m%_#%v%_layout_#1 l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l% fn := Config_layoutFunction_#%l%
View_getTiledWndIds(m, v, wndIds) View_getTiledWndIds(m, v, wndIds)
View_arrange_%fn%(m, v, wndIds) View_arrange_%fn%(m, v, wndIds)
View_updateLayout(m, v) View_updateLayout_%fn%(m, v)
Bar_updateLayout(m)
SetWinDelay, 10 SetWinDelay, 10
Bar_updateLayout(m)
} }
View_getTiledWndIds(m, v, ByRef tiledWndIds) { View_getTiledWndIds(m, v, ByRef tiledWndIds)
{
Local n, wndIds Local n, wndIds
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Manager_isHung(A_LoopField) { If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Manager_isHung(A_LoopField)
{
n += 1 n += 1
tiledWndIds .= A_LoopField ";" tiledWndIds .= A_LoopField ";"
} }
@ -166,6 +152,15 @@ View_getTiledWndIds(m, v, ByRef tiledWndIds) {
Return, n Return, n
} }
View_ghostWnd(m, v, bodyWndId, ghostWndId)
{
Local search, replace
search := bodyWndId ";"
replace := search ghostWndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
View_updateLayout_(m, v) View_updateLayout_(m, v)
{ {
View_#%m%_#%v%_layoutSymbol := "><>" View_#%m%_#%v%_layoutSymbol := "><>"