Improve HiDPI support and fix 0 item submenus
This commit is contained in:
parent
10fb812c23
commit
76d34dd93d
3
base.lua
3
base.lua
|
@ -150,7 +150,7 @@ local function add_item(data,args)
|
|||
end
|
||||
if (private_data.sub_menu_f or private_data.sub_menu_m)and data._current_item ~= item then
|
||||
local sub_menu = private_data.sub_menu_m or private_data.sub_menu_f()
|
||||
if sub_menu then
|
||||
if sub_menu and sub_menu.rowcount > 0 then
|
||||
sub_menu.arrow_type = module.arrow_type.NONE
|
||||
sub_menu.parent_item = item
|
||||
sub_menu.parent_geometry = data
|
||||
|
@ -365,7 +365,6 @@ local function new(args)
|
|||
-- data.style(data,{arrow_x=20,margin=internal.margin})
|
||||
else
|
||||
data.has_changed = true
|
||||
internal.layout:emit_signal("widget::updated")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ local layout = require( "radical.layout" )
|
|||
local checkbox = require( "radical.widgets.checkbox" )
|
||||
local arrow_style = require( "radical.style.arrow" )
|
||||
|
||||
local capi,module = { mouse = mouse , screen = screen , keygrabber = keygrabber },{}
|
||||
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
||||
|
||||
local function get_direction(data)
|
||||
local parent_geometry = data.parent_geometry --Local cache to avoid always calling the object hooks
|
||||
|
@ -143,7 +143,8 @@ local function setup_drawable(data)
|
|||
set_map.height = function(value)
|
||||
local margins = data.margins
|
||||
local need_update = (internal.w.height ~= (value + margins.top + margins.bottom))
|
||||
internal.w.height = (value + margins.top + margins.bottom) or 1
|
||||
local new_height = (value + margins.top + margins.bottom) or 1
|
||||
internal.w.height = new_height > 0 and new_height or 1
|
||||
if need_update then
|
||||
data.style(data)
|
||||
internal.set_position(data)
|
||||
|
|
|
@ -104,7 +104,6 @@ function module:setup_item(data,item,args)
|
|||
data.item_style(data,item,false,false)
|
||||
item.widget:set_fg(item._private_data.fg)
|
||||
item._internal.has_changed = true
|
||||
data._internal.layout:emit_signal("widget::updated")
|
||||
|
||||
--Event handling
|
||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||
|
@ -220,7 +219,6 @@ function module:setup_item(data,item,args)
|
|||
data._internal.largest_item_w = item
|
||||
data._internal.largest_item_w_v = fit_w
|
||||
end
|
||||
data._internal.layout:emit_signal("widget::updated")
|
||||
--TODO find new largest is item is smaller
|
||||
-- if data._internal.largest_item_h_v < fit_h then
|
||||
-- data._internal.largest_item_h =item
|
||||
|
@ -231,7 +229,6 @@ function module:setup_item(data,item,args)
|
|||
|
||||
item._internal.set_map.f_key = function(value)
|
||||
item._internal.has_changed = true
|
||||
data._internal.layout:emit_signal("widget::updated")
|
||||
item._internal.f_key = value
|
||||
data:remove_key_hook("F"..value)
|
||||
data:add_key_hook({}, "F"..value , "press", function()
|
||||
|
|
|
@ -13,12 +13,13 @@ local keys = {}
|
|||
|
||||
local pango_l,pango_crx,max_width,m_h = nil,nil,0,0
|
||||
local function create_pango()
|
||||
local padding = beautiful.menu_height/5
|
||||
pango_crx = pangocairo.font_map_get_default():create_context()
|
||||
pango_l = pango.Layout.new(pango_crx)
|
||||
local desc = pango.FontDescription()
|
||||
desc:set_family("Verdana")
|
||||
desc:set_weight(pango.Weight.BOLD)
|
||||
desc:set_size((m_h-8) * pango.SCALE)
|
||||
desc:set_size((m_h-padding*2) * pango.SCALE)
|
||||
pango_l:set_font_description(desc)
|
||||
pango_l.text = "F88"
|
||||
max_width = pango_l:get_pixel_extents().width + m_h + 4
|
||||
|
@ -26,6 +27,7 @@ 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 key = item._internal.f_key
|
||||
if m_h == 0 then
|
||||
|
@ -45,13 +47,13 @@ local function new(data,item)
|
|||
local img = cairo.ImageSurface(cairo.Format.ARGB32, max_width,beautiful.menu_height)
|
||||
local cr2 = cairo.Context(img)
|
||||
cr2:set_source(color(beautiful.fg_normal))
|
||||
cr2:arc((height-4)/2 + 2, (height-4)/2 + 2, (height-4)/2,0,2*math.pi)
|
||||
cr2:arc(max_width - (height-4)/2 - 2, (height-4)/2 + 2, (height-4)/2,0,2*math.pi)
|
||||
cr2:rectangle((height-4)/2+2,2,max_width - (height),(height-4))
|
||||
cr2:arc((height-padding)/2 + 2, (height-padding)/2 + padding/2, (height-padding)/2,0,2*math.pi)
|
||||
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("Verdana", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||
cr2:set_font_size(height-6)
|
||||
cr2:move_to(height/2 + 2,1)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue