Dk75 background.module (en)

From Conky PitStop

Revision as of 00:39, 30 June 2012 by DK75 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

dk75_background.module

User:DK75

 Language   English   Français   


Background for One4All project

LUA background under the clocks (both yellow and green)

Dk75 background.module-1.1.tar.gz

--[[
Module for drawing background under Conky window - it's only interface for built-in one4all function.
You can draw as many background as possible with many modules loaded or with one, but with many setting tables.
When copied from available/ to active/ change it's name to which would be listed as first in directory, eg. "01_background.module"

changelog:
v1.1	- (21-06-2012) draw_bg function moved from functions lib to this module
v1.0	- (21-06-2012) initial release
--]]

local modname = ...
local M = {}
_G[modname] = M
package.loaded[modname] = M



--[[
###############################################################################
###                              SETTINGS                                   ###
###############################################################################
--]]

local settings_table = {
	{
		offsetX		= 0,		-- X axis offset to start drawing background (if "nil" then "0" is assumed)
		offsetY		= 0,		-- Y axis offset to start drawing background (if "nil" then "0" is assumed
		width		= 0,		-- Width of drawed background (if "0" or "nil" then Conky window width is assumed)
		height		= 0,		-- Height of drawed background (if "0" or "nil" then Conky window height is assumed)
		radius		= 7.5,		-- Radius for rounding corners in Percent of shortest side (if "nil" then "7.5%" is assumed)
		color		= 0xe0f000,	-- Color of background (if "0" or "nil" then "0x000000" - black; is assumed)
		alpha		= 0.8,		-- Transparency of background (if "nil" then "0.5" is assumed)
	},
	{
		offsetX		= 150,
		offsetY		= 230,
		width		= 1000,
		height		= 50,
		radius		= 50,
		color		= 0x00ff00,
		alpha		= 0.5,
	},
	{
		offsetX		= 50,
		offsetY		= 430,
		width		= 1200,
		height		= 50,
		radius		= 50,
		color		= 0x00ff00,
		alpha		= 0.5,
	},
}
		
--[[
###############################################################################
###                           END OF SETTINGS                               ###
###############################################################################
--]]



function M.background(t)
	if t.radius==nil then t.radiusr=7.5 end
	if t.offsetX==nil then t.offsetX=0 end
	if t.offsetY==nil then t.offsetY=0 end
	if t.width==nil or t.width==0 or (t.width+t.offsetX)>tonumber(conky_window.width) then t.width=tonumber(conky_window.width)-t.offsetX end
	if t.height==nil or t.height==0 or (t.height+t.offsetY)>tonumber(conky_window.height) then t.height=tonumber(conky_window.height)-t.offsetY end
	if t.color==nil or t.color==0 then color=0x000000 end
	if t.alpha==nil then t.alpha=0.5 end
	one4all_cairo.draw_box(cr, t.offsetX, t.offsetY, t.width, t.height, t.radius, t.color, t.alpha)
end



--[[
###############################################################################
###                            MODULE MAIN LOOP                             ###
###############################################################################
--]]
function M.main()
        for i in pairs(settings_table) do
            M.background(settings_table[i])
        end
end
Personal tools
Namespaces
Variants
Actions
Navigation
English
Français
Toolbox