Cleanup/optimization of view update code

This commit is contained in:
Joshua Fuhs 2012-06-21 18:48:37 -04:00
parent a82d486a35
commit 60267c3338

View file

@ -697,28 +697,34 @@ Bar_updateTitle(debugMsg = "") {
Bar_aWndId := aWndId
}
; Update the view portion of the status bar.
Bar_updateView(m, v) {
Local managedWndId0, wndId0, wndIds
Local IdsLen, ViewIdsLen
StringTrimRight, wndIds, Manager_managedWndIds, 1
StringSplit, managedWndId, wndIds, `;
GuiN := (m - 1) + 1
Gui, %GuiN%: Default
Loop, %Config_viewCount% {
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
StringSplit, wndId, wndIds, `;
If (A_Index = v)
IdsLen := StrLen(Manager_managedWndIds)
If (v = Monitor_#%m%_aView_#1) {
; Set foreground/background colors if the view is the current view.
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
} Else If wndId0 {
} Else If StrLen(View_#%m%_#%v%_wndIds) > 0 {
; Set foreground/background colors if the view contains windows.
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
} Else {
; Set foreground/background colors if the view is empty.
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
}
GuiControl, , Bar_#%m%_#%A_Index%_tagged, % wndId0 / managedWndId0 * 100
Loop, %Config_viewCount% {
ViewIdsLen := StrLen( View_#%m%_#%A_Index%_wndIds )
; Update the percentage fill for the view.
GuiControl, , Bar_#%m%_#%A_Index%_tagged, % ViewIdsLen / IdsLen * 100
; Refresh the number on the bar.
GuiControl, , Bar_#%m%_#%A_Index%, %A_Index%
}
}