Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Created September 6, 2013 02:19
Show Gist options
  • Select an option

  • Save NuckChorris/6458766 to your computer and use it in GitHub Desktop.

Select an option

Save NuckChorris/6458766 to your computer and use it in GitHub Desktop.
local assault = wibox.widget.base.make_widget()
function assault.fit (assault, width, height)
local width = math.min(width, assault.size.width)
local height = math.min(height, assault.size.height)
return width, height
end
local battery_bolt_generate = function (width, height)
local surface = cairo.ImageSurface.create('A8', width, height)
local cr = cairo.Context.create(surface)
cr:new_path()
cr:move_to(width * ( 0.0/19), height * ( 3.0/11))
cr:line_to(width * (11.0/19), height * (11.0/11))
cr:line_to(width * (11.0/19), height * ( 5.5/11))
cr:line_to(width * (19.0/19), height * ( 8.0/11))
cr:line_to(width * ( 8.0/19), height * ( 0.0/11))
cr:line_to(width * ( 8.0/19), height * ( 5.5/11))
cr:close_path()
return cr:copy_path()
end
function assault.draw (assault, wibox, cr, width, height)
battery_bolt_generate(width, height)
cr:fill()
end
-- Build properties function
for _, prop in ipairs(properties) do
if not progressbar["set_" .. prop] then
progressbar["set_" .. prop] = function(pbar, value)
data[pbar][prop] = value
pbar:emit_signal("widget::updated")
return pbar
end
end
end
--- Create an assault widget
function assault.new (args)
local args = args or {}
local width = args.width or 36
local height = args.height or 15
args.type = "imagebox"
local widget = base.make_widget()
data[widget] = {
width = width,
height = height
}
-- Set methods
for _, prop in ipairs(properties) do
widget["set_" .. prop] = assault["set_" .. prop]
end
pbar.draw = assault.draw
pbar.fit = progressbar.fit
return pbar
end
function progressbar.mt:__call(...)
return progressbar.new(...)
end
return setmetatable(assault, assault.mt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment