diff --git a/box.lua b/box.lua index 3f7fe62..03e2a95 100644 --- a/box.lua +++ b/box.lua @@ -10,10 +10,16 @@ local function new(args) args.arrow_type = base.arrow_type.NONE local ret = context(args) --- placement.centered (ret.wibox) --- ret.wibox:set_valign("center") --- ret.wibox:set_halign("center") - ret.wibox:set_shape (shape.rounded_rect, 10) + + local w = ret.wibox + + w:set_shape (shape.rounded_rect, 10) + + local function f() placement.centered(w) end + + w:connect_signal("property::width" ,f) + w:connect_signal("property::height",f) + f() return ret end diff --git a/smart_wibox.lua b/smart_wibox.lua index 8a0342a..88e51f2 100644 --- a/smart_wibox.lua +++ b/smart_wibox.lua @@ -165,6 +165,8 @@ end -- @param use_mouse Use the mouse position instead of the widget center as -- reference point. function wb_func:move_by_parent(geo, use_mouse) + if rawget(self, "is_relative") == false then return end + local dps = placement.get_relative_points(geo, mode) rawset(self, "possible_positions", dps) @@ -184,6 +186,12 @@ function wb_func:set_hoffset(offset) end +--- Set if the wibox take into account the other wiboxes. +-- @tparam boolean val Take the other wiboxes position into account +function wb_func:set_relative(val) + rawset(self, "is_relative", val) +end + --- A brilliant idea to totally turn the whole hierarchy on its head -- and create a widget that own a wibox... local function create_auto_resize_widget(self, wdg, args) @@ -225,6 +233,10 @@ local function create_auto_resize_widget(self, wdg, args) w:set_shape(args.shape, unpack(args.shape_args or {})) end + if args.relative ~= nil then + w:set_relative(args.relative) + end + for k,v in ipairs{"shape_border_color", "shape_border_width"} do if args[v] then w["set_"..v](w, args[v])