Skip to content

Commit

Permalink
allow groupbox to be center-aligned via center_aligned parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
w1ndy authored and tych0 committed May 15, 2015
1 parent a044699 commit 0606573
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MANIFEST
/dist
# Files generated by setup.py
qtile.egg-info/
.eggs
# Vim swap files
*.swp
*.swo
Expand Down
11 changes: 9 additions & 2 deletions libqtile/widget/groupbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
class _GroupBase(base._TextBox, base.PaddingMixin, base.MarginMixin):
defaults = [
("borderwidth", 3, "Current group border width"),
("center_aligned", False, "center-aligned group box"),
]

def __init__(self, **config):
Expand Down Expand Up @@ -96,10 +97,16 @@ def drawbox(self, offset, text, bordercolor, textcolor, rounded=False,
self.padding_x,
self.padding_y
)
y = self.margin_y
if self.center_aligned:
for t in base.MarginMixin.defaults:
if t[0] == 'margin':
y += (self.bar.height - framed.height) / 2 - t[1]
break
if block:
framed.draw_fill(offset, self.margin_y, rounded)
framed.draw_fill(offset, y, rounded)
else:
framed.draw(offset, self.margin_y, rounded)
framed.draw(offset, y, rounded)


class AGroupBox(_GroupBase):
Expand Down

0 comments on commit 0606573

Please sign in to comment.