SDL does not guard against the final callback still executing when the
call to remove the timer returns. So we have to make sure the object
we access on the callback is not prematurely destructed. This commit
uses shared_ptr and weak_ptr to ensure that.
Note that we sort-of have a singleton again, only now it is private
and safely destructed.
Removed the suspend check: the best thing we can do after oversleeping
is the same as when we're woken right on time: fetch the time and
reschedule for the next minute boundary.
Don't create a new timer on every callback; instead return the next
interval to SDL.
Don't make Clock a singleton. While there should be no reason to
instantiate this class more than once, there is no problem with doing
that either. Removing the singleton makes it easier to control access
to the instance. It also avoids the rather nasty construct that was
used to delete it.
Make sure the timer callback function is a proper C function, since
SDL is a C library. This requires some trickery to be able to call
a private method from the callback, but I found a way using an
intermediate nested class. The compiler should be able to inline this
to eliminate any overhead.
Also some minor cleanups.
This method was never called.
And I cannot really think of a scenario in which it is useful to wait
for any button to be released: a particular button or all buttons I can
imagine, but not any button.
Instead of having a list and wrapping between beginning and end, always
put the current section in the middle and show the previous and next
sections using wrap-around.
Made sure it fills the space between the top and bottom bar. Use a one
pixel margin; I tried without margins but it didn't look nice.
Also cleaned up the paint code a bit.
Replaced Font constructor with factory method, so that if the TTF
cannot be loaded, the Font object is not constructed. The normal C++
way of handling this is with exceptions, but we're compiling with
-fno-exceptions.
Originally the font implementation was based on SFont, but it was
recently replaced by an SDL_ttf based implementation, so the name
no longer made sense.
The code still has a lot of overlap with the other methods of Link and
LinkApp, but at least it is in the same place now.
Since this was the last outside use, setIconPath() could be declared
as 'protected'.
This could be used to create platform-independent packages. It can
be useful for instance in the case where the executable is a script,
or when the package points to an executable that is present on all
systems on which OPKs are supposed to run.