Formatting
This commit is contained in:
parent
86bef7a2d2
commit
b300def18c
|
@ -82,6 +82,44 @@ local function has_value(tab, val)
|
|||
return false
|
||||
end
|
||||
|
||||
local function scroll(self, dir)
|
||||
if #self:get_grid().children < 1 then
|
||||
self._private.active_widget = nil
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self:get_grid():get_widget_position(self._private.active_widget)
|
||||
local can_scroll = false
|
||||
local step_size = 0
|
||||
local if_cant_scroll_func = nil
|
||||
|
||||
if dir == "up" then
|
||||
can_scroll = self:get_grid():index(self._private.active_widget) > 1
|
||||
step_size = -1
|
||||
if_cant_scroll_func = function() self:page_backward("up") end
|
||||
elseif dir == "down" then
|
||||
can_scroll = self:get_grid():index(self._private.active_widget) < #self:get_grid().children
|
||||
step_size = 1
|
||||
if_cant_scroll_func = function() self:page_forward("down") end
|
||||
elseif dir == "left" then
|
||||
can_scroll = self:get_grid():get_widgets_at(pos.row, pos.col - 1) ~= nil
|
||||
step_size = -self:get_grid().forced_num_rows
|
||||
if_cant_scroll_func = function() self:page_backward("left") end
|
||||
elseif dir == "right" then
|
||||
can_scroll = self:get_grid():get_widgets_at(pos.row, pos.col + 1) ~= nil
|
||||
step_size = self:get_grid().forced_num_cols
|
||||
if_cant_scroll_func = function() self:page_forward("right") end
|
||||
end
|
||||
|
||||
if can_scroll then
|
||||
local app = gtable.cycle_value(self:get_grid().children, self._private.active_widget, step_size)
|
||||
app:select()
|
||||
self:emit_signal("scroll", dir)
|
||||
else
|
||||
if_cant_scroll_func()
|
||||
end
|
||||
end
|
||||
|
||||
local function app_widget(self, app)
|
||||
local widget = nil
|
||||
|
||||
|
@ -229,44 +267,6 @@ local function app_widget(self, app)
|
|||
return widget
|
||||
end
|
||||
|
||||
local function scroll(self, dir)
|
||||
if #self:get_grid().children < 1 then
|
||||
self._private.active_widget = nil
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self:get_grid():get_widget_position(self._private.active_widget)
|
||||
local can_scroll = false
|
||||
local step_size = 0
|
||||
local if_cant_scroll_func = nil
|
||||
|
||||
if dir == "up" then
|
||||
can_scroll = self:get_grid():index(self._private.active_widget) > 1
|
||||
step_size = -1
|
||||
if_cant_scroll_func = function() self:page_backward("up") end
|
||||
elseif dir == "down" then
|
||||
can_scroll = self:get_grid():index(self._private.active_widget) < #self:get_grid().children
|
||||
step_size = 1
|
||||
if_cant_scroll_func = function() self:page_forward("down") end
|
||||
elseif dir == "left" then
|
||||
can_scroll = self:get_grid():get_widgets_at(pos.row, pos.col - 1) ~= nil
|
||||
step_size = -self:get_grid().forced_num_rows
|
||||
if_cant_scroll_func = function() self:page_backward("left") end
|
||||
elseif dir == "right" then
|
||||
can_scroll = self:get_grid():get_widgets_at(pos.row, pos.col + 1) ~= nil
|
||||
step_size = self:get_grid().forced_num_cols
|
||||
if_cant_scroll_func = function() self:page_forward("right") end
|
||||
end
|
||||
|
||||
if can_scroll then
|
||||
local app = gtable.cycle_value(self:get_grid().children, self._private.active_widget, step_size)
|
||||
app:select()
|
||||
self:emit_signal("scroll", dir)
|
||||
else
|
||||
if_cant_scroll_func()
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_apps(self)
|
||||
self._private.all_apps = {}
|
||||
self._private.matched_apps = {}
|
||||
|
|
Loading…
Reference in New Issue