box: Fit position
This commit is contained in:
parent
d43e1170d1
commit
b528ec9730
14
box.lua
14
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
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue