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 base = require( "radical.base" )
|
||||||
local color = require( "gears.color" )
|
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local beautiful = require( "beautiful" )
|
|
||||||
local item_style = require( "radical.item.style.arrow_single" )
|
local item_style = require( "radical.item.style.arrow_single" )
|
||||||
local item_layout= require( "radical.item.layout.horizontal" )
|
local item_layout= require( "radical.item.layout.horizontal" )
|
||||||
local common = require( "radical.common" )
|
local common = require( "radical.common" )
|
||||||
|
local shape = require( "gears.shape" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
local function setup_drawable(data)
|
local function setup_drawable(data)
|
||||||
local internal = data._internal
|
local internal = data._internal
|
||||||
|
|
||||||
internal.layout = internal.layout_func or wibox.layout.fixed.horizontal()
|
-- Use a background to make the border work
|
||||||
internal.margin = wibox.layout.margin(internal.layout)
|
internal.widget = wibox.widget.base.make_widget_declarative {
|
||||||
internal.layout._data = data
|
{
|
||||||
|
{
|
||||||
if internal.layout.set_spacing and data.spacing then
|
id = "main_layout" ,
|
||||||
internal.layout:set_spacing(data.spacing)
|
spacing = data.spacing or nil,
|
||||||
end
|
_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
|
--Getters
|
||||||
data.get_visible = function() return true end
|
data.get_visible = function() return true end
|
||||||
data.get_margins = common.get_margins
|
data.get_margins = common.get_margins
|
||||||
|
function data:get_widget()
|
||||||
|
return internal.widget
|
||||||
|
end
|
||||||
|
|
||||||
|
data:get_margins()
|
||||||
|
|
||||||
if data.style then
|
if data.style then
|
||||||
data.style(data)
|
data.style(data)
|
||||||
|
@ -33,6 +49,7 @@ end
|
||||||
|
|
||||||
local function new(args)
|
local function new(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
|
args.border_width = args.border_width or 0
|
||||||
args.internal = args.internal or {}
|
args.internal = args.internal or {}
|
||||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||||
|
@ -42,7 +59,7 @@ local function new(args)
|
||||||
|
|
||||||
local ret = base(args)
|
local ret = base(args)
|
||||||
|
|
||||||
return ret,ret._internal.margin
|
return ret,ret._internal.widget
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.flex(args)
|
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 = {
|
local module = {
|
||||||
arrow_type = {
|
arrow_type = {
|
||||||
NONE = 0,
|
NONE = 0, --TODO move to theme.state or something
|
||||||
PRETTY = 1,
|
PRETTY = 1,
|
||||||
CENTERED = 2,
|
CENTERED = 2,
|
||||||
},
|
},
|
||||||
|
@ -58,6 +58,7 @@ local module = {
|
||||||
colors_by_id = theme.colors_by_id
|
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.DISABLED , "disabled" , "disabled" , true )
|
||||||
theme.register_color(module.item_flags.URGENT , "urgent" , "urgent" , true )
|
theme.register_color(module.item_flags.URGENT , "urgent" , "urgent" , true )
|
||||||
theme.register_color(module.item_flags.SELECTED , "focus" , "focus" , 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,
|
disable_markup = args.disable_markup or false,
|
||||||
x = args.x or 0,
|
x = args.x or 0,
|
||||||
y = args.y 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,
|
sub_menu_on = args.sub_menu_on or module.event.SELECTED,
|
||||||
select_on = args.select_on or module.event.HOVER,
|
select_on = args.select_on or module.event.HOVER,
|
||||||
opacity = args.opacity or beautiful.menu_opacity or 1,
|
opacity = args.opacity or beautiful.menu_opacity or 1,
|
||||||
|
|
|
@ -51,13 +51,13 @@ function module.get_margins(data)
|
||||||
|
|
||||||
if not internal._margins then
|
if not internal._margins then
|
||||||
local ret = {
|
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),
|
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),
|
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),
|
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),
|
or (data.style and data.style.margins.BOTTOM ) or 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
dock.lua
2
dock.lua
|
@ -138,7 +138,7 @@ local function new(args)
|
||||||
args.internal.layout_func = orientation == "vertical" and vertical or horizontal
|
args.internal.layout_func = orientation == "vertical" and vertical or horizontal
|
||||||
args.layout = args.layout or args.internal.layout_func
|
args.layout = args.layout or args.internal.layout_func
|
||||||
args.item_style = args.item_style or item.style
|
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
|
args[length_inv] = args[length_inv] or 40
|
||||||
|
|
||||||
-- Create the dock
|
-- Create the dock
|
||||||
|
|
|
@ -11,6 +11,7 @@ local common = require( "radical.item.common" )
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
local function after_draw_children(self, context, cr, width, height)
|
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
|
--TODO get rid of this, use the stack container
|
||||||
if self._item.overlay_draw then
|
if self._item.overlay_draw then
|
||||||
self._item.overlay_draw(context,self._item,cr,width,height)
|
self._item.overlay_draw(context,self._item,cr,width,height)
|
||||||
|
|
|
@ -56,4 +56,4 @@ local function new(widget,defaults)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local base = require( "radical.base" )
|
local base = require( "radical.base" )
|
||||||
local color = require( "gears.color" )
|
local color = require( "gears.color" )
|
||||||
|
local shape = require( "gears.shape" )
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
margins = {
|
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:save()
|
||||||
cr:translate(x,y)
|
cr:translate(x,y)
|
||||||
cr:move_to(0,radius)
|
cr:move_to(0,radius)
|
||||||
|
|
Loading…
Reference in New Issue