box: Fit position
This commit is contained in:
parent
0ddb074efd
commit
d6d642551d
14
box.lua
14
box.lua
|
@ -10,10 +10,16 @@ local function new(args)
|
||||||
args.arrow_type = base.arrow_type.NONE
|
args.arrow_type = base.arrow_type.NONE
|
||||||
|
|
||||||
local ret = context(args)
|
local ret = context(args)
|
||||||
-- placement.centered (ret.wibox)
|
|
||||||
-- ret.wibox:set_valign("center")
|
local w = ret.wibox
|
||||||
-- ret.wibox:set_halign("center")
|
|
||||||
ret.wibox:set_shape (shape.rounded_rect, 10)
|
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
|
return ret
|
||||||
end
|
end
|
||||||
|
|
|
@ -165,6 +165,8 @@ end
|
||||||
-- @param use_mouse Use the mouse position instead of the widget center as
|
-- @param use_mouse Use the mouse position instead of the widget center as
|
||||||
-- reference point.
|
-- reference point.
|
||||||
function wb_func:move_by_parent(geo, use_mouse)
|
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)
|
local dps = placement.get_relative_points(geo, mode)
|
||||||
|
|
||||||
rawset(self, "possible_positions", dps)
|
rawset(self, "possible_positions", dps)
|
||||||
|
@ -184,6 +186,12 @@ function wb_func:set_hoffset(offset)
|
||||||
|
|
||||||
end
|
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
|
--- A brilliant idea to totally turn the whole hierarchy on its head
|
||||||
-- and create a widget that own a wibox...
|
-- and create a widget that own a wibox...
|
||||||
local function create_auto_resize_widget(self, wdg, args)
|
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 {}))
|
w:set_shape(args.shape, unpack(args.shape_args or {}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if args.relative ~= nil then
|
||||||
|
w:set_relative(args.relative)
|
||||||
|
end
|
||||||
|
|
||||||
for k,v in ipairs{"shape_border_color", "shape_border_width"} do
|
for k,v in ipairs{"shape_border_color", "shape_border_width"} do
|
||||||
if args[v] then
|
if args[v] then
|
||||||
w["set_"..v](w, args[v])
|
w["set_"..v](w, args[v])
|
||||||
|
|
Loading…
Reference in New Issue