fix: reset view on page change

This commit is contained in:
Kazhnuz Klappsthul 2021-01-29 21:54:34 +01:00
parent f8910aefa4
commit 8f1c326e6a
6 changed files with 24 additions and 0 deletions

View File

@ -45,6 +45,10 @@ function FlowBox:setRealSize()
self.h = self.view.lineNumber * self.widgetSize.h
end
function FlowBox:resetView()
self.view:reset()
end
-- UPDATE FUNCTIONS
-- Update the menu and its view

View File

@ -137,6 +137,11 @@ function GridBox:update(dt)
self.view.firstSlot = 1
end
function GridBox:resetView()
self.view:reset()
end
-- KEYS FUNCTIONS
-- Handle the keyboard/manette functions

View File

@ -50,6 +50,10 @@ function HListBox:update(dt)
self.view:updateFirstSlot(self.widget:getSelected())
end
function HListBox:resetView()
self.view:reset()
end
-- KEYBOARD FUNCTIONS
-- Handle key check.

View File

@ -50,6 +50,10 @@ function ListBox:update(dt)
self.view:updateFirstSlot(self.widget:getSelected())
end
function ListBox:resetView()
self.view:reset()
end
-- KEYBOARD FUNCTIONS
-- Handle input from keyboard/controllers.

View File

@ -109,10 +109,12 @@ end
function Menu:switch(pageName)
self.widget:switch(pageName)
self:resetView()
end
function Menu:back()
self.widget:back()
self:resetView()
end
-- ACTION FUNCTIONS

View File

@ -29,6 +29,11 @@ function View1D:new(slotNumber)
self.firstSlot = 1
end
function View1D:reset()
self.firstSlot = 1
print("reset")
end
function View1D:updateFirstSlot(widgetID)
self.firstSlot = math.max(1, widgetID - (self.slotNumber - 1), math.min(widgetID, self.firstSlot))
end