Rename the first argument to :draw to "context"
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
31b69dbe1a
commit
88b98789a0
|
@ -69,7 +69,7 @@ local properties = { "width", "height", "border_color", "stack",
|
|||
"stack_colors", "color", "background_color",
|
||||
"max_value", "scale" }
|
||||
|
||||
function graph.draw(_graph, wibox, cr, width, height)
|
||||
function graph.draw(_graph, context, cr, width, height)
|
||||
local max_value = data[_graph].max_value
|
||||
local values = data[_graph].values
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ local properties = { "width", "height", "border_color",
|
|||
"vertical", "value", "max_value",
|
||||
"ticks", "ticks_gap", "ticks_size" }
|
||||
|
||||
function progressbar.draw(pbar, wibox, cr, width, height)
|
||||
function progressbar.draw(pbar, context, cr, width, height)
|
||||
local ticks_gap = data[pbar].ticks_gap or 1
|
||||
local ticks_size = data[pbar].ticks_size or 4
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ local widget_base = require("wibox.widget.base")
|
|||
local align = {}
|
||||
|
||||
--- Draw an align layout.
|
||||
-- @param wibox The wibox that this widget is drawn to.
|
||||
-- @param context The context in which we are drawn.
|
||||
-- @param cr The cairo context to use.
|
||||
-- @param width The available width.
|
||||
-- @param height The available height.
|
||||
function align:draw(wibox, cr, width, height)
|
||||
function align:draw(context, cr, width, height)
|
||||
-- Draw will have to deal with all three align modes and should work in a
|
||||
-- way that makes sense if one or two of the widgets are missing (if they
|
||||
-- are all missing, it won't draw anything.) It should also handle the case
|
||||
|
@ -42,7 +42,7 @@ function align:draw(wibox, cr, width, height)
|
|||
-- if all the space is taken, skip the rest, and draw just the middle
|
||||
-- widget
|
||||
if size_second >= size_remains then
|
||||
base.draw_widget(wibox, cr, self.second, 0, 0, width, height)
|
||||
base.draw_widget(context, cr, self.second, 0, 0, width, height)
|
||||
return
|
||||
else
|
||||
-- the middle widget is sized first, the outside widgets are given
|
||||
|
@ -81,7 +81,7 @@ function align:draw(wibox, cr, width, height)
|
|||
w = size_remains
|
||||
end
|
||||
end
|
||||
base.draw_widget(wibox, cr, self.first, 0, 0, w, h)
|
||||
base.draw_widget(context, cr, self.first, 0, 0, w, h)
|
||||
end
|
||||
-- size_remains will be <= 0 if first used all the space
|
||||
if self.third and size_remains > 0 then
|
||||
|
@ -107,7 +107,7 @@ function align:draw(wibox, cr, width, height)
|
|||
end
|
||||
end
|
||||
local x, y = width - w, height - h
|
||||
base.draw_widget(wibox, cr, self.third, x, y, w, h)
|
||||
base.draw_widget(context, cr, self.third, x, y, w, h)
|
||||
end
|
||||
-- here we either draw the second widget in the space set aside for it
|
||||
-- in the beginning, or in the remaining space, if it is "inside"
|
||||
|
@ -130,7 +130,7 @@ function align:draw(wibox, cr, width, height)
|
|||
x = floor( (width -w)/2 )
|
||||
end
|
||||
end
|
||||
base.draw_widget(wibox, cr, self.second, x, y, w, h)
|
||||
base.draw_widget(context, cr, self.second, x, y, w, h)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,17 +45,18 @@ function base.fit_widget(widget, width, height)
|
|||
end
|
||||
|
||||
--- Draw a widget via a cairo context
|
||||
-- @param wibox The wibox on which we are drawing
|
||||
-- @param context The context in which we are drawn.
|
||||
-- @param cr The cairo context used
|
||||
-- @param widget The widget to draw (this uses widget:draw(cr, width, height)).
|
||||
-- @param x The position that the widget should get
|
||||
-- @param y The position that the widget should get
|
||||
-- @param width The widget's width
|
||||
-- @param height The widget's height
|
||||
function base.draw_widget(wibox, cr, widget, x, y, width, height)
|
||||
function base.draw_widget(context, cr, widget, x, y, width, height)
|
||||
if not widget.visible then
|
||||
return
|
||||
end
|
||||
|
||||
-- Use save() / restore() so that our modifications aren't permanent
|
||||
cr:save()
|
||||
|
||||
|
@ -68,13 +69,13 @@ function base.draw_widget(wibox, cr, widget, x, y, width, height)
|
|||
|
||||
-- Let the widget draw itself
|
||||
xpcall(function()
|
||||
widget:draw(wibox, cr, width, height)
|
||||
widget:draw(context, cr, width, height)
|
||||
end, function(err)
|
||||
print(debug.traceback("Error while drawing widget: "..tostring(err), 2))
|
||||
end)
|
||||
|
||||
-- Register the widget for input handling
|
||||
wibox:widget_at(widget, base.rect_to_device_geometry(cr, 0, 0, width, height))
|
||||
context:widget_at(widget, base.rect_to_device_geometry(cr, 0, 0, width, height))
|
||||
|
||||
cr:restore()
|
||||
end
|
||||
|
|
|
@ -15,12 +15,12 @@ local math = math
|
|||
local constraint = { mt = {} }
|
||||
|
||||
--- Draw a constraint layout
|
||||
function constraint:draw(wibox, cr, width, height)
|
||||
function constraint:draw(context, cr, width, height)
|
||||
if not self.widget then
|
||||
return
|
||||
end
|
||||
|
||||
base.draw_widget(wibox, cr, self.widget, 0, 0, width, height)
|
||||
base.draw_widget(context, cr, self.widget, 0, 0, width, height)
|
||||
end
|
||||
|
||||
--- Fit a constraint layout into the given space
|
||||
|
|
|
@ -13,12 +13,12 @@ local pairs = pairs
|
|||
local fixed = {}
|
||||
|
||||
--- Draw a fixed layout. Each widget gets just the space it asks for.
|
||||
-- @param wibox The wibox that this widget is drawn to.
|
||||
-- @param context The context in which we are drawn.
|
||||
-- @param cr The cairo context to use.
|
||||
-- @param width The available width.
|
||||
-- @param height The available height.
|
||||
-- @return The total space needed by the layout.
|
||||
function fixed:draw(wibox, cr, width, height)
|
||||
function fixed:draw(context, cr, width, height)
|
||||
local pos,spacing = 0,self._spacing or 0
|
||||
|
||||
for k, v in pairs(self.widgets) do
|
||||
|
@ -46,7 +46,7 @@ function fixed:draw(wibox, cr, width, height)
|
|||
(self.dir ~= "y" and pos-spacing > width) then
|
||||
break
|
||||
end
|
||||
base.draw_widget(wibox, cr, v, x, y, w, h)
|
||||
base.draw_widget(context, cr, v, x, y, w, h)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ local function round(x)
|
|||
end
|
||||
|
||||
--- Draw a flex layout. Each widget gets an equal share of the available space.
|
||||
-- @param wibox The wibox that this widget is drawn to.
|
||||
-- @param context The context in which we are drawn.
|
||||
-- @param cr The cairo context to use.
|
||||
-- @param width The available width.
|
||||
-- @param height The available height.
|
||||
-- @return The total space needed by the layout.
|
||||
function flex:draw(wibox, cr, width, height)
|
||||
function flex:draw(context, cr, width, height)
|
||||
local pos,spacing = 0,self._spacing or 0
|
||||
local num = #self.widgets
|
||||
local total_spacing = (spacing*(num-1))
|
||||
|
@ -48,7 +48,7 @@ function flex:draw(wibox, cr, width, height)
|
|||
x, y = round(pos), 0
|
||||
w, h = floor(space_per_item), height
|
||||
end
|
||||
base.draw_widget(wibox, cr, v, x, y, w, h)
|
||||
base.draw_widget(context, cr, v, x, y, w, h)
|
||||
|
||||
pos = pos + space_per_item + spacing
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ local cairo = require("lgi").cairo
|
|||
local margin = { mt = {} }
|
||||
|
||||
--- Draw a margin layout
|
||||
function margin:draw(wibox, cr, width, height)
|
||||
function margin:draw(context, cr, width, height)
|
||||
local x = self.left
|
||||
local y = self.top
|
||||
local w = self.right
|
||||
|
@ -37,7 +37,7 @@ function margin:draw(wibox, cr, width, height)
|
|||
cr:restore()
|
||||
end
|
||||
|
||||
base.draw_widget(wibox, cr, self.widget, x, y, width - x - w, height - y - h)
|
||||
base.draw_widget(context, cr, self.widget, x, y, width - x - w, height - y - h)
|
||||
end
|
||||
|
||||
--- Fit a margin layout into the given space
|
||||
|
|
|
@ -16,10 +16,8 @@ local widget_base = require("wibox.widget.base")
|
|||
local mirror = { mt = {} }
|
||||
|
||||
--- Draw this layout
|
||||
function mirror:draw(wibox, cr, width, height)
|
||||
if not self.widget then
|
||||
return { width = 0, height = 0 }
|
||||
end
|
||||
function mirror:draw(context, cr, width, height)
|
||||
if not self.widget then return end
|
||||
if not self.horizontal and not self.vertical then
|
||||
base.draw_widget(wibox, cr, self.widget, 0, 0, width, height)
|
||||
return -- nothing changed
|
||||
|
@ -40,7 +38,7 @@ function mirror:draw(wibox, cr, width, height)
|
|||
cr:translate(t.x, t.y)
|
||||
cr:scale(s.x, s.y)
|
||||
|
||||
self.widget:draw(wibox, cr, width, height)
|
||||
self.widget:draw(context, cr, width, height)
|
||||
|
||||
-- Undo the scale and translation from above.
|
||||
cr:restore()
|
||||
|
|
|
@ -25,9 +25,9 @@ local function transform(layout, width, height)
|
|||
end
|
||||
|
||||
--- Draw this layout
|
||||
function rotate:draw(wibox, cr, width, height)
|
||||
function rotate:draw(context, cr, width, height)
|
||||
if not self.widget or not self.widget.visible then
|
||||
return { width = 0, height = 0 }
|
||||
return
|
||||
end
|
||||
|
||||
local dir = self:get_direction()
|
||||
|
@ -45,7 +45,7 @@ function rotate:draw(wibox, cr, width, height)
|
|||
|
||||
-- Since we rotated, we might have to swap width and height.
|
||||
-- transform() does that for us.
|
||||
base.draw_widget(wibox, cr, self.widget, 0, 0, transform(self, width, height))
|
||||
base.draw_widget(context, cr, self.widget, 0, 0, transform(self, width, height))
|
||||
end
|
||||
|
||||
--- Fit this layout into the given area
|
||||
|
|
|
@ -17,7 +17,7 @@ local type = type
|
|||
local background = { mt = {} }
|
||||
|
||||
--- Draw this widget
|
||||
function background:draw(wibox, cr, width, height)
|
||||
function background:draw(context, cr, width, height)
|
||||
if not self.widget or not self.widget.visible then
|
||||
return
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ function background:draw(wibox, cr, width, height)
|
|||
cr:save()
|
||||
cr:set_source(self.foreground)
|
||||
end
|
||||
layout_base.draw_widget(wibox, cr, self.widget, 0, 0, width, height)
|
||||
layout_base.draw_widget(context, cr, self.widget, 0, 0, width, height)
|
||||
if self.foreground then
|
||||
cr:restore()
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ local print = print
|
|||
local imagebox = { mt = {} }
|
||||
|
||||
--- Draw an imagebox with the given cairo context in the given geometry.
|
||||
function imagebox:draw(wibox, cr, width, height)
|
||||
function imagebox:draw(context, cr, width, height)
|
||||
if not self._image then return end
|
||||
if width == 0 or height == 0 then return end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ local horizontal = true
|
|||
local base_size = nil
|
||||
local reverse = false
|
||||
|
||||
function systray:draw(wibox, cr, width, height)
|
||||
function systray:draw(context, cr, width, height)
|
||||
local x, y, _, _ = lbase.rect_to_device_geometry(cr, 0, 0, width, height)
|
||||
local num_entries = capi.awesome.systray()
|
||||
local bg = beautiful.bg_systray or beautiful.bg_normal or "#000000"
|
||||
|
@ -41,7 +41,7 @@ function systray:draw(wibox, cr, width, height)
|
|||
else
|
||||
base = in_dir / num_entries
|
||||
end
|
||||
capi.awesome.systray(wibox.wibox.drawin, math.ceil(x), math.ceil(y),
|
||||
capi.awesome.systray(context.wibox.drawin, math.ceil(x), math.ceil(y),
|
||||
base, is_rotated, bg, reverse, spacing)
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ local function setup_layout(box, width, height)
|
|||
end
|
||||
|
||||
--- Draw the given textbox on the given cairo context in the given geometry
|
||||
function textbox:draw(wibox, cr, width, height)
|
||||
function textbox:draw(context, cr, width, height)
|
||||
cr:update_layout(self._layout)
|
||||
setup_layout(self, width, height)
|
||||
local ink, logical = self._layout:get_pixel_extents()
|
||||
|
|
Loading…
Reference in New Issue