Fixed bug with VN scrolling

This commit is contained in:
2023-06-18 10:00:28 -07:00
parent 24cf072b97
commit de7504a4b4
7 changed files with 56 additions and 14 deletions

View File

@ -7,13 +7,18 @@
using namespace Dawn;
UsageLock::UsageLock() {
UsageLock::UsageLock() : UsageLock(&this->internalPool) {
}
UsageLock::UsageLock(usagelockid_t *lockPool) {
assertNotNull(lockPool);
this->pool = lockPool;
this->onEmpty = []() {};
this->onFirstLock = []() {};
}
usagelockid_t UsageLock::createLock() {
usagelockid_t lock = this->nextLock++;
usagelockid_t lock = (*this->pool)++;
this->locks.push_back(lock);
if(this->locks.size() == 1) this->onFirstLock();
return lock;
@ -23,5 +28,6 @@ void UsageLock::removeLock(usagelockid_t lock) {
auto it = std::find(this->locks.begin(), this->locks.end(), lock);
if(it == this->locks.end()) return;
this->locks.erase(it);
this->onLockRemoved(lock);
if(this->locks.size() == 0) this->onEmpty();
}

View File

@ -10,18 +10,27 @@ namespace Dawn {
class UsageLock {
protected:
usagelockid_t nextLock = 0;
usagelockid_t internalPool = 0;
usagelockid_t *pool = nullptr;
std::vector<usagelockid_t> locks;
public:
std::function<void()> onEmpty;
std::function<void()> onFirstLock;
std::function<void(usagelockid_t)> onLockRemoved;
/**
* Construct a new usage lock object.
*/
UsageLock();
/**
* Construct a new Usage Lock object
*
* @param lockPool Pool that will be used to create locks.
*/
UsageLock(usagelockid_t *lockPool);
/**
* Creates a new lock.
*