Skip to content

Commit

Permalink
docs(visual_guide): add examples for focus_nth_tab(), focus_nth_window()
Browse files Browse the repository at this point in the history
  • Loading branch information
aravinda0 committed Jul 3, 2024
1 parent 93a8f3b commit f512a9d
Show file tree
Hide file tree
Showing 3 changed files with 1,381 additions and 0 deletions.
122 changes: 122 additions & 0 deletions scripts/generate_visual_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class ExampleTree(Tree):
Notes:
The examples primarily use all the functionality from the core Tree class to
generate examples. Except for a few things.
The branch-selection mode is a UI-driven feature implemented in the qtile layer,
outside the core Tree. So we kind of fake its behavior in a simple manner here.
Same goes for `focus_nth_tab()`/`focus_nth_window()`
"""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -547,6 +549,126 @@ def build_context_fragment(self):
}


class EgFocusNthTab1(Example):
section = "Focus nth Tab"

def build_context_fragment(self):
lhs = make_tree()
lp1 = lhs.tab()
_ = lhs.tab()
lp3 = lhs.tab()
lhs.focus(lp1)

rhs = lhs.clone()
rhs.focus(rhs.node(lp3.id))
rhs.command = "focus_nth_tab(3)"

return {
"lhs": lhs,
"rhs_items": [rhs],
}


class EgFocusNthTab2(Example):
section = "Focus nth Tab"

def build_context_fragment(self):
lhs = make_tree()
lp1 = lhs.tab()
lp2 = lhs.split(lp1, "x")
lp3 = lhs.split(lp2, "y")
lp4 = lhs.tab(lp3, new_level=True)
lp5 = lhs.tab(lp4)
lp6 = lhs.tab(lp1, level=1)
lhs.focus(lp3)

rhs1 = lhs.clone()
rhs1.focus(rhs1.node(lp4.id))
rhs1.command = "focus_nth_tab(2) / focus_nth_tab(2, level=-1)"

rhs2 = lhs.clone()
rhs2.focus(rhs2.node(lp6.id))
rhs2.command = "focus_nth_tab(2, level=1)"

return {
"lhs": lhs,
"rhs_items": [rhs1, rhs2],
}


class EgFocusNthWindow1(Example):
section = "Focus nth Window"

def build_context_fragment(self):
lhs = make_tree()
lp1 = lhs.tab()
lp2 = lhs.split(lp1, "x")
lp3 = lhs.split(lp2, "y")
lhs.focus(lp1)

rhs = lhs.clone()
rhs.focus(rhs.node(lp3.id))
rhs.command = "focus_nth_window(3)"

return {
"lhs": lhs,
"rhs_items": [rhs],
}


class EgFocusNthWindow2(Example):
section = "Focus nth Window"

def build_context_fragment(self):
lhs = make_tree()
_ = lhs.tab()
lp2 = lhs.tab()
lp3 = lhs.split(lp2, "x")
lp4 = lhs.split(lp3, "y")
lhs.focus(lp2)

rhs1 = lhs.clone()
rhs1.focus(rhs1.node(lp3.id))
rhs1.command = "focus_nth_window(3)"

rhs2 = lhs.clone()
rhs2.focus(rhs2.node(lp4.id))
rhs2.command = "focus_nth_window(3, ignore_inactive_tabs_at_levels=[1])"

return {
"lhs": lhs,
"rhs_items": [rhs1, rhs2],
}


class EgFocusNthWindow3(Example):
section = "Focus nth Window"

def build_context_fragment(self):
lhs = make_tree()
lp1 = lhs.tab()
lp2 = lhs.split(lp1, "x")
lp3 = lhs.split(lp2, "y")
lp4 = lhs.tab(lp3, new_level=True)
lp5 = lhs.tab(lp4)
_ = lhs.tab(lp1, level=1)
lhs.focus(lp5)
lhs.focus(lp1)

rhs1 = lhs.clone()
rhs1.focus(rhs1.node(lp3.id))
rhs1.command = "focus_nth_window(3)"

rhs2 = lhs.clone()
rhs2.focus(rhs2.node(lp5.id))
rhs2.command = "focus_nth_window(3, ignore_inactive_tabs_at_levels=[1,2])"

return {
"lhs": lhs,
"rhs_items": [rhs1, rhs2],
}


class EgAdvanced1(Example):
section = "Advanced Options for Branch Selection"

Expand Down
9 changes: 9 additions & 0 deletions static/visual_guide/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ footer {
font-size: 0.75rem;
}

.example-focus_nth_window_2 :nth-child(2 of .command-label) {
font-size: 0.7rem;
padding-left: 3rem;
}
.example-focus_nth_window_3 :nth-child(2 of .command-label) {
font-size: 0.7rem;
padding-left: 3rem;
}

.example-advanced_1 .command-label {
font-size: 0.7rem;
margin-bottom: 1rem;
Expand Down
Loading

0 comments on commit f512a9d

Please sign in to comment.