diff --git a/bar.lua b/bar.lua index 794e5e2..308b410 100644 --- a/bar.lua +++ b/bar.lua @@ -1,28 +1,44 @@ -local setmetatable,unpack,table = setmetatable,unpack,table +local setmetatable = setmetatable local base = require( "radical.base" ) -local color = require( "gears.color" ) local wibox = require( "wibox" ) -local beautiful = require( "beautiful" ) local item_style = require( "radical.item.style.arrow_single" ) local item_layout= require( "radical.item.layout.horizontal" ) local common = require( "radical.common" ) +local shape = require( "gears.shape" ) local module = {} local function setup_drawable(data) local internal = data._internal - internal.layout = internal.layout_func or wibox.layout.fixed.horizontal() - internal.margin = wibox.layout.margin(internal.layout) - internal.layout._data = data - - if internal.layout.set_spacing and data.spacing then - internal.layout:set_spacing(data.spacing) - end + -- Use a background to make the border work + internal.widget = wibox.widget.base.make_widget_declarative { + { + { + id = "main_layout" , + spacing = data.spacing or nil, + _data = data , + layout = internal.layout_func or wibox.layout.fixed.horizontal + }, + id = "main_margin" , + layout = wibox.layout.margin, + }, + shape = data.shape or shape.rectangle or nil, + shape_border_width = data.border_width , + shape_border_color = data.border_color , + widget = wibox.widget.background , + } + internal.layout = internal.widget:get_children_by_id("main_layout")[1] + internal.margin = internal.widget:get_children_by_id("main_margin")[1] --Getters data.get_visible = function() return true end data.get_margins = common.get_margins + function data:get_widget() + return internal.widget + end + + data:get_margins() if data.style then data.style(data) @@ -33,6 +49,7 @@ end local function new(args) local args = args or {} + args.border_width = args.border_width or 0 args.internal = args.internal or {} args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable args.internal.setup_item = args.internal.setup_item or common.setup_item @@ -42,7 +59,7 @@ local function new(args) local ret = base(args) - return ret,ret._internal.margin + return ret,ret._internal.widget end function module.flex(args) diff --git a/base.lua b/base.lua index aee3acb..a80b744 100644 --- a/base.lua +++ b/base.lua @@ -16,7 +16,7 @@ local capi = { mouse = mouse, screen = screen , keygrabber = keygrabber, root=ro local module = { arrow_type = { - NONE = 0, + NONE = 0, --TODO move to theme.state or something PRETTY = 1, CENTERED = 2, }, @@ -58,6 +58,7 @@ local module = { colors_by_id = theme.colors_by_id } +--TODO move to theme/init.lua theme.register_color(module.item_flags.DISABLED , "disabled" , "disabled" , true ) theme.register_color(module.item_flags.URGENT , "urgent" , "urgent" , true ) theme.register_color(module.item_flags.SELECTED , "focus" , "focus" , true ) @@ -354,6 +355,8 @@ local function new(args) disable_markup = args.disable_markup or false, x = args.x or 0, y = args.y or 0, + shape = args.shape or nil, + item_shape = args.item_shape, sub_menu_on = args.sub_menu_on or module.event.SELECTED, select_on = args.select_on or module.event.HOVER, opacity = args.opacity or beautiful.menu_opacity or 1, diff --git a/common.lua b/common.lua index 5985b33..862d770 100644 --- a/common.lua +++ b/common.lua @@ -51,13 +51,13 @@ function module.get_margins(data) if not internal._margins then local ret = { - left = data.border_width+(data.default_margins.left + left = ((data.default_margins.left or data.default_margins.LEFT) or (data.style and data.style.margins.LEFT ) or 0), - right = data.border_width+(data.default_margins.right + right = ((data.default_margins.right or data.default_margins.RIGHT) or (data.style and data.style.margins.RIGHT ) or 0), - top = data.border_width+(data.default_margins.top + top = ((data.default_margins.top or data.default_margins.TOP) or (data.style and data.style.margins.TOP ) or 0), - bottom = data.border_width+(data.default_margins.bottom + bottom = ((data.default_margins.bottom or data.default_margins.BOTTOM) or (data.style and data.style.margins.BOTTOM ) or 0), } diff --git a/dock.lua b/dock.lua index ae061ee..0a71524 100644 --- a/dock.lua +++ b/dock.lua @@ -138,7 +138,7 @@ local function new(args) args.internal.layout_func = orientation == "vertical" and vertical or horizontal args.layout = args.layout or args.internal.layout_func args.item_style = args.item_style or item.style - args.item_layout = args.item_layout or item_layout + args.item_layout = args.item_layout or item_layout args[length_inv] = args[length_inv] or 40 -- Create the dock diff --git a/item/layout/icon.lua b/item/layout/icon.lua index 4ff40fd..5321fdb 100644 --- a/item/layout/icon.lua +++ b/item/layout/icon.lua @@ -11,6 +11,7 @@ local common = require( "radical.item.common" ) local module = {} local function after_draw_children(self, context, cr, width, height) + wibox.widget.background.after_draw_children(self, context, cr, width, height) --TODO get rid of this, use the stack container if self._item.overlay_draw then self._item.overlay_draw(context,self._item,cr,width,height) diff --git a/margins.lua b/margins.lua index 1c7126d..466ed27 100644 --- a/margins.lua +++ b/margins.lua @@ -56,4 +56,4 @@ local function new(widget,defaults) end return setmetatable(module, { __call = function(_, ...) return new(...) end }) --- kate: space-indent on; indent-width 2; replace-tabs on; \ No newline at end of file +-- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/style/grouped_3d.lua b/style/grouped_3d.lua index 0c36ff0..ec82215 100644 --- a/style/grouped_3d.lua +++ b/style/grouped_3d.lua @@ -1,6 +1,7 @@ local setmetatable = setmetatable -local base = require( "radical.base" ) -local color = require( "gears.color" ) +local base = require( "radical.base" ) +local color = require( "gears.color" ) +local shape = require( "gears.shape" ) local module = { margins = { @@ -11,7 +12,7 @@ local module = { } } -local function rounded_rect(cr,x,y,w,h,radius) +local function rounded_rect(cr,x,y,w,h,radius) --TODO port to shape API cr:save() cr:translate(x,y) cr:move_to(0,radius)