cleanup: Port scrolling to Awesome 3.6 visible widget API
It still doesn't work, but at least there is no logic duplication with Awesome anymore.
This commit is contained in:
parent
a1abd2f57a
commit
f48ede52f9
14
base.lua
14
base.lua
|
@ -91,7 +91,7 @@ local function filter(data)
|
|||
if tmp ~= v._filter_out then
|
||||
v.widget:emit_signal("widget::updated")
|
||||
end
|
||||
if (not v._filter_out) and (not v._hidden) then
|
||||
if (not v._filter_out) and (not v.widget.visible == false) then
|
||||
visible_counter = visible_counter + v.height
|
||||
data._internal.visible_item_count = data._internal.visible_item_count +1
|
||||
v.f_key = data._internal.visible_item_count
|
||||
|
@ -475,14 +475,14 @@ local function new(args)
|
|||
|
||||
data.get_previous_item = function(_)
|
||||
local candidate,idx = internal.items[(data.current_index or 0)-1],(data.current_index or 0)-1
|
||||
while candidate and (candidate._hidden or candidate._filter_out) and idx > 0 do
|
||||
while candidate and (candidate.widget.visible == false or candidate._filter_out) and idx > 0 do
|
||||
candidate,idx = internal.items[idx - 1],idx-1
|
||||
end
|
||||
return (candidate or internal.items[data.rowcount])
|
||||
end
|
||||
data.get_next_item = function(_)
|
||||
local candidate,idx = internal.items[(data.current_index or 0)+1],(data.current_index or 0)+1
|
||||
while candidate and (candidate._hidden or candidate._filter_out) and idx <= data.rowcount do
|
||||
while candidate and (candidate.widget.visible == false or candidate._filter_out) and idx <= data.rowcount do
|
||||
candidate,idx = internal.items[idx + 1],idx+1
|
||||
end
|
||||
return (candidate or internal.items[1])
|
||||
|
@ -602,9 +602,9 @@ local function new(args)
|
|||
current_item:set_selected(false,true)
|
||||
end
|
||||
data._start_at = (data._start_at or 1) - 1
|
||||
internal.items[data._start_at]._hidden = false
|
||||
internal.items[data._start_at].widget:set_visible(false)
|
||||
data:emit_signal("_hidden::changed",internal.items[data._start_at])
|
||||
internal.items[data._start_at+data.max_items]._hidden = true
|
||||
internal.items[data._start_at+data.max_items].widget:set_visible(true)
|
||||
data:emit_signal("_hidden::changed",internal.items[data._start_at+data.max_items])
|
||||
filter(data)
|
||||
|
||||
|
@ -623,9 +623,9 @@ local function new(args)
|
|||
current_item:set_selected(false,true)
|
||||
end
|
||||
data._start_at = (data._start_at or 1) + 1
|
||||
internal.items[data._start_at-1]._hidden = true
|
||||
internal.items[data._start_at-1].widget:set_visible(true)
|
||||
data:emit_signal("_hidden::changed",internal.items[data._start_at-1])
|
||||
internal.items[data._start_at-1+data.max_items]._hidden = false
|
||||
internal.items[data._start_at-1+data.max_items].widget:set_visible(false)
|
||||
data:emit_signal("_hidden::changed",internal.items[data._start_at-1+data.max_items])
|
||||
filter(data)
|
||||
|
||||
|
|
|
@ -164,10 +164,6 @@ function module.setup_item_move_events(data)
|
|||
l:reset()
|
||||
end)
|
||||
|
||||
data:connect_signal("_hidden::changed",function(_,item)
|
||||
item.widget:emit_signal("widget::updated")
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function module.setup_state_events(data, item)
|
||||
|
@ -218,6 +214,11 @@ function module.setup_item(data,item,args)
|
|||
item.infoshapes = item._internal.infoshapes
|
||||
end
|
||||
|
||||
-- Hide items after the maximum is reached
|
||||
if data.max_items ~= nil and data.rowcount > data.max_items then-- and (data._start_at or 0)
|
||||
item.widget:set_visible(false)
|
||||
end
|
||||
|
||||
item.widget:emit_signal("widget::updated")
|
||||
end
|
||||
|
||||
|
|
|
@ -56,11 +56,8 @@ local function new(args)
|
|||
local l = ret._internal.content_layout or ret._internal.layout
|
||||
l:reset()
|
||||
end)
|
||||
ret:connect_signal("_hidden::changed",function(_,item)
|
||||
item.widget:emit_signal("widget::updated")
|
||||
end)
|
||||
return ret
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
|
|
|
@ -135,9 +135,9 @@ local function new_item(data,args)
|
|||
item._private_data = private_data
|
||||
item._internal = args._internal or {}
|
||||
theme.setup_item_colors(data,item,args)
|
||||
item.get_y = function()
|
||||
return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height --Hack around missing :fit call for last item
|
||||
end
|
||||
-- item.get_y = function()
|
||||
-- return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height --Hack around missing :fit call for last item
|
||||
-- end
|
||||
item.get_height = function()
|
||||
return args.height or data.item_height or beautiful.menu_height or 30
|
||||
end
|
||||
|
@ -154,10 +154,6 @@ local function new_item(data,args)
|
|||
item["button"..i] = args["button"..i]
|
||||
end
|
||||
|
||||
if data.max_items ~= nil and data.rowcount >= data.max_items then-- and (data._start_at or 0)
|
||||
item._hidden = true
|
||||
end
|
||||
|
||||
-- Use _internal to avoid the radical.object trigger
|
||||
data._internal.visible_item_count = (data._internal.visible_item_count or 0) + 1
|
||||
item._internal.f_key = data._internal.visible_item_count
|
||||
|
|
|
@ -23,7 +23,7 @@ function module:setup_item(data,item,args)
|
|||
item._private_data._fit = wibox.widget.background.fit
|
||||
if item._internal.margin_w then
|
||||
item._internal.margin_w.fit = function(...)
|
||||
if (item.visible == false or item._filter_out == true or item._hidden == true) then
|
||||
if (item.visible == false or item._filter_out == true or item.widget.visible == false) then
|
||||
return 0,0
|
||||
end
|
||||
return item_fit(data,item,...)
|
||||
|
@ -129,8 +129,6 @@ local function new(data)
|
|||
-- Set the overloaded methods
|
||||
real_l.fit = real_fit
|
||||
|
||||
local l = data._internal.content_layout
|
||||
|
||||
return real_l
|
||||
end
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ local function return_data(tab, key)
|
|||
end
|
||||
|
||||
-- Common method to set foreground and background color dependeing on state
|
||||
function module.update_colors(item)
|
||||
function module.update_colors(item, current_state_override)
|
||||
local state = item.state or {}
|
||||
local current_state = state._current_key or nil
|
||||
local current_state = current_state_override or state._current_key or nil
|
||||
|
||||
local state_name = base.colors_by_id[current_state]
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ local button = require( "awful.button" )
|
|||
local beautiful = require( "beautiful" )
|
||||
local shape = require( "gears.shape" )
|
||||
local surface = require( "gears.surface" )
|
||||
local theme = require( "radical.theme" )
|
||||
local rad_item = require( "radical.item" )
|
||||
|
||||
local module = {}
|
||||
|
||||
|
@ -66,10 +68,11 @@ local function new(data)
|
|||
scroll_w[v].visible = true
|
||||
data.item_style({widget=scroll_w[v]},{color=data.bg_highlight})
|
||||
scroll_w[v]:connect_signal("mouse::enter",function()
|
||||
data.item_style({widget=scroll_w[v]},{color=data.bg_alternate or beautiful.bg_focus})
|
||||
--FIXME once the theme use a metatable chain, this should start working again
|
||||
theme.update_colors({widget=scroll_w[v]},rad_item.item_flags.HOVER)
|
||||
end)
|
||||
scroll_w[v]:connect_signal("mouse::leave",function()
|
||||
data.item_style({widget=scroll_w[v]},{color=data.bg_highlight})
|
||||
theme.update_colors({widget=scroll_w[v]},rad_item.item_flags.NONE)
|
||||
end)
|
||||
scroll_w[v]:buttons( util.table.join( button({ }, 1, function()
|
||||
data["scroll_"..v](data)
|
||||
|
|
Loading…
Reference in New Issue