2022-02-09 14:47:30 +00:00
|
|
|
local awful = require("awful")
|
|
|
|
local wibox = require("wibox")
|
|
|
|
local awmtk = require("awmtk")
|
|
|
|
|
|
|
|
return function(args)
|
|
|
|
local style = awmtk.style(awmtk.defaults, args.style or {},"drawer_")
|
|
|
|
local contained_widget = {
|
|
|
|
id = "contents",
|
|
|
|
widget = wibox.container.background,
|
|
|
|
layout = (args.vertical and wibox.layout.fixed.vertical) or
|
|
|
|
wibox.layout.fixed.horizontal,
|
|
|
|
visible = false
|
|
|
|
}
|
|
|
|
for k,v in ipairs(args) do
|
|
|
|
table.insert(contained_widget,v)
|
|
|
|
end
|
|
|
|
local widget = style.icon {
|
|
|
|
contained_widget,
|
|
|
|
{
|
|
|
|
widget = wibox.widget.imagebox,
|
2022-02-13 03:32:35 +00:00
|
|
|
image = style["drawer_closed_icon"],
|
2022-02-09 14:47:30 +00:00
|
|
|
id = "widget_toggle",
|
|
|
|
resize = true
|
|
|
|
},
|
|
|
|
layout = (args.vertical and wibox.layout.fixed.vertical) or
|
|
|
|
wibox.layout.fixed.horizontal,
|
|
|
|
spacing = style.drawer_container_spacing_horizontal
|
|
|
|
}
|
|
|
|
widget:get_children_by_id("widget_toggle")[1]:buttons(
|
|
|
|
awful.util.table.join(
|
|
|
|
awful.button({},1,function()
|
|
|
|
local subwidget = widget:get_children_by_id("contents")[1]
|
2022-02-13 03:32:35 +00:00
|
|
|
local image = widget:get_children_by_id("widget_toggle")[1]
|
|
|
|
if not subwidget.visible then
|
|
|
|
image.image = style["drawer_open_icon"]
|
|
|
|
else
|
|
|
|
image.image = style["drawer_closed_icon"]
|
|
|
|
end
|
2022-02-09 14:47:30 +00:00
|
|
|
subwidget.visible = not subwidget.visible
|
2022-02-13 03:32:35 +00:00
|
|
|
|
2022-02-09 14:47:30 +00:00
|
|
|
end)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return widget
|
|
|
|
end
|