test
This commit is contained in:
parent
3a8a55b63a
commit
000334fb96
109
libs/awmtk2.lua
109
libs/awmtk2.lua
|
@ -6,14 +6,18 @@ local beautiful = require("beautiful")
|
||||||
local awmtk = {}
|
local awmtk = {}
|
||||||
|
|
||||||
-- {{{ Utils
|
-- {{{ Utils
|
||||||
|
local debugdata = io.open("/home/yessiest/.awesome_errors","w")
|
||||||
awmtk.create_namespace = function(parent_class,instance_overrides,name)
|
awmtk.create_class = function(name,overrides,style,parent_class)
|
||||||
return setmetatable(instance_overrides,{
|
return setmetatable(overrides,{
|
||||||
__index = function(self,k)
|
__index = function(self,k)
|
||||||
|
debugdata:write(tostring(name)..": "..tostring(k).."\n")
|
||||||
|
-- Per-widget overrides are top priority
|
||||||
if rawget(self,k) then
|
if rawget(self,k) then
|
||||||
return rawget(self,k)
|
return rawget(self,k)
|
||||||
elseif type(beautiful[name]) == "table" and beautiful[name][k] then
|
-- Style overrides are second in priority
|
||||||
return beautiful[name][k]
|
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
|
elseif parent_class[k] then
|
||||||
return parent_class[k]
|
return parent_class[k]
|
||||||
end
|
end
|
||||||
|
@ -21,50 +25,65 @@ awmtk.create_namespace = function(parent_class,instance_overrides,name)
|
||||||
})
|
})
|
||||||
end
|
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
|
-- Default style
|
||||||
awmtk.default = setmetatable({
|
awmtk.default = {
|
||||||
-- { Backgrounds
|
base = setmetatable({},{
|
||||||
-- custom background color for highlighting elements
|
-- { Backgrounds
|
||||||
bg_highlight = beautiful.bg_highlight or beautiful.bg_focus,
|
-- custom background color for highlighting elements
|
||||||
-- }
|
bg_highlight = beautiful.bg_highlight or beautiful.bg_focus,
|
||||||
-- { Borders
|
-- }
|
||||||
-- Borders for popups
|
-- { Borders
|
||||||
shape_border_width = beautiful.shape_border_width or 0,
|
-- Borders for popups
|
||||||
shape_border_color = beautiful.shape_border_color or beautiful.bg_normal,
|
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
|
-- { Shapes
|
||||||
rounding = beautiful.rounding or 0
|
inner_margin = beautiful.inner_margin or 5,
|
||||||
-- }
|
rounding = beautiful.rounding or 0,
|
||||||
}, { __index = beautiful })
|
-- }
|
||||||
|
},{__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
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 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