layout.margin: Avoid unneeded redraw

This commit is contained in:
Emmanuel Lepage Vallee 2016-03-26 01:40:59 -04:00
parent d2c5e36294
commit 87813a5597
1 changed files with 8 additions and 0 deletions

View File

@ -87,6 +87,13 @@ end
--- Set all the margins to val. --- Set all the margins to val.
function margin:set_margins(val) function margin:set_margins(val)
if self.left == val and
self.right == val and
self.top == val and
self.bottom == val then
return
end
self.left = val self.left = val
self.right = val self.right = val
self.top = val self.top = val
@ -142,6 +149,7 @@ end
-- Create setters for each direction -- Create setters for each direction
for _, v in pairs({ "left", "right", "top", "bottom" }) do for _, v in pairs({ "left", "right", "top", "bottom" }) do
margin["set_" .. v] = function(layout, val) margin["set_" .. v] = function(layout, val)
if layout[v] == val then return end
layout[v] = val layout[v] = val
layout:emit_signal("widget::layout_changed") layout:emit_signal("widget::layout_changed")
end end