test
This commit is contained in:
parent
3a8a55b63a
commit
000334fb96
|
@ -6,14 +6,18 @@ local beautiful = require("beautiful")
|
|||
local awmtk = {}
|
||||
|
||||
-- {{{ Utils
|
||||
|
||||
awmtk.create_namespace = function(parent_class,instance_overrides,name)
|
||||
return setmetatable(instance_overrides,{
|
||||
local debugdata = io.open("/home/yessiest/.awesome_errors","w")
|
||||
awmtk.create_class = function(name,overrides,style,parent_class)
|
||||
return setmetatable(overrides,{
|
||||
__index = function(self,k)
|
||||
debugdata:write(tostring(name)..": "..tostring(k).."\n")
|
||||
-- Per-widget overrides are top priority
|
||||
if rawget(self,k) then
|
||||
return rawget(self,k)
|
||||
elseif type(beautiful[name]) == "table" and beautiful[name][k] then
|
||||
return beautiful[name][k]
|
||||
-- Style overrides are second in priority
|
||||
elseif type(style[name]) == "table" and rawget(style[name],k) then
|
||||
return rawget(style[name],k)
|
||||
-- Parent class is fallback
|
||||
elseif parent_class[k] then
|
||||
return parent_class[k]
|
||||
end
|
||||
|
@ -21,15 +25,35 @@ awmtk.create_namespace = function(parent_class,instance_overrides,name)
|
|||
})
|
||||
end
|
||||
|
||||
awmtk.create_class = function
|
||||
awmtk.create_style = function(name,parent,overrides)
|
||||
local new_style = setmetatable(beautiful[name] or {},{
|
||||
__index = function(self,k)
|
||||
if rawget(self,k) then
|
||||
return rawget(self,k)
|
||||
else
|
||||
return parent[k]
|
||||
end
|
||||
end
|
||||
})
|
||||
for name,parent_class in pairs(parent) do
|
||||
new_style[name] = awmtk.create_class(
|
||||
name,
|
||||
(overrides and overrides[name]) or {},
|
||||
new_style,
|
||||
parent_class
|
||||
)
|
||||
end
|
||||
return new_style
|
||||
end
|
||||
|
||||
-- }}}
|
||||
|
||||
|
||||
-- {{{ Classes and namespaces
|
||||
-- {{{ Default style
|
||||
|
||||
-- Default namespace
|
||||
awmtk.default = setmetatable({
|
||||
-- Default style
|
||||
awmtk.default = {
|
||||
base = setmetatable({},{
|
||||
-- { Backgrounds
|
||||
-- custom background color for highlighting elements
|
||||
bg_highlight = beautiful.bg_highlight or beautiful.bg_focus,
|
||||
|
@ -40,31 +64,26 @@ awmtk.default = setmetatable({
|
|||
shape_border_color = beautiful.shape_border_color or beautiful.bg_normal,
|
||||
-- }
|
||||
-- { Shapes
|
||||
inner_margin = beautiful.inner_margin or 5
|
||||
rounding = beautiful.rounding or 0
|
||||
inner_margin = beautiful.inner_margin or 5,
|
||||
rounding = beautiful.rounding or 0,
|
||||
-- }
|
||||
}, { __index = beautiful })
|
||||
|
||||
-- Container subnamespace
|
||||
-- We copy the table instead of referncing default namespace to avoid recursion
|
||||
awmtk.default.container = setmetatable({
|
||||
-- { Backgrounds
|
||||
-- custom background color for highlighting elements
|
||||
bg_highlight = beautiful.bg_highlight or beautiful.bg_focus,
|
||||
-- }
|
||||
-- { Borders
|
||||
-- Borders for popups
|
||||
shape_border_width = beautiful.shape_border_width or 0,
|
||||
shape_border_color = beautiful.shape_border_color or beautiful.bg_normal,
|
||||
-- }
|
||||
-- { Shapes
|
||||
inner_margin = beautiful.inner_margin or 5
|
||||
rounding = beautiful.rounding or 0
|
||||
-- }
|
||||
-- { Layout spacing
|
||||
spacing = (beautiful.container and beautiful.container.spacing) or 2
|
||||
},{
|
||||
__index = beautiful
|
||||
})
|
||||
},{__index = beautiful})
|
||||
}
|
||||
|
||||
|
||||
-- Container subclass
|
||||
awmtk.default.container = awmtk.create_class("container",{
|
||||
},awmtk.default,awmtk.default.base)
|
||||
|
||||
-- Button subclass
|
||||
awmtk.default.button = awmtk.create_class("button",{
|
||||
inner_margin = 1
|
||||
},awmtk.default,awmtk.default.base)
|
||||
|
||||
-- Icon subclass
|
||||
awmtk.default.icon = awmtk.create_class("icon",{
|
||||
inner_margin = 1
|
||||
},awmtk.default,awmtk.default.base)
|
||||
|
||||
return awmtk
|
||||
-- }}}
|
||||
|
|
Loading…
Reference in New Issue