feat(awful: widget: calendar_popup): implement 'margin' widget property (#2010)

This commit is contained in:
Yauhen Kirylau 2017-08-27 14:23:43 +02:00 committed by Daniel Hahler
parent ec08af4e76
commit fd66d12a4b
1 changed files with 9 additions and 4 deletions

View File

@ -171,6 +171,7 @@ end
-- @treturn number,number,number,number Geometry of the calendar, list of x, y, width, height -- @treturn number,number,number,number Geometry of the calendar, list of x, y, width, height
local function get_geometry(widget, screen, position) local function get_geometry(widget, screen, position)
local pos, s = position or "cc", screen or ascreen.focused() local pos, s = position or "cc", screen or ascreen.focused()
local margin = widget._calendar_margin or 0
local wa = s.workarea local wa = s.workarea
local width, height = widget:fit({screen=s, dpi=beautiful.xresources.get_dpi(s)}, wa.width, wa.height) local width, height = widget:fit({screen=s, dpi=beautiful.xresources.get_dpi(s)}, wa.width, wa.height)
@ -183,16 +184,16 @@ local function get_geometry(widget, screen, position)
-- bl, bc, br -- bl, bc, br
local x,y local x,y
if pos:sub(1,1) == "t" then if pos:sub(1,1) == "t" then
y = wa.y y = wa.y + margin
elseif pos:sub(1,1) == "b" then elseif pos:sub(1,1) == "b" then
y = wa.y + wa.height - height y = wa.y + wa.height - (height + margin)
else --if pos:sub(1,1) == "c" then else --if pos:sub(1,1) == "c" then
y = wa.y + math.floor((wa.height - height) / 2) y = wa.y + math.floor((wa.height - height) / 2)
end end
if pos:sub(2,2) == "l" then if pos:sub(2,2) == "l" then
x = wa.x x = wa.x + margin
elseif pos:sub(2,2) == "r" then elseif pos:sub(2,2) == "r" then
x = wa.x + wa.width - width x = wa.x + wa.width - (width + margin)
else --if pos:sub(2,2) == "c" then else --if pos:sub(2,2) == "c" then
x = wa.x + math.floor((wa.width - width) / 2) x = wa.x + math.floor((wa.width - width) / 2)
end end
@ -272,6 +273,7 @@ end
-- @tparam string args.bg Wibox background color -- @tparam string args.bg Wibox background color
-- @tparam string args.font Calendar font -- @tparam string args.font Calendar font
-- @tparam number args.spacing Calendar spacing -- @tparam number args.spacing Calendar spacing
-- @tparam number args.margin Margin around calendar widget
-- @tparam boolean args.week_numbers Show weeknumbers -- @tparam boolean args.week_numbers Show weeknumbers
-- @tparam boolean args.start_sunday Start week on Sunday -- @tparam boolean args.start_sunday Start week on Sunday
-- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two -- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two
@ -304,6 +306,7 @@ local function get_cal_wibox(caltype, args)
start_sunday = args.start_sunday, start_sunday = args.start_sunday,
long_weekdays = args.long_weekdays, long_weekdays = args.long_weekdays,
fn_embed = embed(parse_all_options(args)), fn_embed = embed(parse_all_options(args)),
_calendar_margin = args.margin,
widget = caltype == "year" and wibox.widget.calendar.year or wibox.widget.calendar.month widget = caltype == "year" and wibox.widget.calendar.year or wibox.widget.calendar.month
} }
ret:set_widget(widget) ret:set_widget(widget)
@ -335,6 +338,7 @@ end
-- @tparam string args.bg Wibox background color -- @tparam string args.bg Wibox background color
-- @tparam string args.font Calendar font -- @tparam string args.font Calendar font
-- @tparam number args.spacing Calendar spacing -- @tparam number args.spacing Calendar spacing
-- @tparam number args.margin Margin around calendar widget
-- @tparam boolean args.week_numbers Show weeknumbers -- @tparam boolean args.week_numbers Show weeknumbers
-- @tparam boolean args.start_sunday Start week on Sunday -- @tparam boolean args.start_sunday Start week on Sunday
-- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two -- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two
@ -368,6 +372,7 @@ end
-- @tparam string args.bg Wibox background color -- @tparam string args.bg Wibox background color
-- @tparam string args.font Calendar font -- @tparam string args.font Calendar font
-- @tparam number args.spacing Calendar spacing -- @tparam number args.spacing Calendar spacing
-- @tparam number args.margin Margin around calendar widget
-- @tparam boolean args.week_numbers Show weeknumbers -- @tparam boolean args.week_numbers Show weeknumbers
-- @tparam boolean args.start_sunday Start week on Sunday -- @tparam boolean args.start_sunday Start week on Sunday
-- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two -- @tparam boolean args.long_weekdays Format the weekdays with three characters instead of two