From 9a539e10af3fefa6c06573287cc3a1bbe13e5c06 Mon Sep 17 00:00:00 2001 From: joten Date: Tue, 27 Jan 2015 22:13:03 +0100 Subject: [PATCH] Re-implemented "View_setLayout" ... allowing to set absolute and relative values --- doc/Default_hotkeys.md | 5 +++-- src/Bar.ahk | 2 +- src/View.ahk | 20 +++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/Default_hotkeys.md b/doc/Default_hotkeys.md index 321b6f0..1dd0ba0 100644 --- a/doc/Default_hotkeys.md +++ b/doc/Default_hotkeys.md @@ -105,8 +105,9 @@ two log messages (`Manager_logViewWindowList` and ### Layout management `#Tab::View_setLayout(-1)` -> Set the previously set layout. You may also use `View_setLayout(>)` for -setting the next layout in the layout array. +> Set the previously set layout. You may also use `View_setLayout(0, +1)` for +setting the next or `View_setLayout(0, -1)` for setting the previous layout in +the layout array. `#f::View_setLayout(3)` > Set the 3rd defined layout (i. e. floating layout diff --git a/src/Bar.ahk b/src/Bar.ahk index c3aaa88..0613367 100644 --- a/src/Bar.ahk +++ b/src/Bar.ahk @@ -318,7 +318,7 @@ Bar_GuiContextMenu: { If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) - View_setLayout(">") + View_setLayout(0, +1) } Else If (SubStr(A_GuiControl, -4) = "_view") { diff --git a/src/View.ahk b/src/View.ahk index ff7b1e3..b8793b8 100644 --- a/src/View.ahk +++ b/src/View.ahk @@ -225,21 +225,19 @@ View_setGapWidth(d) } } -View_setLayout(l) -{ +View_setLayout(i, d = 0) { Local v v := Monitor_#%Manager_aMonitor%_aView_#1 - If (l = -1) - l := View_#%Manager_aMonitor%_#%v%_layout_#2 - If (l = ">") - l := Manager_loop(View_#%Manager_aMonitor%_#%v%_layout_#1, +1, 1, Config_layoutCount) - If (l > 0) And (l <= Config_layoutCount) - { - If Not (l = View_#%Manager_aMonitor%_#%v%_layout_#1) - { + If (i = -1) + i := View_#%Manager_aMonitor%_#%v%_layout_#2 + Else If (i = 0) + i := View_#%Manager_aMonitor%_#%v%_layout_#1 + i := Manager_loop(i, d, 1, Config_layoutCount) + If (i > 0) And (i <= Config_layoutCount) { + If Not (i = View_#%Manager_aMonitor%_#%v%_layout_#1) { View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1 - View_#%Manager_aMonitor%_#%v%_layout_#1 := l + View_#%Manager_aMonitor%_#%v%_layout_#1 := i } View_arrange(Manager_aMonitor, v, True) }