Make F-key widget scale better to lower size
This commit is contained in:
parent
95c37a93b9
commit
e20c6921dc
|
@ -7,13 +7,10 @@ local pangocairo = require( "lgi" ).PangoCairo
|
|||
local wibox = require( "wibox" )
|
||||
local beautiful = require( "beautiful" )
|
||||
|
||||
local module = {}
|
||||
local pango_l,pango_crx,max_width,keys = nil,nil,0,{}
|
||||
|
||||
local keys = {}
|
||||
|
||||
local pango_l,pango_crx,max_width = nil,nil,0
|
||||
local function create_pango(height)
|
||||
local padding = beautiful.menu_height/5
|
||||
local padding = height/4
|
||||
pango_crx = pangocairo.font_map_get_default():create_context()
|
||||
pango_l = pango.Layout.new(pango_crx)
|
||||
local desc = pango.FontDescription()
|
||||
|
@ -27,8 +24,8 @@ end
|
|||
|
||||
local function new(data,item)
|
||||
local pref = wibox.widget.textbox()
|
||||
local padding = beautiful.menu_height/5
|
||||
pref.draw = function(self,w, cr, width, height)
|
||||
local padding = height/4
|
||||
local key = item._internal.f_key
|
||||
if not keys[height] then
|
||||
pref:emit_signal("widget::updated")
|
||||
|
@ -49,26 +46,14 @@ local function new(data,item)
|
|||
cr2:arc(max_width - (height-padding)/2 - 2, (height-padding)/2 + padding/2, (height-padding)/2,0,2*math.pi)
|
||||
cr2:rectangle((height-padding)/2+2,padding/2,max_width - (height),(height-padding))
|
||||
cr2:fill()
|
||||
cr2:select_font_face("Arial", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||
cr2:set_font_size(height-padding*1.5)
|
||||
cr2:move_to(height/2 + padding/2,padding/4)
|
||||
cr2:set_source(color(beautiful.bg_normal))
|
||||
local text = (key and key <= 12) and ("F"..(key)) or " ---"
|
||||
pango_l.text = text
|
||||
pango_l.text = (key and key <= 12) and ("F"..(key)) or " ---"
|
||||
cr2:show_layout(pango_l)
|
||||
if key > 12 then
|
||||
keys[height][0] = img
|
||||
else
|
||||
keys[height][key] = img
|
||||
end
|
||||
end
|
||||
if key and key > 12 and keys[height][0] then
|
||||
cr:set_source_surface(keys[height][0])
|
||||
cr:paint()
|
||||
else
|
||||
cr:set_source_surface(keys[height][key])
|
||||
cr:paint()
|
||||
keys[height][key > 12 and 0 or key] = img
|
||||
end
|
||||
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)
|
||||
return max_width,data.item_height
|
||||
|
@ -77,5 +62,5 @@ local function new(data,item)
|
|||
return pref
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
return setmetatable({}, { __call = function(_, ...) return new(...) end })
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
|
|
Loading…
Reference in New Issue