Port to the new Awesome widget system
This commit fix most issues introduced by the new widget system. It is not production ready and will require multiple commits to fix individual issues. The new widget system is better suited for modules like Radical than the previous one. Over time, this breakage will probably end up being a good thing. However, for now, expect multiple errors. The changes: * The draw "wibox" argument is now a "context". "context.wibox" is the equivalent. This will allow passing the Radical structure to the draw method without storing it in the widgets. * "fit" now have a new required "context" argument for the DPI, this will allow removing the "default_height" variable Radical is using to scale the UI on HIDPI systems. This will allow size policies to be passed to the fit method * "draw" has been splitted into "draw", "draw_before_children", "draw_after_children" and "layout". This simplify the overlay system and will allow cleaner code * Drawing outside of the widget clip is no longer supported, this break multiple Radical item.style. This will allow better performance and less redraw once the new system issues have been fixed
This commit is contained in:
parent
dba05f5774
commit
cf9bb87b36
8
bar.lua
8
bar.lua
|
@ -25,13 +25,12 @@ local function set_position(self)
|
|||
end
|
||||
|
||||
-- Draw the menu background
|
||||
local function bg_draw(self, w, cr, width, height)
|
||||
local function bg_draw(self, context, cr, width, height)--w, cr, width, height)
|
||||
cr:save()
|
||||
cr:set_source(color(self._data.bg))
|
||||
cr:rectangle(0,0,width,height)
|
||||
cr:fill()
|
||||
cr:restore()
|
||||
self._draw(self, w, cr, width, height)
|
||||
end
|
||||
|
||||
local function proxy_draw(_,...)
|
||||
|
@ -49,8 +48,9 @@ local function setup_drawable(data)
|
|||
local private_data = internal.private_data
|
||||
|
||||
internal.layout = internal.layout_func or wibox.layout.fixed.horizontal()
|
||||
internal.layout._draw = internal.layout.draw
|
||||
internal.layout.draw = bg_draw
|
||||
|
||||
--internal.layout.draw = bg_draw --TODO Dead code?
|
||||
|
||||
internal.layout._data = data
|
||||
|
||||
if internal.layout.set_spacing and data.spacing then
|
||||
|
|
13
base.lua
13
base.lua
|
@ -213,8 +213,8 @@ local function add_widget(data,widget,args)
|
|||
args = args or {}
|
||||
data._internal.has_widget = true
|
||||
widget._fit = widget.fit
|
||||
widget.fit = function(self,width,height)
|
||||
local w,h = widget._fit(self,width or 1, height or 1)
|
||||
widget.fit = function(self,context,width,height)
|
||||
local w,h = widget._fit(self, context, width or 1, height or 1)
|
||||
return args.width or w,args.height or h
|
||||
end
|
||||
|
||||
|
@ -239,7 +239,7 @@ local function add_widget(data,widget,args)
|
|||
data._internal.items[#data._internal.items+1] = item
|
||||
data:emit_signal("widget::added",item,widget)
|
||||
if data.visible then
|
||||
local fit_w,fit_h = data._internal.layout:fit(9999,9999)
|
||||
local fit_w,fit_h = data._internal.layout:fit({dpi=96}, 9999,9999)
|
||||
data.width = data._internal.width or fit_w
|
||||
data.height = fit_h
|
||||
end
|
||||
|
@ -262,18 +262,21 @@ end
|
|||
-- Sum all widgets height and width
|
||||
local function get_widget_fit_sum(data)
|
||||
local h,w = 0,0
|
||||
-- TODO query this from the layout itself
|
||||
for k,v in ipairs(data._internal.widgets) do
|
||||
local fw,fh = v.widget:fit(9999,9999)
|
||||
local fw,fh = v.widget:fit({dpi=96},9999,9999)
|
||||
w,h = w + fw,h + fh
|
||||
end
|
||||
return w,h
|
||||
end
|
||||
|
||||
local function get_widget_fit_width_sum(data)
|
||||
-- TODO query this from the layout itself
|
||||
return get_widget_fit_sum(data)
|
||||
end
|
||||
|
||||
local function get_widget_fit_height_sum(data)
|
||||
-- TODO query this from the layout itself
|
||||
local w,h = get_widget_fit_sum(data)
|
||||
return h
|
||||
end
|
||||
|
@ -406,7 +409,7 @@ print(beautiful.menu_border_color)
|
|||
data.set_visible = function(_,value)
|
||||
private_data.visible = value
|
||||
if value then
|
||||
local fit_w,fit_h = data._internal.layout:fit(9999,9999)
|
||||
local fit_w,fit_h = data._internal.layout:fit({dpi=96}, 9999,9999)
|
||||
data.width = internal.width or fit_w
|
||||
data.height = fit_h
|
||||
elseif data._tmp_menu and data._current_item then
|
||||
|
|
4
box.lua
4
box.lua
|
@ -7,8 +7,8 @@ local function set_position(data)
|
|||
local s = data.screen or capi.mouse.screen
|
||||
s = s > capi.screen.count() and 1 or s
|
||||
local geom = capi.screen[s].geometry
|
||||
data.wibox.x = geom.x + (geom.width/2) - data.width/2
|
||||
data.wibox.y = geom.y + (geom.height/2) - data.height/2
|
||||
data.wibox.x = math.ceil(geom.x + (geom.width/2) - data.width/2)
|
||||
data.wibox.y = math.ceil(geom.y + (geom.height/2) - data.height/2)
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
|
|
|
@ -43,7 +43,7 @@ local function set_geometry_real(data)
|
|||
local geo = data._internal._next_geometry
|
||||
if geo then
|
||||
for k,v in pairs(geo) do
|
||||
data.wibox[k] = v
|
||||
data.wibox[k] = math.ceil(v)
|
||||
end
|
||||
end
|
||||
data._internal._next_geometry = nil
|
||||
|
|
26
dock.lua
26
dock.lua
|
@ -78,7 +78,9 @@ local function mask(rotate,width,height,radius,offset,anti,bg,fg)
|
|||
end
|
||||
|
||||
-- Do not draw over the boder, ever
|
||||
local function dock_draw(self, w, cr, width, height)
|
||||
local function dock_draw(self, context, cr, width, height)
|
||||
|
||||
local w = context.wibox
|
||||
|
||||
-- Generate the border surface
|
||||
if not self.mask or self.mask_hash ~= width*1000+height then
|
||||
|
@ -89,7 +91,7 @@ local function dock_draw(self, w, cr, width, height)
|
|||
cr:save()
|
||||
|
||||
--Draw the border
|
||||
self.__draw(self, w, cr, width, height)
|
||||
--self.__draw(self, context, cr, width, height)
|
||||
cr:set_source_surface(self.mask)
|
||||
cr:paint()
|
||||
cr:restore()
|
||||
|
@ -103,15 +105,15 @@ local function align_wibox(w,direction,screen)
|
|||
local src_geom = capi.screen[screen].geometry
|
||||
local scr_size = src_geom[offset] + (src_geom[axis] - w[axis]) /2
|
||||
|
||||
w[offset] = scr_size
|
||||
w[offset] = math.ceil(scr_size)
|
||||
if direction == "left" then
|
||||
w.x = src_geom.x
|
||||
w.x = math.ceil(src_geom.x)
|
||||
elseif direction == "right" then
|
||||
w.x = src_geom.x + src_geom.width - w.width
|
||||
w.x = math.ceil(src_geom.x + src_geom.width - w.width)
|
||||
elseif direction == "bottom" then
|
||||
w.y = src_geom.y+src_geom.height-w.height
|
||||
w.y = math.ceil(src_geom.y+src_geom.height-w.height)
|
||||
else
|
||||
w.y = src_geom.y
|
||||
w.y = math.ceil(src_geom.y)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -163,7 +165,7 @@ local function adapt_size(data,w,h,screen)
|
|||
local max = get_max_size(data,screen)
|
||||
|
||||
-- Get the current size, then compare and ajust
|
||||
local fit_w,fit_h = data._internal.layout:fit(20,9999,true)
|
||||
local fit_w,fit_h = data._internal.layout:fit({dpi=96},20,9999,true)
|
||||
|
||||
-- Get the number of items minus the number of widgets
|
||||
-- This can be used to approximate the number of pixel to remove
|
||||
|
@ -323,13 +325,13 @@ local function setup_drawable(data)
|
|||
data.get_x = function() return 0 end
|
||||
data.get_y = function() return 0 end
|
||||
data.get_width = function()
|
||||
return internal.w and internal.w.width or data._internal.layout:fit(9999,9999,true)
|
||||
return internal.w and internal.w.width or data._internal.layout:fit({dpi=96},9999,9999,true)
|
||||
end
|
||||
data.get_height = function()
|
||||
if internal.orientation == "horizontal" then
|
||||
return beautiful.default_height
|
||||
else
|
||||
local w,h = internal.layout.fit(internal.layout,9999,9999)
|
||||
local w,h = internal.layout.fit(internal.layout,{dpi=96},9999,9999)
|
||||
return h
|
||||
end
|
||||
end
|
||||
|
@ -355,7 +357,7 @@ end
|
|||
|
||||
local function setup_item(data,item,args)
|
||||
-- Add widgets
|
||||
local f = (data._internal.layout.setup_item) or (layout.vertical.setup_item)
|
||||
local f = (data._internal.layout.setup_item) or (vertical.setup_item)
|
||||
f(data._internal.layout,data,item,args)
|
||||
|
||||
-- Buttons
|
||||
|
@ -397,7 +399,7 @@ local function new(args)
|
|||
args.internal.layout_func = orientation == "vertical" and vertical or horizontal
|
||||
args.layout = args.layout or args.internal.layout_func
|
||||
args.item_style = args.item_style or item.style
|
||||
args.item_layout = args.item_layout or item_layout
|
||||
-- args.item_layout = args.item_layout or item_layout
|
||||
args[length_inv] = args[length_inv] or 40
|
||||
|
||||
-- Create the dock
|
||||
|
|
|
@ -126,8 +126,8 @@ local function new(args)
|
|||
if not auto_release then
|
||||
local pref_bg = wibox.widget.background()
|
||||
local pref_l = wibox.layout.align.horizontal()
|
||||
pref_bg.fit = function(s,w,h)
|
||||
local w2,h2 = wibox.widget.background.fit(s,w,h)
|
||||
pref_bg.fit = function(s,c,w,h)
|
||||
local w2,h2 = wibox.widget.background.fit(s,c,w,h)
|
||||
return w2,currentMenu.item_height
|
||||
end
|
||||
pref_bg:set_bg(currentMenu.bg_alternate)
|
||||
|
@ -136,13 +136,13 @@ local function new(args)
|
|||
pref_l:set_first(tb2)
|
||||
pref_bg:set_widget(pref_l)
|
||||
local pref_menu,pref_menu_l = radical.bar{item_style=radical.item.style.basic}
|
||||
pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
-- pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
pref_menu:add_item{text="Exclusive"}
|
||||
pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
-- pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
pref_menu:add_item{text="12 clients"}
|
||||
pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
-- pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
pref_menu:add_item{text="All Screens"}
|
||||
pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
-- pref_menu:add_widget(radical.widgets.separator(pref_menu,radical.widgets.separator.VERTICAL))
|
||||
pref_l:set_third(pref_menu_l)
|
||||
|
||||
currentMenu:add_prefix_widget(pref_bg)
|
||||
|
@ -186,7 +186,7 @@ local function new(args)
|
|||
l:add( button_group({client = v, field = "sticky" , focus = false, checked = function() return v.sticky end, onclick = function() v.sticky = not v.sticky end }))
|
||||
l:add( button_group({client = v, field = "ontop" , focus = false, checked = function() return v.ontop end, onclick = function() v.ontop = not v.ontop end }))
|
||||
l:add( button_group({client = v, field = "close" , focus = false, checked = function() return false end, onclick = function() v:kill() end }))
|
||||
l.fit = function (s,w,h) return 5*h,h end
|
||||
l.fit = function (s,c,w,h) return 5*h,h end
|
||||
end
|
||||
|
||||
local underlays = reload_underlay(v)
|
||||
|
|
|
@ -50,11 +50,13 @@ module.buttons = { [1] = awful.tag.viewonly,
|
|||
|
||||
|
||||
|
||||
local function index_draw(self,w, cr, width, height)
|
||||
local function index_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
cr:set_source(color(self._color or beautiful.taglist_fg_prefix or beautiful.fg_normal))
|
||||
local d = wibox.widget.textbox._draw or wibox.widget.textbox.draw
|
||||
d(self,wibox, cr, width, height)
|
||||
if d then
|
||||
d(self,context, cr, width, height)
|
||||
end
|
||||
cr:restore()
|
||||
end
|
||||
|
||||
|
|
4
init.lua
4
init.lua
|
@ -35,13 +35,13 @@ local function set_menu(self,menu,button)
|
|||
return bt
|
||||
end
|
||||
|
||||
local function _underlay_draw(self,w, cr, width, height)
|
||||
local function _underlay_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
local udl = underlay.draw(self._underlay,{height=height,style = self._underlay_style,bg=self._underlay_color})
|
||||
cr:set_source_surface(udl,width-udl:get_width()-3)
|
||||
cr:paint_with_alpha(self._underlay_alpha or beautiful.underlay_alpha or 0.7)
|
||||
cr:restore()
|
||||
self._draw_underlay(self,w, cr, width, height)
|
||||
self._draw_underlay(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local function set_underlay(self,udl,args)
|
||||
|
|
|
@ -100,7 +100,7 @@ function module:setup_sub_menu_arrow(item,data)
|
|||
if (item._private_data.sub_menu_f or item._private_data.sub_menu_m) and not data.disable_submenu_icon then
|
||||
if not sub_arrow then
|
||||
sub_arrow = wibox.widget.imagebox() --TODO, make global
|
||||
sub_arrow.fit = function(box, w, h) return (sub_arrow._image and sub_arrow._image:get_width() or 0),item.height end
|
||||
sub_arrow.fit = function(box, context,w, h) return (sub_arrow._image and sub_arrow._image:get_width() or 0),item.height end
|
||||
sub_arrow:set_image( beautiful.menu_submenu_icon )
|
||||
end
|
||||
return sub_arrow
|
||||
|
@ -157,15 +157,15 @@ function module.setup_event(data,item,widget)
|
|||
end
|
||||
|
||||
-- Use all the space, let "align_fit" compute the right size
|
||||
local function textbox_fit(box,w,h)
|
||||
local function textbox_fit(box,context,w,h)
|
||||
return w,h
|
||||
end
|
||||
|
||||
-- Force the width or compute the minimum space
|
||||
local function align_fit(box,w,h)
|
||||
local function align_fit(box,context,w,h)
|
||||
local mar = util.table.join(box._data.item_style.margins,box._data.default_item_margins)
|
||||
if box._item.width then return box._item.width - box._data.item_style.margins.LEFT - box._data.item_style.margins.RIGHT,h end
|
||||
return box.first:fit(w,h)+wibox.widget.textbox.fit(box.second,w,h)+box.third:fit(w,h),h
|
||||
return box.first:fit(context,w,h)+wibox.widget.textbox.fit(box.second,context,w,h)+box.third:fit(context,w,h),h
|
||||
end
|
||||
|
||||
-- Create the actual widget
|
||||
|
@ -217,11 +217,11 @@ local function create_item(item,data,args)
|
|||
-- Text
|
||||
local tb = wibox.widget.textbox()
|
||||
tb.fit = data._internal.text_fit or textbox_fit
|
||||
tb.draw = function(self,w, cr, width, height)
|
||||
tb.draw = function(self, context, cr, width, height)
|
||||
if item.underlay then
|
||||
module.paint_underlay(data,item,cr,width,height)
|
||||
end
|
||||
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||
wibox.widget.textbox.draw(self, context, cr, width, height)
|
||||
end
|
||||
tb:set_text(item.text)
|
||||
item.set_text = function (_,value)
|
||||
|
|
|
@ -22,11 +22,11 @@ local function icon_fit(data,...)
|
|||
|
||||
end
|
||||
|
||||
local function icon_draw(self,w, cr, width, height)
|
||||
local w,h = wibox.widget.imagebox.fit(self,width,height)
|
||||
local function icon_draw(self, context, cr, width, height)
|
||||
local w,h = wibox.widget.imagebox.fit(self,context,width,height)
|
||||
cr:save()
|
||||
cr:translate((width-w)/2,0)
|
||||
wibox.widget.imagebox.draw(self,w, cr, width, height)
|
||||
wibox.widget.imagebox.draw(self, context, cr, width, height)
|
||||
cr:restore()
|
||||
end
|
||||
|
||||
|
@ -57,10 +57,10 @@ local function create_item(item,data,args)
|
|||
|
||||
if data.fkeys_prefix == true then
|
||||
local pref = wibox.widget.textbox()
|
||||
pref.draw = function(self,w, cr, width, height)
|
||||
pref.draw = function(self, context, cr, width, height)
|
||||
cr:set_source(color(beautiful.fg_normal))
|
||||
cr:paint()
|
||||
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||
wibox.widget.textbox.draw(self, context, cr, width, height)
|
||||
end
|
||||
l:add(pref)
|
||||
m:set_left ( 0 )
|
||||
|
@ -78,16 +78,16 @@ local function create_item(item,data,args)
|
|||
l:add(text_w)
|
||||
if item._private_data.sub_menu_f or item._private_data.sub_menu_m then
|
||||
local subArrow = wibox.widget.imagebox() --TODO, make global
|
||||
subArrow.fit = function(box, w, h) return subArrow._image:get_width(),item.height end
|
||||
subArrow.fit = function(box, context, w, h) return subArrow._image:get_width(),item.height end
|
||||
subArrow:set_image( beautiful.menu_submenu_icon )
|
||||
lr:add(subArrow)
|
||||
end
|
||||
bg.fit = function(box,w,h)
|
||||
bg.fit = function(box, context, w,h)
|
||||
-- args.y = data.height-h-data.margins.top --TODO dead code?
|
||||
if data._internal.layout.item_fit then
|
||||
return data._internal.layout.item_fit(data,item,box,w,h)
|
||||
return data._internal.layout.item_fit(data,item,box,contextw,h)
|
||||
else
|
||||
return wibox.widget.background.fit(box,w,h)
|
||||
return wibox.widget.background.fit(box,context, w,h)
|
||||
end
|
||||
return 0,0
|
||||
end
|
||||
|
|
|
@ -75,7 +75,7 @@ function module:setup_sub_menu_arrow(item,data)
|
|||
if item._private_data.sub_menu_f or item._private_data.sub_menu_m then
|
||||
if not sub_arrow then
|
||||
sub_arrow = wibox.widget.imagebox() --TODO, make global
|
||||
sub_arrow.fit = function(box, w, h) return sub_arrow._image:get_width(),item.height end
|
||||
sub_arrow.fit = function(box, context, w, h) return sub_arrow._image:get_width(),item.height end
|
||||
sub_arrow:set_image( beautiful.menu_submenu_icon )
|
||||
end
|
||||
return sub_arrow
|
||||
|
@ -132,15 +132,15 @@ function module.setup_event(data,item,widget)
|
|||
end
|
||||
|
||||
-- Use all the space, let "align_fit" compute the right size
|
||||
local function textbox_fit(box,w,h)
|
||||
local w2,h2 = wibox.widget.textbox.fit(box,w,h)
|
||||
local function textbox_fit(box,context,w,h)
|
||||
local w2,h2 = wibox.widget.textbox.fit(box,context,w,h)
|
||||
return w,h2
|
||||
end
|
||||
|
||||
-- Force the width or compute the minimum space
|
||||
local function align_fit(box,w,h)
|
||||
local function align_fit(box,context,w,h)
|
||||
if box._item.width then return box._item.width - box._data.item_style.margins.LEFT - box._data.item_style.margins.RIGHT,h end
|
||||
return box.first:fit(w,h)+wibox.widget.textbox.fit(box.second,w,h)+box.third:fit(w,h),h
|
||||
return box.first:fit(context,w,h)+wibox.widget.textbox.fit(box.second,context,w,h)+box.third:fit(context,w,h),h
|
||||
end
|
||||
|
||||
-- Create the actual widget
|
||||
|
@ -207,11 +207,11 @@ local function create_item(item,data,args)
|
|||
|
||||
-- Text
|
||||
local tb4 = wibox.widget.textbox()
|
||||
tb4.draw = function(self,w, cr, width, height)
|
||||
tb4.draw = function(self, context, cr, width, height)
|
||||
if item.underlay then
|
||||
module.paint_underlay(data,item,cr,width,height)
|
||||
end
|
||||
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||
wibox.widget.textbox.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
item.set_text = function (_,value)
|
||||
|
@ -225,7 +225,7 @@ local function create_item(item,data,args)
|
|||
item:set_text(item.text or "")
|
||||
local tb2 = wibox.widget.textbox()
|
||||
tb2:set_text("alternate")
|
||||
tb2.fit = function(s,w,h)
|
||||
tb2.fit = function(s,context,w,h)
|
||||
return w,h
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ local c4 = color("#3b4249dd")
|
|||
local padding = 1
|
||||
local p2 = 2
|
||||
|
||||
local function widget_draw23(self, w, cr, width, height)
|
||||
local function widget_draw23(self, context, cr, width, height)
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
@ -62,7 +62,10 @@ local function widget_draw23(self, w, cr, width, height)
|
|||
create_path(cr,1,height,1)
|
||||
cr:stroke()
|
||||
cr:restore()
|
||||
self.__drawbasic(self,w, cr, width, height)
|
||||
|
||||
if self.__drawbasic then
|
||||
self.__drawbasic(self, context, cr, width, height)
|
||||
end
|
||||
end
|
||||
|
||||
local function new_set_bg(self,bg)
|
||||
|
|
|
@ -76,8 +76,8 @@ module.get_beg_arrow = function(args)
|
|||
return img
|
||||
end
|
||||
|
||||
local function draw_real(self, w, cr, width, height)
|
||||
-- wibox.widget.background.draw(self, w, cr, width, height)
|
||||
local function draw_real(self, context, cr, width, height)
|
||||
-- wibox.widget.background.draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
|
||||
-- This item style require negative padding, this is a little dangerous to
|
||||
|
@ -94,9 +94,15 @@ local function draw_real(self, w, cr, width, height)
|
|||
cr:reset_clip()
|
||||
cr:fill()
|
||||
cr:restore()
|
||||
self._draw(self, w, cr, width, height)
|
||||
|
||||
self.widget:draw(w, cr, width, height)
|
||||
if self._draw then
|
||||
self._draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
if self.widget.draw then
|
||||
self.widget:draw(context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -15,7 +15,7 @@ local module = {
|
|||
}
|
||||
}
|
||||
|
||||
local function prefix_draw(self, w, cr, width, height)
|
||||
local function prefix_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
|
||||
-- This item style require negative padding, this is a little dangerous to
|
||||
|
@ -32,21 +32,23 @@ local function prefix_draw(self, w, cr, width, height)
|
|||
cr:reset_clip()
|
||||
cr:fill()
|
||||
cr:restore()
|
||||
self._draw(self, w, cr, width, height)
|
||||
if self._draw then
|
||||
self._draw(self, context, cr, width, height)
|
||||
end
|
||||
end
|
||||
|
||||
local function prefix_fit(box,w,h)
|
||||
local width,height = box._fit(box,w,h)
|
||||
local function prefix_fit(box,context,w,h)
|
||||
local width,height = box._fit(box,context,w,h)
|
||||
return width + h/2 + h/6,height
|
||||
end
|
||||
|
||||
local function suffix_fit(box,w,h)
|
||||
local width,height = box._fit(box,w,h)
|
||||
local function suffix_fit(box,context,w,h)
|
||||
local width,height = box._fit(box,context,w,h)
|
||||
return width + h/2 + h/6,height
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
self:_drawprefix(w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
self:_drawprefix(context, cr, width, height)
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -16,7 +16,7 @@ local module = {
|
|||
}
|
||||
|
||||
|
||||
local function suffix_draw(self, w, cr, width, height)
|
||||
local function suffix_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
cr:move_to(height/2,0)
|
||||
cr:line_to(width-height/2,0)
|
||||
|
@ -27,7 +27,11 @@ local function suffix_draw(self, w, cr, width, height)
|
|||
cr:line_to(height/2,0)
|
||||
cr:close_path()
|
||||
cr:clip()
|
||||
wibox.widget.background.draw(self, w, cr, width, height)
|
||||
|
||||
if wibox.widget.background.draw then
|
||||
wibox.widget.background.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -2,6 +2,7 @@ local setmetatable = setmetatable
|
|||
local print = print
|
||||
local pairs=pairs
|
||||
local base = require( "radical.base" )
|
||||
local wibox = require("wibox" )
|
||||
|
||||
local module = {
|
||||
margins = {
|
||||
|
@ -12,8 +13,11 @@ local module = {
|
|||
}
|
||||
}
|
||||
|
||||
local function widget_draw23(self, w, cr, width, height)
|
||||
self.__drawbasic(self,w, cr, width, height)
|
||||
local function widget_draw23(self, context, cr, width, height)
|
||||
if wibox.widget.background.draw then
|
||||
wibox.widget.background.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
@ -23,11 +27,7 @@ end
|
|||
local function draw(item,args)
|
||||
local args = args or {}
|
||||
|
||||
if not item.widget._overlay_init and not item.widget._draw then
|
||||
item.widget.__drawbasic = item.widget.draw
|
||||
item.widget.draw = widget_draw23
|
||||
item.widget._overlay_init = true
|
||||
end
|
||||
item.widget.draw = widget_draw23
|
||||
|
||||
local state = item.state or {}
|
||||
local current_state = state._current_key or nil
|
||||
|
|
|
@ -3,6 +3,7 @@ local base = require( "radical.base" )
|
|||
local color = require( "gears.color" )
|
||||
local cairo = require( "lgi" ).cairo
|
||||
local beautiful = require( "beautiful" )
|
||||
local wibox = require("wibox" )
|
||||
local print = print
|
||||
|
||||
local module = {
|
||||
|
@ -27,8 +28,12 @@ local function gen(item_height,bg_color,border_color)
|
|||
return cairo.Pattern.create_for_surface(img)
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
self:_draw2(w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
|
||||
if wibox.widget.background.draw then
|
||||
wibox.widget.background.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
@ -39,11 +44,7 @@ local function draw(item,args)
|
|||
local args = args or {}
|
||||
local col = args.color
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._draw2 = item.widget.draw
|
||||
item.widget.draw = widget_draw
|
||||
item.widget._overlay_init = true
|
||||
end
|
||||
item.widget.draw = widget_draw
|
||||
|
||||
local ih = item.height or 1
|
||||
if not focussed or not focussed[ih] then
|
||||
|
|
|
@ -32,7 +32,7 @@ local function gen(width,height,bg_color,border_color, pos)
|
|||
return cairo.Pattern.create_for_surface(img)
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
|
||||
local state = self._item.state or {}
|
||||
local current_state = state._current_key or ""
|
||||
|
@ -56,7 +56,10 @@ local function widget_draw(self, w, cr, width, height)
|
|||
self._last_state = current_state
|
||||
end
|
||||
|
||||
self:_drawrounded(w, cr, width, height)
|
||||
if self._drawrounded then
|
||||
self:_drawrounded(context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -15,4 +15,4 @@ return {
|
|||
arrow_3d = require("radical.item.style.arrow_3d" ),
|
||||
slice_prefix = require("radical.item.style.slice_prefix" ),
|
||||
line_3d = require("radical.item.style.line_3d" ),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ local module = {
|
|||
}
|
||||
}
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
self.__drawbasic(self,w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
self.__drawbasic(self,context, cr, width, height)
|
||||
cr:set_source(self.col1)
|
||||
cr:rectangle(0,3,1,height-6)
|
||||
cr:fill()
|
||||
|
@ -37,7 +37,7 @@ local function draw(item,args)
|
|||
item.widget.draw = widget_draw
|
||||
item.widget._overlay_init = true
|
||||
item.widget._item = item
|
||||
|
||||
|
||||
-- Build the 2 item border colors, this item_style doesn't support gradient
|
||||
-- or patterns
|
||||
item.widget.col1 = color(item.item_border_color or item.border_color or beautiful.border_color)
|
||||
|
|
|
@ -3,6 +3,7 @@ local math = math
|
|||
local base = require( "radical.base" )
|
||||
local color = require( "gears.color" )
|
||||
local cairo = require( "lgi" ).cairo
|
||||
local wibox = require("wibox" )
|
||||
local print = print
|
||||
|
||||
local module = {
|
||||
|
@ -45,7 +46,7 @@ local function gen(width,height,bg_color,border_color,item,shadow)
|
|||
return cairo.Pattern.create_for_surface(img)
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height,shadow)
|
||||
local function widget_draw(self, context, cr, width, height,shadow)
|
||||
local item = self._item
|
||||
local state = item.state or {}
|
||||
local current_state = state._current_key or ""
|
||||
|
@ -69,14 +70,17 @@ local function widget_draw(self, w, cr, width, height,shadow)
|
|||
self._last_state = current_state
|
||||
end
|
||||
|
||||
self:_drawrounded(w, cr, width, height)
|
||||
if wibox.widget.background.draw then
|
||||
wibox.widget.background.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = item and item.overlay
|
||||
if overlay then
|
||||
overlay(item._menu,item,cr,width,height)
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_width_shadow(self, w, cr, width, height)
|
||||
local function draw_width_shadow(self, context, cr, width, height)
|
||||
|
||||
cr:save()
|
||||
cr:reset_clip()
|
||||
|
@ -90,7 +94,7 @@ local function draw_width_shadow(self, w, cr, width, height)
|
|||
end
|
||||
cr:restore()
|
||||
|
||||
widget_draw(self, w, cr, width, height,true)
|
||||
widget_draw(self, context, cr, width, height,true)
|
||||
end
|
||||
|
||||
local function common(item,args)
|
||||
|
@ -110,9 +114,9 @@ end
|
|||
local function draw(item,args)
|
||||
local args = args or {}
|
||||
|
||||
item.widget.draw = widget_draw
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._drawrounded = item.widget.draw
|
||||
item.widget.draw = widget_draw
|
||||
item.widget._overlay_init = true
|
||||
item.widget._item = item
|
||||
end
|
||||
|
@ -124,9 +128,9 @@ end
|
|||
local function shadow(item,args)
|
||||
local args = args or {}
|
||||
|
||||
item.widget.draw = draw_width_shadow
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._drawrounded = item.widget.draw
|
||||
item.widget.draw = draw_width_shadow
|
||||
item.widget._overlay_init = true
|
||||
item.widget._item = item
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ local module = {
|
|||
}
|
||||
}
|
||||
|
||||
local function prefix_draw(self, w, cr, width, height)
|
||||
local function prefix_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
|
||||
-- This item style require negative padding, this is a little dangerous to
|
||||
|
@ -30,21 +30,27 @@ local function prefix_draw(self, w, cr, width, height)
|
|||
cr:reset_clip()
|
||||
cr:fill()
|
||||
cr:restore()
|
||||
self._draw(self, w, cr, width, height)
|
||||
|
||||
if self._draw then
|
||||
self._draw(self, context, cr, width, height)
|
||||
end
|
||||
end
|
||||
|
||||
local function prefix_fit(box,w,h)
|
||||
local width,height = box._fit(box,w,h)
|
||||
local function prefix_fit(box,context,w,h)
|
||||
local width,height = box._fit(box,context,w,h)
|
||||
return width + h/2,height
|
||||
end
|
||||
|
||||
local function suffix_fit(box,w,h)
|
||||
local width,height = box._fit(box,w,h)
|
||||
local function suffix_fit(box,context,w,h)
|
||||
local width,height = box._fit(box,context,w,h)
|
||||
return width + h/2 + h/6,height
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
self:_drawprefix(w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
if self._drawprefix then
|
||||
self:_drawprefix(context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -39,7 +39,7 @@ local function gen(w,h,bg_color,border_color)
|
|||
return cairo.Pattern.create_for_surface(img)
|
||||
end
|
||||
|
||||
local function widget_draw(self, w, cr, width, height)
|
||||
local function widget_draw(self, context, cr, width, height)
|
||||
|
||||
local state = self._item.state or {}
|
||||
local current_state = state._current_key or ""
|
||||
|
@ -63,7 +63,10 @@ local function widget_draw(self, w, cr, width, height)
|
|||
self._last_state = current_state
|
||||
end
|
||||
|
||||
self:_drawrounded(w, cr, width, height)
|
||||
if self._drawrounded then
|
||||
self:_drawrounded(context, cr, width, height)
|
||||
end
|
||||
|
||||
local overlay = self._item and self._item.overlay
|
||||
if overlay then
|
||||
overlay(self._item._menu,self._item,cr,width,height)
|
||||
|
|
|
@ -109,7 +109,7 @@ function module:setup_item(data,item,args)
|
|||
text_w:set_markup(value)
|
||||
end
|
||||
if data.auto_resize then
|
||||
local fit_w,fit_h = text_w:fit(999,9999)
|
||||
local fit_w,fit_h = text_w:fit({dpi=96},999,9999)
|
||||
local is_largest = item == data._internal.largest_item_h
|
||||
--TODO find new largest is item is smaller
|
||||
if not data._internal.largest_item_h_v or data._internal.largest_item_h_v < fit_h then
|
||||
|
@ -144,8 +144,8 @@ local function new(data)
|
|||
base = require( "radical.base" )
|
||||
end
|
||||
local l = wibox.layout.fixed.horizontal()
|
||||
l.fit = function(a1,a2,a3,force_values)
|
||||
local result,r2 = wibox.layout.fixed.fit(a1,force_values and a2 or 99999,force_values and a3 or 99999)
|
||||
l.fit = function(self,context,w,h,force_values) --TODO use the context instead of extra argument
|
||||
local result,r2 = wibox.layout.fixed.fit(self,context,force_values and w or 99999,force_values and h or 99999)
|
||||
local w,h
|
||||
if data.auto_resize and data._internal.largest_item_h then
|
||||
w,h = data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height
|
||||
|
|
|
@ -55,7 +55,7 @@ end
|
|||
local function item_fit(data,item,self,width,height)
|
||||
local w, h = 0,0--item._internal.cache_w or 1,item._internal.cache_h or 1
|
||||
if data.visible then
|
||||
w, h = item._private_data._fit(self,width,height)
|
||||
w, h = item._private_data._fit({},self,{},width,height)
|
||||
item._internal.pix_cache = {} --Clear the pimap cache
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ end
|
|||
local function cache_pixmap(item)
|
||||
item._internal.pix_cache = {}
|
||||
item.widget._draw = item.widget.draw
|
||||
item.widget.draw = function(self,w, cr, width, height)
|
||||
item.widget.draw = function(self, context, cr, width, height)
|
||||
if not w.visible or item._hidden then return end
|
||||
if item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)] then
|
||||
cr:set_source_surface(item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)])
|
||||
|
@ -75,7 +75,7 @@ local function cache_pixmap(item)
|
|||
else
|
||||
local img5 = cairo.ImageSurface.create(cairo.Format.ARGB32, width, height)
|
||||
local cr5 = cairo.Context(img5)
|
||||
item.widget._draw(self,w, cr5, width, height)
|
||||
item.widget._draw(self, context, cr5, width, height)
|
||||
cr:set_source_surface(img5)
|
||||
cr:paint()
|
||||
item._internal.pix_cache[10*width+7*height+(item.selected and 8888 or 999)] = img5
|
||||
|
@ -87,13 +87,13 @@ end
|
|||
function module:setup_text(item,data,text_w)
|
||||
local text_w = item._internal.text_w
|
||||
|
||||
text_w.draw = function(self,w, cr, width, height)
|
||||
text_w.draw = function(self,context, cr, width, height)
|
||||
if item.underlay then
|
||||
horizontal_item_layout.paint_underlay(data,item,cr,width,height)
|
||||
end
|
||||
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||
wibox.widget.textbox.draw(self, context, cr, width, height)
|
||||
end
|
||||
text_w.fit = function(self,width,height) return width,height end
|
||||
text_w.fit = function(self,context,width,height) return width,height end
|
||||
|
||||
item.set_text = function (_,value)
|
||||
if data.disable_markup then
|
||||
|
@ -183,7 +183,7 @@ function module:setup_item(data,item,args)
|
|||
|
||||
-- Compute the minimum width
|
||||
if data.auto_resize and item._internal.margin_w then
|
||||
local fit_w,fit_h = wibox.layout.margin.fit(item._internal.margin_w,9999,9999)
|
||||
local fit_w = wibox.layout.margin.fit(item._internal.margin_w,{},9999,9999)
|
||||
local is_largest = item == data._internal.largest_item_w
|
||||
if fit_w < 1000 and (not data._internal.largest_item_w_v or data._internal.largest_item_w_v < fit_w) then
|
||||
data._internal.largest_item_w = item
|
||||
|
@ -202,8 +202,8 @@ local function compute_geo(data,width,height,force_values)
|
|||
|
||||
local visblerow = data.visible_row_count
|
||||
|
||||
local sw,sh = data._internal.suf_l:fit(9999,9999)
|
||||
local pw,ph = data._internal.pref_l:fit(9999,9999)
|
||||
local sw,sh = data._internal.suf_l:fit({dpi=96},9999,9999)
|
||||
local pw,ph = data._internal.pref_l:fit({dpi=96},9999,9999)
|
||||
if not data._internal.has_widget then
|
||||
return w,(total and total > 0 and total or visblerow*data.item_height) + ph + sh
|
||||
else
|
||||
|
@ -217,8 +217,8 @@ local function new(data)
|
|||
if not base then
|
||||
base = require( "radical.base" )
|
||||
end
|
||||
local l,real_l = wibox.layout.fixed.vertical(),nil
|
||||
real_l = wibox.layout.fixed.vertical()
|
||||
local l = wibox.layout.fixed.vertical()
|
||||
local real_l = wibox.layout.fixed.vertical()
|
||||
local pref_l,suf_l = wibox.layout.fixed.vertical(),wibox.layout.fixed.vertical()
|
||||
real_l:add(pref_l)
|
||||
if data.max_items then
|
||||
|
@ -239,9 +239,9 @@ local function new(data)
|
|||
suf_l:add(data._internal.scroll_w["down"])
|
||||
end
|
||||
end
|
||||
real_l.fit = function(a1,a2,a3,force_values)
|
||||
real_l.fit = function(self,context,o_w,o_h,force_values)
|
||||
if not data.visible then return 1,1 end
|
||||
local w,h = compute_geo(data,a2,a3,force_values)
|
||||
local w,h = compute_geo(data,o_w,o_h,force_values)
|
||||
data:emit_signal("layout_size",w,h)
|
||||
return w,h
|
||||
end
|
||||
|
@ -287,7 +287,7 @@ local function new(data)
|
|||
data:connect_signal("suffix_widget::added",function(_,widget,args)
|
||||
suf_l:add(widget)
|
||||
end)
|
||||
data._internal.text_fit = function(self,width,height) return width,height end
|
||||
data._internal.text_fit = function(self,context,width,height) return width,height end
|
||||
return real_l
|
||||
end
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ local function get_arrow_x(data)
|
|||
return data._arrow_x
|
||||
end
|
||||
|
||||
-- Draw the border on top of items, prevent sharp corners from messing with the border
|
||||
local function draw_border(self,w, cr, width, height)
|
||||
-- Draw the widget content
|
||||
self.__draw(self,w, cr, width, height)
|
||||
-- As the menus have a rounded border, rectangle elements will draw over the
|
||||
-- corner border. To fix this, this method re-draw the border on top of the
|
||||
-- content
|
||||
local function after_draw_children(self, context, cr, width, height)
|
||||
local data = self._data
|
||||
|
||||
-- Create a matrix to rotate the border
|
||||
|
@ -217,7 +217,7 @@ local function draw(data,args)
|
|||
-- Prevent sharp corners from being over the border
|
||||
if data._internal.margin then
|
||||
data._internal.margin.__draw = data._internal.margin.draw
|
||||
data._internal.margin.draw = draw_border
|
||||
data._internal.margin.after_draw_children = after_draw_children
|
||||
if not data._internal.margin._data then
|
||||
data._internal.margin._data = data
|
||||
end
|
||||
|
|
|
@ -23,20 +23,25 @@ local function rounded_rect(cr,x,y,w,h,radius)
|
|||
cr:restore()
|
||||
end
|
||||
|
||||
local function draw2(self,w, cr, width, height)
|
||||
local function draw2(self, context, cr, width, height)
|
||||
cr:save()
|
||||
local mx,my = self.left or 0, self.top or 0
|
||||
local mw,mh = width - mx - (self.right or 0), height - my - (self.bottom or 0)
|
||||
rounded_rect(cr,mx,my,mw,mh,6)
|
||||
local path = cr:copy_path()
|
||||
cr:clip()
|
||||
self.___draw(self,w, cr, width, height)
|
||||
|
||||
if self.___draw then
|
||||
self.___draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
cr:append_path(path)
|
||||
cr:set_source(color(self.data.border_color))
|
||||
cr:stroke()
|
||||
cr:restore()
|
||||
end
|
||||
|
||||
--TODO unported
|
||||
local function draw(data)
|
||||
if not data._internal then return end
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ local function new(widget,text, args)
|
|||
|
||||
data.wibox:connect_signal("mouse::leave",hide_tooltip)
|
||||
local relative_to_parent = rel_parent(data.wibox,args2,args)
|
||||
data.wibox.x = args2.x or args.x or relative_to_parent.x or capi.mouse.coords().x - data.wibox.width/2 -5
|
||||
data.wibox.y = args2.y or args.y or relative_to_parent.y or ((not vertical) and capi.screen[capi.mouse.screen].geometry.height - 16 - 25 or 16)
|
||||
data.wibox.x = math.floor(args2.x or args.x or relative_to_parent.x or capi.mouse.coords().x - data.wibox.width/2 -5)
|
||||
data.wibox.y = math.floor(args2.y or args.y or relative_to_parent.y or ((not vertical) and capi.screen[capi.mouse.screen].geometry.height - 16 - 25 or 16))
|
||||
data.wibox.visible = true
|
||||
if args2.parent and args2.parent.drawable and data.drawable ~= args2.parent.drawable then
|
||||
data.drawable = args2.parent.drawable
|
||||
|
|
|
@ -14,7 +14,7 @@ local function new(data)
|
|||
bg:set_bg(data.bg_highlight)
|
||||
bg:set_widget(filter_tb)
|
||||
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder)
|
||||
filter_tb.fit = function(tb,width,height)
|
||||
filter_tb.fit = function(tb,context,width,height)
|
||||
return width,data.item_height
|
||||
end
|
||||
filter_tb:set_underlay(data.filter_underlay,{alpha=data.filter_underlay_alpha,color=data.filter_underlay_color})
|
||||
|
|
|
@ -24,7 +24,7 @@ end
|
|||
|
||||
local function new(data,item)
|
||||
local pref = wibox.widget.textbox()
|
||||
pref.draw = function(self,w, cr, width, height)
|
||||
pref.draw = function(self, context, cr, width, height)
|
||||
local padding = height/4
|
||||
local key = item._internal.f_key
|
||||
if not keys[height] then
|
||||
|
@ -55,7 +55,7 @@ local function new(data,item)
|
|||
cr:set_source_surface((key and key > 12 and keys[height][0]) and keys[height][0] or keys[height][key])
|
||||
cr:paint()
|
||||
end
|
||||
pref.fit = function(self,width,height)
|
||||
pref.fit = function(self,context,width,height)
|
||||
return max_width,data.item_height
|
||||
end
|
||||
pref:set_markup("<span fgcolor='".. beautiful.bg_normal .."'><tt><b>F11</b></tt></span>")
|
||||
|
|
|
@ -38,7 +38,7 @@ local function compute_sum(data)
|
|||
return ret
|
||||
end
|
||||
|
||||
local function draw(self, w, cr, width, height)
|
||||
local function draw(self, context, cr, width, height)
|
||||
if not self._data then return end
|
||||
|
||||
-- Load from cache
|
||||
|
|
|
@ -50,13 +50,13 @@ local function new(data)
|
|||
for k,v in ipairs({"up","down"}) do
|
||||
local ib = wibox.widget.imagebox()
|
||||
ib:set_image(module[v]())
|
||||
ib.fit = function(tb,width,height)
|
||||
ib.fit = function(tb,context,width,height)
|
||||
if scroll_w.visible == false then
|
||||
return 0,0
|
||||
end
|
||||
return width,data.item_height
|
||||
end
|
||||
ib.draw = function(self,wibox, cr, width, height)
|
||||
ib.draw = function(self, context, cr, width, height)
|
||||
if width > 0 and height > 0 then
|
||||
cr:set_source_surface(self._image, width/2 - self._image:get_width()/2, 0)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ local beautiful = require( "beautiful" )
|
|||
|
||||
local module = {HORIZONTAL=1,VERTICAL=2}
|
||||
|
||||
local function draw(self, w, cr, width, height)
|
||||
local function draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
cr:set_source(self._color)
|
||||
if self.direction == module.VERTICAL then
|
||||
|
@ -19,7 +19,7 @@ local function draw(self, w, cr, width, height)
|
|||
cr:restore()
|
||||
end
|
||||
|
||||
local function fit(box, w, h)
|
||||
local function fit(box, context, w, h)
|
||||
local direction = box.direction or w > h and module.HORIZONTAL or module.VERTICAL
|
||||
return direction == module.VERTICAL and 5 or w,direction == module.VERTICAL and h or 5
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ local color = require("gears.color")
|
|||
local ipairs = ipairs
|
||||
local print = print
|
||||
|
||||
local function textbox_draw(self, w, cr, width, height)
|
||||
local function textbox_draw(self, context, cr, width, height)
|
||||
cr:save()
|
||||
cr:set_source(color(beautiful.menu_border_color or beautiful.border_normal or beautiful.border_color))
|
||||
cr:rectangle(0,0,width,1)
|
||||
|
@ -12,14 +12,14 @@ local function textbox_draw(self, w, cr, width, height)
|
|||
cr:stroke()
|
||||
cr:restore()
|
||||
cr:set_source(color(beautiful.menu_fg_normal or beautiful.fg_normal))
|
||||
wibox.widget.textbox.draw(self, w, cr, width, height)
|
||||
wibox.widget.textbox.draw(self, context, cr, width, height)
|
||||
end
|
||||
|
||||
local function create_textbox(w,col_c,col,has_v_header,row_height)
|
||||
local function create_textbox(context,col_c,col,has_v_header,row_height)
|
||||
local t = wibox.widget.textbox()
|
||||
|
||||
t.fit = function(s,w2,h)
|
||||
local fw,fh = wibox.widget.textbox.fit(s,w2,h)
|
||||
t.fit = function(s,context,w2,h)
|
||||
local fw,fh = wibox.widget.textbox.fit(s,context,w2,h)
|
||||
return (w2/(col_c+2 - col)),row_height or fh
|
||||
end
|
||||
t.draw = textbox_draw
|
||||
|
@ -27,19 +27,19 @@ local function create_textbox(w,col_c,col,has_v_header,row_height)
|
|||
return t
|
||||
end
|
||||
|
||||
local function create_h_header(main_l,cols,w,args)
|
||||
local function create_h_header(main_l,cols,context,args)
|
||||
if args.h_header then
|
||||
local bg = wibox.widget.background()
|
||||
local row_l = wibox.layout.fixed.horizontal()
|
||||
bg:set_bg(beautiful.menu_table_bg_header or beautiful.menu_bg_header or beautiful.fg_normal)
|
||||
bg:set_widget(row_l)
|
||||
if args.v_header then
|
||||
local t = create_textbox(w,cols,1,args.v_header ~= nil,args.row_height)
|
||||
local t = create_textbox(context,cols,1,args.v_header ~= nil,args.row_height)
|
||||
t:set_markup("<span color='".. beautiful.bg_normal .."'>--</span>")
|
||||
row_l:add(t)
|
||||
end
|
||||
for i=1,cols do
|
||||
local t = create_textbox(w,cols,i+1,args.v_header ~= nil,args.row_height)
|
||||
local t = create_textbox(context,cols,i+1,args.v_header ~= nil,args.row_height)
|
||||
t:set_markup("<span color='".. beautiful.bg_normal .."'>".. (args.h_header[i] or "-") .."</span>")
|
||||
row_l:add(t)
|
||||
end
|
||||
|
@ -58,9 +58,9 @@ local function new(content,args)
|
|||
end
|
||||
local main_l = wibox.layout.fixed.vertical()
|
||||
local w =200
|
||||
main_l.fit = function(self,width,height)
|
||||
main_l.fit = function(self,context,width,height)
|
||||
w = width
|
||||
return wibox.layout.fixed.fit(self,width,height)
|
||||
return wibox.layout.fixed.fit(self,context,width,height)
|
||||
end
|
||||
create_h_header(main_l,cols,w,args)
|
||||
|
||||
|
|
Loading…
Reference in New Issue