add "gravity" option for bar

A bar must be full-screen-width (or height, for vertical bars) to
have an "exclusive zone", otherwise it appears on top of other windows
instead of moving them out of the way. To right-justify (or bottom-
justify) the indicators in a bar, add :gravity :end to its options

Am *probably* going to get rid of this again, in favour of adding
support for "spacers" in the bar - then the same bar could contain
both left- and right-justified indicators
phoen
Daniel Barlow 2022-04-05 21:09:52 +00:00
parent c426bf7893
commit 8d8c65e5b3
2 changed files with 11 additions and 2 deletions

View File

@ -23,8 +23,12 @@
(bar
{
:anchor [:top :right]
;; bar must be full width to set up an "exclusive zone" (moves
;; other windows out of the way), otherwise it will display on
;; to of whatever's on the screen already
:anchor [:top :right :left]
:orientation :horizontal
:gravity :end
:classes ["hey"]
:indicators
[

View File

@ -135,7 +135,9 @@
(local bars [])
(fn bar [{ : anchor : orientation : indicators : classes }]
(fn bar [{: anchor : orientation : indicators
: gravity
: classes }]
(let [window (Gtk.Window {} )
orientation (match orientation
:vertical Gtk.Orientation.VERTICAL
@ -145,6 +147,9 @@
(add-css-classes ["bar"])
(add-css-classes (or classes [])))
(if (= gravity :end)
(box:pack_start (Gtk.EventBox) true true 0))
(table.insert bars { : window : anchor : indicators })
(each [_ i (ipairs indicators)]
(box:pack_start i.button false false 0))