0

Apparently, using :setup() on a widget doesn't make use of the margin container inside it, and only shows up if the height and width properties are set. Below two examples. Both declarative style. First one working and adjusting depending on the content, second one only works with hard-coded width and height values.

This behaves as intended, first code

confirmation = awful.popup {
    widget    = {
        {
            {
                widget = wibox.widget.textbox,
                font = beautiful.barfont,
                markup = help.fg("Are you sure?", beautiful.fg, "bold"),
                halign = "center",
                align = 'center',
            },
            margins = dpi(20),
            widget = wibox.container.margin,
            {
                create_button("\u{58}", function()
                    confirmation.toggle()
                end, false),
                create_button("\u{f00c}", function()
                    confirmation.toggle()
                    run_comm(command)
                end
                    , false),
                spacing = dpi(15),
                layout = wibox.layout.fixed.horizontal,
            },
            spacing = dpi(15),
            layout = wibox.layout.fixed.vertical,
        },
        margins = dpi(20),
        widget = wibox.container.margin
    },
    shape     = help.rrect(beautiful.br),
    bg        = beautiful.bg,
    visible   = false,
    ontop     = true,
    placement = function(c)
        (awful.placement.bottom)(c,
                { margins = { bottom = beautiful.useless_gap * 2 } })
    end,
}

This look wrong. The problem is that it needs th width and height properties to define size I want this to work, as I need to use get_children_by_id() to access the id = txt widget. So using this declarative style should be the way to go.

confirmation = wibox({
    type      = "popup",
    shape     = help.rrect(beautiful.br),
    bg        = beautiful.bg,
    visible   = false,
    ontop     = true,
    placement = function(c)
        (awful.placement.bottom)(c,
                { margins = { bottom = beautiful.useless_gap * 2 } })
    end,
})

confirmation:setup({
    {
        {
            {
                id = "txt",
                widget = wibox.widget.textbox,
                font = beautiful.barfont,
                halign = "center",
                align = 'center',
            },
            margins = dpi(20),
            widget = wibox.container.margin,
        },
        {
            create_button("\u{58}", function()
                confirmation.toggle()
            end, false),
            create_button("\u{f00c}", function()
                confirmation.toggle()
                run_comm(command)
            end
                , false),
            spacing = dpi(15),
            layout = wibox.layout.fixed.horizontal,
        },
        spacing = dpi(15),
        layout = wibox.layout.fixed.vertical,
    },
    margins = dpi(20),
    widget = wibox.container.margin
})

First code Second code

Latest code "works" when

wibox({
  (...)
  width = some_value,
  height = some_value,
  (...)
})

This is hard-coded. I need a way of adjusting it to the content.

0 Answers0