bar: Support border color
Apparently this never worked as documented
This commit is contained in:
parent
21f735600c
commit
b167117958
39
bar.lua
39
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)
|
||||
|
|
5
base.lua
5
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,
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
local setmetatable = setmetatable
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue