From 4683fa672d549509f01f356cac54172efbb0ba01 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 23 Dec 2014 14:55:54 -0500 Subject: [PATCH] Add a 'rounded' style for bar menus --- style/grouped_3d.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++ style/init.lua | 1 + 2 files changed, 49 insertions(+) create mode 100644 style/grouped_3d.lua diff --git a/style/grouped_3d.lua b/style/grouped_3d.lua new file mode 100644 index 0000000..6dbe625 --- /dev/null +++ b/style/grouped_3d.lua @@ -0,0 +1,48 @@ +local setmetatable = setmetatable +local base = require( "radical.base" ) +local color = require( "gears.color" ) + +local module = { + margins = { + TOP = 0 , + BOTTOM = 0 , + LEFT = 0 , + BOTTOM = 0 , + } +} + +local function rounded_rect(cr,x,y,w,h,radius) + cr:save() + cr:translate(x,y) + cr:move_to(0,radius) + cr:arc(radius,radius,radius,math.pi,3*(math.pi/2)) + cr:arc(w-radius,radius,radius,3*(math.pi/2),math.pi*2) + cr:arc(w-radius,h-radius,radius,math.pi*2,math.pi/2) + cr:arc(radius,h-radius,radius,math.pi/2,math.pi) + cr:close_path() + cr:restore() +end + +local function draw2(self,w, cr, width, height) + cr:save() + cr:set_source_rgba(1,0,0,1) + local mx,my = self.left or 0, self.top or 0 + local mw,mh = width - mx - (self.right or 0), height - my - (self.bottom or 0) + rounded_rect(cr,mx,my,mw,mh,6) + cr:clip() + self.___draw(self,w, cr, width, height) + cr:restore() +end + +local function draw(data) + if not data._internal then return end + + local m = data._internal.margin + if m then + m.___draw = m.draw + m.draw = draw2 + end +end + +return setmetatable(module, { __call = function(_, ...) return draw(...) end }) +-- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/style/init.lua b/style/init.lua index af1e30a..80c573a 100644 --- a/style/init.lua +++ b/style/init.lua @@ -1,4 +1,5 @@ return { arrow = require( "radical.style.arrow" ), classic = require( "radical.style.classic" ), + grouped_3d = require( "radical.style.grouped_3d" ), } \ No newline at end of file