0

Is it posible in awesome wm to draw widget upper the other widget? As example: draw texbox with some text(percentages) on progressbar.

Here is worked solution

local function make_stack(w1, w2)
    local ret = wibox.widget.base.make_widget()

    ret.fit = function(self, ...) return w1:fit(...) end
    ret.draw = function(self, wibox, cr, width, height)
        w1:draw(wibox, cr, width, height)
        w2:draw(wibox, cr, width, height)
    end

    update = function() ret:emit_signal("widget::updated") end
    w1:connect_signal("widget::updated", update)
    w2:connect_signal("widget::updated", update)

    return ret
end
sinsuren
  • 1,745
  • 2
  • 23
  • 26

1 Answers1

0

There is nothing like this built-in, but you can write it yourself (untested):

function make_stack(w1, w2)
  local ret = wibox.widget.base.make_widget()

  local update = function() ret:emit_signal("widget::updated") end
  w1:connect_signal("widget::updated", update)
  w2:connect_signal("widget::updated", update)

  ret.fit = function(self, ...) return w2:fit(...) end
  ret.draw = function(self, wibox, cr, width, height)
    wibox.layout.base.draw_widget(wibox, cr, w1, 0, 0, width, height)
    wibox.layout.base.draw_widget(wibox, cr, w2, 0, 0, width, height)
  end

  return ret
end

The function make_stack(w1, w2) creates a new widget that draws w2 ontop of w1. The widget w2 decides about the size that both widgets get, as can be seen in the fit function.

This can be used, for example, like this: left_layout:add(make_stack(mytasklist[s], mytextclock))

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39