1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 21:05:27 +03:00
Commit Graph

638 Commits

Author SHA1 Message Date
Maarten ter Huurne
d4344c7960 Revert "Removed support for multi-line text drawing"
This reverts commit 0908aa7bb7.

It turns out there are multi-line text messages in use: Nebuleon found
one in the confirmation message when deleting a section.
2014-07-23 02:22:27 +02:00
Maarten ter Huurne
79dcc8a146 Implemented stream output for RGBAColor
In commit 950518f3 I changed the component type of RGBAColor from
16-bit to 8-bit integers. Unfortunately, in C++ 8-bit integers are
identical to characters, so this broke the writing of colors to
output streams.
2014-07-19 12:06:09 +02:00
Nebuleon Fumika
69d6c0006c TextDialog: Improve the average and worst-case performance of word wrapping
This affects manuals, About GMenu2X, and the Log Viewer.

Instead of trying to compute the width of the entire string, then backing
off one word at a time, TextDialog::preProcess now performs a binary search
on Font::getTextWidth(string) and backs off to the last fitting space, if
there is one, at the last moment.

In Japanese and Chinese text, words are not usually separated by spaces.
Text in these languages is now wrapped when it would reach the edge of the
screen.
2014-07-19 02:35:09 +02:00
Maarten ter Huurne
9b93eabcc5 Clean up trim() utility function 2014-07-19 02:32:30 +02:00
Zear
cdf4ef1bf4 Introduced custom application launch text
This can be used to override weird automatically constructed messages
such as "Launching Power Off".
2014-07-19 01:09:16 +02:00
Maarten ter Huurne
08ffbc76de Use our own alpha blended rectangle outline instead of SDL_gfx
I implemented it as four 1-pixel-wide filled rectangles. While this
is not the fastest way to do it, I doubt this will have a significant
impact on overall performance.

Note that the proper way to clip a rectangle outline is to clip the
outline's four lines individually, not clip the rectangle and then
draw a smaller rectangle outline. This means that an optimized drawing
routine would have to be aware of whether clipping occurs, complicating
the code.
2014-07-19 00:43:06 +02:00
Maarten ter Huurne
0dd027fcf4 Use our own alpha blended rectangle fill instead of SDL_gfx
I want to remove the dependency on SDL_gfx, since only two functions
from that library are actually used. Also this new blend implementation
is more optimized, especially the 32bpp case, which is the one most
platforms are using.
2014-07-19 00:43:06 +02:00
Maarten ter Huurne
9df565b73c Made rect+color the preferred argument style for (filled) rectangle drawing
This is the opposite of the old situation, when the structs were
unraveled.

The definitions for the alternative styles were moved to the header,
so the compiler has more opportunities for optimizing the conversions.
2014-07-19 00:43:06 +02:00
Maarten ter Huurne
dd27cb2e07 Add constructors for RGBAColor 2014-07-19 00:43:06 +02:00
Maarten ter Huurne
5f454a8569 Made strtorgba into a factory method of RGBAColor
The method is RGBAColor::fromString.
2014-07-19 00:43:06 +02:00
Maarten ter Huurne
950518f3a7 Made RGBAColor components 8 bits wide
The values are all in the range 0..255, so storing more than 8 bits
is wasteful.
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
2a4b519282 Removed return code from surface drawing methods
Not a single caller actually checked the return codes.
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
86ee9955d6 Removed dedicated horizontal line routine
Just draw a 1-pixel-high box instead.
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
0810a26589 Removed unnecessary includes of SDL_gfx header
Only surface.cpp actually uses SDL_gfx functions.
2014-07-19 00:43:05 +02:00
Nebuleon Fumika
9c4e97c839 Make the button repeat rate (after the first repetition) a user setting.
This allows for faster scrolling between section links, in file and directory
selectors, and in manuals, without repeatedly pressing buttons.

The setting's unit is repetitions per second. Its default value is set to
10, and anything between 0 (disabled) and 20 (50 ms) is acceptable.

Grabbing &(instance of GMenu2X).confInt["buttonRepeatRate"] is unsafe, because
the storage for the slot may move as the slot is deleted or added. Instead, a
callback jumps back into the context of an InputManager so the value can be
read from a GMenu2X object's configuration.

A GMenu2X object is also passed to InputManager::init.
2014-07-19 00:43:05 +02:00
Nebuleon Fumika
98a63e2940 Fix setting default values for configuration entries.
Previously, one would check the value in &confInt["someKey"] by passing a
reference to it to evalIntConf. However, because this passing of the reference
went through std::unordered_map::operator[], it created a slot with the named
key and initialised its value with the default constructor of int, which
placed 0 there, if it didn't exist. If the value of 0 was acceptable for the
setting, then 0 as the value selected by the user was indistinguishable from
a slot that had been just created and had to be set to its default.

Now, the std::unordered_map is passed along with the key so that evalIntConf
can check whether the key exists and, if it doesn't exist, set the value to
its default.

Include utilities.h in gmenu2x.h instead of the reverse. One type definition
used by utilities.cpp is moved there (ConfIntHash) and for consistency
ConfStrHash is moved there as well.
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
0908aa7bb7 Removed support for multi-line text drawing
When trying to test the previous commit, I couldn't find any place in
the application where strings containing newlines are drawn. So I'm
assuming this is an unnecessary feature, until someone comes up with
a test case proving otherwise.

Yeah, I'm too lazy to review all the code that draws text...
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
2effd1fc99 Made multi-line text drawing more efficient
Instead of splitting everything at once, split off one line at a time.
The code could be more compact but I want to avoid using substr on the
very common special case when a string contains no newlines.
2014-07-19 00:43:05 +02:00
Maarten ter Huurne
5c7ca19f4b Don't issue warnings when rendering empty string 2014-07-19 00:43:05 +02:00
Nebuleon Fumika
08fffbff6a Improve performance in Font::writeLine.
Asking FreeType for metrics before asking it for a render, when rendering
would compute the metrics anyway, is wasteful. Now the width of text, for
horizontal alignment purposes, is simply the width of the render.
2014-07-17 02:04:10 +02:00
Nebuleon Fumika
099bd24556 Use the font's suggested line height instead of its ascent and descent.
In well-described fonts, this enables multi-line text (e.g. in manuals) to be
more readable.

The term "height" is also replaced with "line spacing" in Font's code.
2014-07-17 02:03:02 +02:00
Nebuleon Fumika
349e758b3b Load previews from the previews/ subdir of the current dir in selectors.
This does away with per-link selector directories in link files. It is assumed
that, if a user has access to write files to be launched by an application at
some location, he or she also has access to write files in the previews/
subdirectory under it.
2014-07-17 02:02:23 +02:00
Nebuleon Fumika
aca6025533 Selector previews are now shown with alpha 128 and fill the screen.
The alpha change is so that:
* some of the background is still visible, which includes the name of the
  application for which the selector is being called, its description, and
  text in the status bar;
* the preview, if bright, does not obscure the file names too much.

Selector previews are now shown full-screen (320x240) instead of being a
160x160px square on the right.
2014-07-17 02:00:12 +02:00
Nebuleon Fumika
7284104fd1 Fix issues with loading images with alpha disabled.
These issues are fixed:
* loadPNG gave RGBA surfaces unconditionally. Now it gives RGB surfaces if
  its second parameter, defaulting to true, is false. This fixes adding per-
  surface alpha values, because an RGBA surface ignores its per-surface value.
* Surface::loadImage is updated to receive a third parameter, defaulting to
  true, to determine whether alpha is loaded.
* SurfaceCollection::defaultAlpha was never used.
* SurfaceCollection::defaultAlpha defaulted to false, so even if it were used,
  it would have loaded images without alpha.
2014-07-17 01:25:41 +02:00
Maarten ter Huurne
bb7a30d697 Simplify iteration over tokens using std::array 2014-07-17 01:19:18 +02:00
Nebuleon Fumika
4474a42767 Do not construct Font objects that crash gmenu2x if font loading fails.
This commit ensures that a fully constructed Font object will not crash
gmenu2x when it is used, even if loading the font or initialising SDL_ttf
altogether has failed. Instead, it will render no text, but icons and
images are still drawn.

The proper way to signal an error would be to throw an exception and fail
to construct the Font object. However, gmenu2x does not use exceptions.
2014-07-17 00:42:46 +02:00
Nebuleon Fumika
738c296c67 Fix crashes that could occur when keeping two fonts loaded concurrently.
Since 2002-09-03, SDL_ttf performs reference counting on TTF_Init and
TTF_Quit. If two fonts were loaded concurrently via the Font class and
one was destructed, the destructor of the first object would call TTF_Quit,
making the second object unusable. The constructor now calls TTF_Init
unconditionally to prevent this situation.

The reference counting behavior was introduced in this SDL_ttf commit:
http://hg.libsdl.org/SDL_ttf/rev/fc0371908009
2014-07-17 00:42:14 +02:00
Paul Cercueil
917cbf7208 Various changes related to translations 2014-07-15 14:25:17 +02:00
Paul Cercueil
5e22dd5941 Remove the 'Show root' option, which didn't do anything 2014-07-15 14:25:17 +02:00
Paul Cercueil
c72266d771 Remove the 'Selector alias file' feature
Who seriously used that?
2014-07-15 14:25:17 +02:00
Maarten ter Huurne
9e113d88c7 Fixed compilation with GCC 4.9 2014-05-18 21:19:03 +02:00
Paul Cercueil
fe1a586fb3 Don't consider *.dge files as being executables 2014-05-17 13:56:16 +02:00
Paul Cercueil
dac1e49238 Show the background while loading the menu
This is better than showing an empty black screen, I think.
2014-04-29 00:22:04 +02:00
Paul Cercueil
5fa8919f2b Allow to map actions to keyboard keys and joystick keys at the same time 2014-04-20 16:08:17 +02:00
Paul Cercueil
92a6453ff8 Re-insert proper detection of the %f tokens for OPK apps 2014-04-18 09:10:01 +02:00
Paul Cercueil
47b098cce6 Fix text in log viewer disappearing when pressing alt-right 2014-04-17 20:52:41 +02:00
Paul Cercueil
b1eedf6992 Init SDL timers before creating the menu 2014-04-14 00:28:11 +02:00
Paul Cercueil
9fba35feed Init the Menu before initializing SDL
This avoids seeing a black screen for a few seconds while GMenu2X
is loading.
2014-03-23 12:48:30 +01:00
Paul Cercueil
b087e5c1f9 Fix key repeat of analog stick working only on some screens 2014-02-24 22:34:53 +01:00
Paul Cercueil
7777b9edde Added key repeat on analog sticks and hats 2014-02-23 17:00:12 +01:00
Paul Cercueil
c19e78951d Fix launching non-OPK apps with files with special characters 2014-02-23 16:55:14 +01:00
Paul Cercueil
b0846812b8 Show disk usage of the home partition, not the one mounted on /boot 2014-02-07 13:43:46 +01:00
Paul Cercueil
0fd8333257 Merge branch 'opkrun' 2014-02-05 16:29:07 +01:00
Paul Cercueil
55a6528cde Revert to launching in the shell for non-OPK apps 2014-02-05 16:26:00 +01:00
Paul Cercueil
a7f0fef059 linkapp.cpp: remove dead/useless code 2014-02-05 14:53:46 +01:00
Paul Cercueil
1a1f891a4d Fix launching OPKs with a file containing spaces 2014-02-05 14:33:45 +01:00
Paul Cercueil
1792e6329b Change sort order so that OPKs are listed after normal links 2014-01-19 23:10:42 +01:00
Paul Cercueil
8bb58f6270 Sort links once they have all been added to the menu 2014-01-19 23:07:54 +01:00
Paul Cercueil
cb82d55350 Set default link size to 80x50 2014-01-16 16:23:26 +01:00
Paul Cercueil
ad30fae321 Remove "scan for applications and games" feature
It's been broken for a long time now.
2014-01-16 16:07:06 +01:00
Paul Cercueil
e63ad99ba9 Set row size to 20px minimum in file list if browsing directories 2014-01-16 16:02:29 +01:00
Paul Cercueil
408a991a9d Remove hardcoded sizes and positions in WallpaperDialog 2014-01-16 15:49:51 +01:00
Paul Cercueil
ae6f52a0a3 Fix BrowseDialog and InputDialog rendering incorrectly
Parts of the background were still visible when the upper and
lower bars were transparent.
2014-01-16 01:19:34 +01:00
Paul Cercueil
cfb96dd697 Pass a Surface to ButtonBox' and IconButton's paint function 2014-01-16 01:19:34 +01:00
Paul Cercueil
ca3df65daa Remove hardcoded sizes and positions in Selector 2014-01-16 01:19:30 +01:00
Paul Cercueil
67ac54e970 Handle the skin: prefix on the font path 2014-01-15 22:02:30 +01:00
Paul Cercueil
af258530db Allow the skin to change the font and font size 2014-01-15 20:32:17 +01:00
Paul Cercueil
c8cf37787b InputManager: Handle joystick hat events 2013-12-30 15:41:52 +01:00
Paul Cercueil
2ab44489a1 Execute the links directly, don't use the shell
This breaks one thing: the "params" option of the links must be
only one parameter (without spaces). The only way to actually
set this option being to edit the config files manually, it is
pretty safe to assume it will never contain two parameters.
2013-12-11 12:34:01 +01:00
Paul Cercueil
6ef3f3b190 Redirect to log by redefining stdout and stderr 2013-12-11 12:34:01 +01:00
Paul Cercueil
7c1af3a03b Use 'opkrun' to execute OPK files 2013-12-11 12:34:01 +01:00
Paul Cercueil
53ba01c40a Don't set called programs as group leaders
The comment of this code indicates that it is needed for
SDL apps to work correctly.

However, I don't see any valid reason for the apps we
launch to be running in a different group.

Removing it didn't make any apparent difference, so unless
I'm proven wrong, it'll stay gone from now on.
2013-12-11 12:31:47 +01:00
Paul Cercueil
31ad27f2bd Do not try to change the permissions of the executables 2013-12-11 12:31:29 +01:00
Paul Cercueil
61a79cd3d9 InputDialog: Make SETTINGS button confirm and MENU button cancel 2013-11-30 02:27:45 +01:00
Paul Cercueil
246fd8630c Output log to /var/log/gmenu2x.log 2013-11-08 11:27:34 +01:00
Paul Cercueil
217a9b5cd6 Remove calls to setInputSpeed(), as it only needs to be called once 2013-09-26 18:59:22 -03:00
Paul Cercueil
8452c037ac Remove calls to sync()
This is not a low-level tool to deal with the filesystem, using
sync() here is nonsense and just bogs down the system for nuts.
2013-09-26 18:58:12 -03:00
Paul Cercueil
6947997d44 Fix build for platforms without libopk 2013-09-19 17:26:32 +02:00
Paul Cercueil
0e4180460b Recover last session from main() instead of constructor
This fixes a bug where the apps using the file selector wouldn't be
launched at all when selecting a new file after a session recover.
2013-09-07 17:02:38 -04:00
Paul Cercueil
e86a96c73f Fixes the Selector returning empty file/directory names
This fixes commit ba5ef51269
2013-09-07 16:47:18 -04:00
Paul Cercueil
3ce314c65d Make the InputManager handle analog sticks as input 2013-09-07 11:09:56 -04:00
Paul Cercueil
dba6c32109 Change API of InputManager: we don't care about key release events 2013-09-07 11:00:57 -04:00
Paul Cercueil
ba5ef51269 Make the Selector return the canonicalised absolute pathname 2013-09-05 19:23:27 -04:00
Paul Cercueil
b73391486f Simplify again the prototype of LinkApp as gmenu2x->input is public 2013-09-05 19:20:54 -04:00
Paul Cercueil
1ff17d83c9 Add function GMenu2X::getTouchscreen(), to simplify Link and LinkApp prototypes 2013-09-05 19:19:16 -04:00
Paul Cercueil
20339c8849 Allow exiting the selector with B when not in explorer mode 2013-08-30 07:02:56 -04:00
Paul Cercueil
5eb8fb7fd7 Revert "When started, load all OPKs in a thread to boost startup time"
Loading dynamically at startup is a very bad idea, as it
confuses the "load state before exiting" feature of GMenu2X:
the file selector will pass the file to a different program,
the cursor will move to select a different app, etc.

This reverts commit 5c631d610e.
2013-08-28 13:49:08 -04:00
Paul Cercueil
5c631d610e When started, load all OPKs in a thread to boost startup time 2013-08-28 13:25:10 -04:00
Paul Cercueil
5d8fb6520f Code factorisation (Add function inject_user_event() to utilities) 2013-08-28 13:14:08 -04:00
Paul Cercueil
3ff6dc93f2 Also search the Default skin in the user directory for skin files
This fixes a segmentation fault occuring on the wallpaper dialog
when trying to select a wallpaper located in the Default skin in
the user directory, when the current skin is not "Default".
2013-08-28 11:32:23 -04:00
Maarten ter Huurne
965340a39c Fixed bug with launch screen and double buffering
LinkApp::drawRun() assumes the layers below are already painted when
it is called, but this was not the case. With single buffering, the
previous frame was still there so it still looked good, but with
double buffering the buffer typically contains an outdated screen.

Long term I think the launch should happen at the outermost scope,
so all destructors get a chance to run. This commit is a small step
in that direction, by exiting the main loop before launching.
2013-08-16 10:41:16 +02:00
Maarten ter Huurne
8d38decc82 Pass full path to LinkApp::launch 2013-08-16 09:46:16 +02:00
Maarten ter Huurne
d6deb29ba0 Eliminated selectedDir argument to LinkApp::launch() 2013-08-16 09:38:16 +02:00
Maarten ter Huurne
6c80a663e1 Check for empty strings using empty() instead of comparing to "" 2013-08-16 09:16:04 +02:00
Maarten ter Huurne
8472acc26c Removed checks for manuals and screenshots in JPEG and BMP format
Support for loading JPEG and BMP images was removed a long time ago,
so there is no point in looking for files in those formats.
2013-08-14 13:30:17 +02:00
Maarten ter Huurne
666be4d354 Fixed text area coordinates in TextDialog
Take top and bottom bar height as defined by skin into account.
2013-08-14 13:25:07 +02:00
Maarten ter Huurne
91dd708476 Added method GMenu2X::getContentArea() 2013-08-14 12:56:15 +02:00
Maarten ter Huurne
19fc3cb4d1 Added "bottomBarHeight" item to skin
There was already "topBarHeight", but the height of the bottom bar was
still hardcoded.
2013-08-14 12:23:15 +02:00
Maarten ter Huurne
1ffae36004 Made Surface argument to drawTopBar/drawBottomBar() mandatory 2013-08-14 11:47:29 +02:00
Maarten ter Huurne
69b2b795a2 Make GMenu2X::initBG() private 2013-08-14 11:47:29 +02:00
Maarten ter Huurne
b18e3fa6a8 Don't pass screen coordinates to drawScrollBar()
The scroll bar always spans the content area of the screen: the
position and height depend only on the theme and not on who is
drawing it.

Note that the coordinates passed were wrong in most cases, so this
commit fixes the scroll bar positioning for several dialogs.
2013-08-14 11:47:29 +02:00
Maarten ter Huurne
ea85b10d31 Reduce use of HAVE_LIBOPK inside LinkApp class as well
In commit de30b3f9 several outside uses were removed by always defining
isOpk(), this commit does the same for LinkApp itself.
2013-08-14 11:47:29 +02:00
Maarten ter Huurne
9c497e7867 Remove "don't leave" feature
If the application in question daemonizes, it will continue running
no matter whether we start it with system() or execlp(). So I don't
see a reason for this feature to exist and removing it means less
code paths to worry about.
2013-08-14 11:47:28 +02:00
Maarten ter Huurne
dfa5413b5b Removed the word "Color" from the labels in the skin settings menu
The labels were longer than the space before the RGBA controls and
the fact that these are colors is already clear from the context
(such as having an RGBA control after it ;).

I tried to update the translated versions of these labels as well.
However, since I don't speak most of these languages, it is possible
the result is grammatically incorrect. If this is the case, please
mail me a correction.
2013-08-14 11:47:28 +02:00
Maarten ter Huurne
742444c919 Removed Button class
It was only used to share implementation between IconButton and Link.
However, there was only one non-trivial method, handleTS(), and that
method used a different code path for each use case: doubleClick was
always false for IconButton and always true for Link. So the total
amount of code was actually reduced by eliminating this code sharing.

The main motivation for this split is that I can now freely refactor
Link without having to worry about IconButton.
2013-08-14 04:26:04 +02:00
Maarten ter Huurne
6378fcfcd7 Make Link and IconButton inherit from Button privately
Each part of the code deals with either Links or IconButtons, but
not both: the base class is only used to share implementation and
not interface. Make this explicit by doing private inheritance.
2013-08-13 01:47:02 +02:00
Maarten ter Huurne
06ee35bb7a Make ButtonBox deal with IconButtons instead of generic Buttons
Nowhere in the code do we actually mix IconButtons and Links (the other
Button subclass), so I'm thinking of breaking up this class hierarchy
or at least making the inheritance private.

Also switched to C++11 style loops.
2013-08-13 00:34:04 +02:00
Maarten ter Huurne
90afa096e7 Query animation status instead of storing it
This makes it a lot easier to support more than one possible animation
in the same layer.
2013-08-12 19:41:56 +02:00
Maarten ter Huurne
f820bf8d6e Scroll when link cursor moves into top/bottom row
Previously, the links would scroll when the cursor was about to move
out of screen. By scrolling earlier, the user gets a view of the next
row before it becomes the current row. This allows a longer reaction
time to switch from vertical to horizontal navigation when looking for
a particular link in the grid.
2013-08-12 06:11:18 +02:00
Maarten ter Huurne
6cdd5694d3 Minor cleanups in Menu::linkUp/Down() and setLinkIndex() 2013-08-12 05:54:20 +02:00
Maarten ter Huurne
0d0eebe365 Made Link/LinkApp::searchIcon() protected (instead of public) 2013-08-12 05:05:06 +02:00
Maarten ter Huurne
02dd542ea5 Renamed section left/right images
Since we adopted the circular navigation, there is no more need for
separate enabled and disabled images.
2013-08-12 01:38:32 +02:00
Maarten ter Huurne
de30b3f98f Define LinkApp::isOpk() also when OPK support is disabled
This reduces the number of required preprocessor directives, leading to
more readable code and more code being examined by the compiler (useful
to spot problems). Since the method is inlined, the compiler should be
able to eliminate the same amount of code that the preprocessor would,
only at a later stage of the compilation.
2013-08-12 00:13:18 +02:00
Maarten ter Huurne
271ef00c18 Call Menu::selLinkApp() only once in GMenu2X::editLink() 2013-08-12 00:08:28 +02:00
Maarten ter Huurne
84fe36b5e8 Implemented wrap around for context menu option selection 2013-08-11 23:50:20 +02:00
Maarten ter Huurne
76117663ff Converted the context menu to a Layer
This fixes a bug with the captured background being wrong when using
double buffering. Also it ensures that for example the clock in the
status bar is updated when the context menu is open.
2013-08-11 23:46:04 +02:00
Maarten ter Huurne
945e29986a Cleaned up GMenu2X::contextMenu() 2013-08-11 20:57:13 +02:00
Maarten ter Huurne
8de59b5c04 Animate section header changes 2013-08-11 05:17:12 +02:00
Maarten ter Huurne
f414ce4685 Allow layers to play animations 2013-08-11 01:35:43 +02:00
Maarten ter Huurne
71f4391cda Moved all code for opening the context menu into the Menu class
All of the entries in the context menu affect sections and links, so
the context menu should be considered part of the main menu, not of
the global / background context.
2013-08-09 19:09:57 +02:00
Maarten ter Huurne
3f299f62b6 Set initial key repeat delay to a more sensible value
Previously it was set to 1 ms, which in practice means "as fast as
you can" and leads to a lot of unintended repeats.
2013-08-09 18:18:51 +02:00
Maarten ter Huurne
346067896a Put background painting and global keys in new Background layer
The battery status was put into a separate class instead of directly
into the Background class.
2013-08-09 18:01:51 +02:00
Maarten ter Huurne
b0d1d9e55f Declare Surface methods that don't change the surface as "const"
This allows source surfaces (such as icons) to be passed around as
const references.
2013-08-09 17:47:34 +02:00
Maarten ter Huurne
46626030b2 Clock: Update current time atomically
Writing hours and minutes separately while the string representation
is being constructed could lead to an incorrect result on an hour
boundary. Avoid this by using an atomic timestamp.

With GCC 4.8.1 on MIPS this atomic timestamp is lock free.
2013-08-09 04:03:47 +02:00
Maarten ter Huurne
9e1f717d9b Made Clock destruction safe
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.
2013-08-09 03:13:02 +02:00
Maarten ter Huurne
9158b90a45 Made Clock simpler and more reliable
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.
2013-08-07 03:08:48 +02:00
Maarten ter Huurne
a15339d425 Cleanups of Clock class
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.
2013-08-07 02:55:23 +02:00
Maarten ter Huurne
f71ea3bcee Call Menu::skinUpdated() earlier in initMenu()
That method initializes linkColumns, which is divided by in
setLinkIndex().
2013-08-06 19:59:35 +02:00
Maarten ter Huurne
4a392a9173 Use reference to SurfaceCollection in Menu::paint()
This should have been a reference all along, but somehow I forgot to
actually type the "&".
2013-08-06 19:57:38 +02:00
Maarten ter Huurne
63029d85d7 Use shared_ptr for layers
This allows transient layers to be deleted automatically when they are
dismissed, while persistent layers will be kept alive by their other
owner(s).
2013-08-06 02:34:03 +02:00
Maarten ter Huurne
6d868a895a Implemented layer system for painting and events
The long term goal is to be able to use a single event loop regardless
of which submenu or alternative mode is active.
2013-08-06 01:55:32 +02:00
Maarten ter Huurne
074668336e Handle menu-related buttons inside Menu class 2013-08-05 16:43:22 +02:00
Maarten ter Huurne
d588b97b34 Removed InputManager::waitForReleasedButton()
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.
2013-08-05 16:01:50 +02:00
Maarten ter Huurne
e6300ab07a Changed section headers to be displayed in a circular fashion
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.
2013-08-05 14:54:42 +02:00
Maarten ter Huurne
903ccc2cfe Switch from mega to giga when showing large disk/card sizes
Also made our use of 1024-based prefixes explicit by using MiB/GiB.
2013-08-05 02:02:04 +02:00
Maarten ter Huurne
bdf3cfdf86 Moved linkColumns and linkRows fields into Menu class 2013-08-05 00:51:36 +02:00
Maarten ter Huurne
8d7ac6e0ba Center links horizontally 2013-08-05 00:42:59 +02:00
Maarten ter Huurne
f65a59a02f Fixed scrollbar size for links area
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.
2013-08-05 00:02:56 +02:00
Maarten ter Huurne
41b0551595 Moved menu touch handling code into Menu class 2013-08-04 23:19:15 +02:00
Maarten ter Huurne
1eeba171dd Moved menu painting code into Menu class 2013-08-04 21:14:29 +02:00
Maarten ter Huurne
cbe7735f73 Put main loop painting code in separate methods
Also declare the relevant variables with a reduced scope, where
possible.
2013-08-04 03:47:23 +02:00
Maarten ter Huurne
f8dc4c7bb8 Don't construct non-functional Font objects
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.
2013-08-04 00:58:32 +02:00
Maarten ter Huurne
724aefe482 Renamed ASFont class to just Font
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.
2013-08-03 22:30:12 +02:00
Maarten ter Huurne
0046fa9e19 Made ASFont::utf8Code() a function in inputdialog.cpp instead
The implementation doesn't make sense to me, but that's something for
another day; at least it is together with the code that calls it now.
2013-08-03 22:02:50 +02:00
Maarten ter Huurne
a9b5d8bd19 Moved most Menu::loadIcons() code into Link/LinkApp classes
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'.
2013-08-02 21:24:20 +02:00
Maarten ter Huurne
40372d14ef Cleaned up Menu::loadIcons()
Most changes involve not calling the same method with the same
arguments again and again. Also use C++11 range-based loops.
2013-08-02 20:53:38 +02:00
Maarten ter Huurne
a7b31669bb Restrict access to Link::recalcCoordinates()
This method was only called from within the Link class itself.
2013-08-02 20:53:02 +02:00
Maarten ter Huurne
dd55b7290b Do not draw NULL icon
If for whatever reason no icon at all could be loaded, then skip
drawing the icon rather than crashing on the NULL pointer.
2013-08-01 14:37:56 +02:00
Maarten ter Huurne
fb8f4e6e72 The "tr1" namespace is no longer needed now that we're on C++11 2013-08-01 14:37:56 +02:00
Paul Cercueil
de9b3cd27d Make sure the joystick subsystem is inited before InputManager starts 2013-07-29 16:54:12 -04:00
Paul Cercueil
fcb2618286 Open all available joysticks 2013-07-29 13:21:36 -04:00
Paul Cercueil
50b3bb2b7f Revert the log level to INFO
It was modified by error to DEBUG by commit 88f54e1ccc
2013-07-29 13:02:06 -04:00
Paul Cercueil
88f54e1ccc Drop incredibly dirty and huge file FastDelegate.h
It's way too over-engineered for what we need to do, and we can
do much simpler using C++11.
2013-07-29 12:58:25 -04:00
Paul Cercueil
9951ab2ab5 Switched to C++11 2013-07-29 12:55:58 -04:00
Paul Cercueil
152ed5cb29 Drop enum constants of unsupported button actions 2013-07-29 12:51:42 -04:00
Paul Cercueil
e0109dfe55 Initialize the timers subsystem of SDL at the beginning
This fixes a bug where disabling the backlight timeout would
prevent the clock from working correctly.
2013-07-22 00:20:18 -04:00
Paul Cercueil
47bbc0b673 Added a clock on the bottom bar 2013-07-21 23:54:09 -04:00
Paul Cercueil
b0fa6db97d Use an enum instead of hardcoded values for the user-injected codes 2013-07-21 23:52:35 -04:00
Paul Cercueil
a0515ad356 Make the file selector accept all files by default 2013-07-21 15:43:41 -04:00
Paul Cercueil
a682d10657 Load the localized title and description of an OPK if available 2013-07-20 21:21:36 -04:00