Cleaned up tagger code

This commit is contained in:
2022-04-24 12:57:41 -07:00
parent 58b2df6956
commit 9a13f2406d
5 changed files with 118 additions and 94 deletions

View File

@ -1,68 +0,0 @@
local tagindicator = {}
tagindicator.make = function(screen)
local widget
-- Create tag tagindicators
-- We're using flex.vertical and flex.horizontal layouts because the grid
-- layout doesn't expand things properly.
screen.tagindicators = {}
screen.tagindicator = wibox.widget {
homogeneous = true,
spacing = beautiful.dpi(2),
min_cols_size = 10,
min_rows_size = 10,
layout = wibox.layout.grid
}
local tmp_row
for r=1, screen.tagger.rows do
for c=1, screen.tagger.cols do
screen.tagindicators[(c + (screen.tagger.cols * (r - 1)))] = wibox.widget {
checked = false,
border_width = beautiful.dpi(2),
paddings = beautiful.dpi(3),
color = beautiful.color.bar.active,
border_color = beautiful.color.bar.inactive,
widget = wibox.widget.checkbox
}
-- Calculate checkbox size limit
local cbox_maxsize = beautiful.dpi(conf.bar_height)
cbox_maxsize = cbox_maxsize - (2 * beautiful.dpi(conf.bar_margin))
cbox_maxsize = cbox_maxsize - (screen.tagger.rows - 1)*(beautiful.dpi(screen.tagindicator.spacing))
if ((conf.bar_position == "bottom") or (conf.bar_position == "top")) then
cbox_maxsize = cbox_maxsize / screen.tagger.rows
else
cbox_maxsize = cbox_maxsize / screen.tagger.cols
end
screen.tagindicator:add_widget_at(
-- The constraint container is VERY necessary here!
-- Otherwise, the checkboxes will fill all the height that is available to them.
wibox.container.constraint(
screen.tagindicators[(c + (screen.tagger.cols * (r - 1)))],
"exact", cbox_maxsize, cbox_maxsize
), r, c)
end
end
widget = wibox.widget {
screen.tagindicator,
layout = wibox.container.background
}
-- Change background when mouse is over widget
widget:connect_signal("mouse::enter", function(result)
widget.bg = beautiful.color.bar.hover_bg
end)
widget:connect_signal("mouse::leave", function(result)
widget.bg = beautiful.color.transparent
end)
return widget
end
return tagindicator.make