rect_to_device_geometry: Use gears.matrix.transform_rectangle
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
19b9bfc46e
commit
3685077291
|
@ -8,6 +8,7 @@
|
||||||
local debug = require("gears.debug")
|
local debug = require("gears.debug")
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
local cache = require("gears.cache")
|
local cache = require("gears.cache")
|
||||||
|
local matrix = require("gears.matrix")
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -18,16 +19,7 @@ local base = {}
|
||||||
--- Figure out the geometry in device coordinate space. This gives only tight
|
--- Figure out the geometry in device coordinate space. This gives only tight
|
||||||
-- bounds if no rotations by non-multiples of 90° are used.
|
-- bounds if no rotations by non-multiples of 90° are used.
|
||||||
function base.rect_to_device_geometry(cr, x, y, width, height)
|
function base.rect_to_device_geometry(cr, x, y, width, height)
|
||||||
local x1, y1 = cr:user_to_device(x, y)
|
return matrix.transform_rectangle(cr.matrix, x, y, width, height)
|
||||||
local x2, y2 = cr:user_to_device(x, y + height)
|
|
||||||
local x3, y3 = cr:user_to_device(x + width, y + height)
|
|
||||||
local x4, y4 = cr:user_to_device(x + width, y)
|
|
||||||
local x = math.min(x1, x2, x3, x4)
|
|
||||||
local y = math.min(y1, y2, y3, y4)
|
|
||||||
local width = math.max(x1, x2, x3, x4) - x
|
|
||||||
local height = math.max(y1, y2, y3, y4) - y
|
|
||||||
|
|
||||||
return x, y, width, height
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set/get a widget's buttons
|
--- Set/get a widget's buttons
|
||||||
|
|
Loading…
Reference in New Issue