1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-05 09:53:45 +02:00
Commit Graph

700 Commits

Author SHA1 Message Date
Maarten ter Huurne
6a2a0969f3 Set close-on-exec flag on inotify file descriptor 2014-08-14 07:30:33 +02:00
Maarten ter Huurne
47d349f78b Simplified file extension filtering code
Don't create any temporary strings, just use the d_name field and
strcasecmp.
2014-08-14 06:43:37 +02:00
Maarten ter Huurne
404b2a1029 Use proper feature test macro for d_type support 2014-08-14 06:10:55 +02:00
Maarten ter Huurne
56beec0895 Convert file name to C++ string as late as possible
This avoids copying the string if the file is rejected because its
category (directory or regular file) is disabled.
2014-08-14 05:30:31 +02:00
Maarten ter Huurne
b6f6bb387c Skip stat() call when the d_type field can tell us the file type
This is a BSD extension also present in glibc and uClibc. Not all libc
implementations and not all file systems support it, so we keep the
stat-based code as a fallback.
2014-08-14 05:25:26 +02:00
Maarten ter Huurne
a505d3e494 Removed FileLister::insertFile
This was a nasty hack to insert English into the list of translations.
Instead of modifying the scan results, make a copy and modify the copy.
2014-08-14 05:08:36 +02:00
Maarten ter Huurne
85b072ca43 Removed FileLister::at
In the STL, 'at' will perform range checking while operator[] will not.
Since GMenu2X doesn't use exceptions, range checking is not possible,
so 'at' and operator[] were identical.
2014-08-14 05:02:24 +02:00
Maarten ter Huurne
ba47744a52 Put trivial FileLister method implementations in header
This cuts a few hundred bytes off the stripped binary size.
2014-08-14 04:59:07 +02:00
Maarten ter Huurne
eb3def19ea Replaced generic exclude mechanism by updir filter in FileLister
The exclude mechanism was only used to filter out ".." for the skins
lister, so this lighter filter does all we need.
2014-08-14 04:45:26 +02:00
Nebuleon Fumika
d51fbb8716 Properly save the value of Selector Browser after editing a link 2014-08-14 02:12:06 +02:00
Maarten ter Huurne
60aaf5954a Show a file selector in OPK links only if Exec requires a file
Previously, if a user installed a new version of an OPK with the same
name as one that had a link configuration file, GMenu2X could request
a file for an application whose new version required no files to
launch.

In practice, this transition would occur only once per OPK application,
when its developer decided to use a custom browser after having used
GMenu2X's file browser. This bug would then show GMenu2X's file browser
to request a file that would not even be passed to the application.

Thanks to Nebuleon for analyzing the problem and the above description.
2014-08-14 02:08:51 +02:00
Maarten ter Huurne
35724170f8 Make FileLister::browse not log a non-existing directory as an error
To avoid unnecessary existence checks, we consider browsing a
non-existing directory to be a normal situation.
2014-08-13 22:59:13 +02:00
Nebuleon Fumika
f85ef14b3e Remove unnecessary file existence check in WallpaperDialog::exec()
Browsing the user's wallpaper directory will simply add no new files
to the list of wallpapers available if the directory doesn't exist.
WallpaperDialog::exec doesn't need to care about that.

Because wallpapers are files, not directories, also don't return
directories in the result. The code that makes the wallpapers list
calls FileLister::getFiles and ignores directories anyway.
2014-08-13 22:51:56 +02:00
Nebuleon Fumika
cf896e6175 Remove unnecessary file existence check in GMenu2X::showSettings()
Browsing the user's translations directory will simply add no new files
to the list of translations available if the directory doesn't exist.
GMenu2X::showSettings() doesn't need to care about that.

Because translations are files, not directories, also don't return
directories in the result. The code that makes the translations list
calls FileLister::getFiles and ignores directories anyway.
2014-08-13 22:50:16 +02:00
Nebuleon Fumika
a60a529de6 Remove unnecessary file existence check in GMenu2X::writeSkinConfig
mkdir is able to return an error code in errno to indicate that the
directory requested to be created already exists (EEXIST).
2014-08-13 22:44:43 +02:00
Nebuleon Fumika
8cd3ab8cb8 Remove unnecessary file existence check in GMenu2X::readTmp()
A file existence check is already performed, atomically with respect to
the filesystem, by ifstream's constructor. The result of this check is
available using ifstream::is_open().
2014-08-13 22:43:41 +02:00
Nebuleon Fumika
82ac7ef44b Set the clock to 0 before reading application link files
0 is the default clock value, which doesn't get written to link files
if it's not changed. The clock was previously uninitialised before
reading link files, so it would get written with a random value if
there was none before.
2014-08-13 07:39:37 +02:00
Maarten ter Huurne
13f574bfb2 Avoid moving around entries unless new ones were found
When scanning multiple directories in succession, it's possible that
in some of them no matches are found. Avoid moving all pre-existing
entries back and forth in that case.

Also use move instead of copy for transferring the pre-existing
entries from the vector to the set.
2014-08-13 07:35:29 +02:00
Maarten ter Huurne
90a5f82b92 In FileLister::browse, declare variables when they are needed 2014-08-13 07:14:30 +02:00
Maarten ter Huurne
2c76ddae50 Removed special case handling for !(showDirectories || showFiles)
The special case is not necessary for correctness. It would help
performance in theory, but it seems very unlikely that any code would
request a directory scan when it interested in neither the subdirs nor
the files in that directory.
2014-08-13 07:08:04 +02:00
Maarten ter Huurne
46c64ea984 Move instead of copy strings at the end of FileLister::browse
This takes a little trickery, which I wrapped and documented.
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
f1e92425ac Optimise duplicate checking and sorting in FileLister::browse
Using a std::set makes both duplicate checking and sorting run in
O(n log n).
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
bd7eac32ba Pre-process the filter string in FileLister::setFilter
Instead of splitting the filter for every file in FileLister::browse,
the filter is split immediately in FileLister::setFilter, improving
performance.

getFilter is removed because it was unused. This also removes the need
to update the return type to 'const std::vector&' in the method and
rewrite its callers.
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
0b785770dc Use a plain FileLister instead of a pointer in BrowseDialog
Configuration of the FileLister is now left to the subclasses of
BrowseDialog, as the construction of a FileLister and its configuration
(to show or hide directories and files) have been separated.

This allows deleting the destructors of BrowseDialog's subclasses,
which existed solely to delete a FileLister object constructed by
each subclass.

The allocation of a BrowseDialog now also implies allocating enough
space for its FileLister, so remove the check for fl being nullptr in
BrowseDialog::exec().
2014-08-13 07:06:05 +02:00
Nebuleon Fumika
1dec6f6f11 Split creation, configuration and use of FileLister objects
The constructor now has zero arguments. showDirectories and showFiles
are now set using setter methods.

FileLister::browse is now the sole way to start a scan for files and
directories, replacing the initial path in the constructor and the
setPath method. It allows merging results from multiple directories
as before.

This is all to make explicit how many times the costly task of browsing
a directory is actually carried out.
2014-08-13 04:50:22 +02:00
Nebuleon Fumika
1508ac87ac When editing colors, show the selected color component using its color
Instead of showing 'R:', 'G:', 'B:' and 'A:', which take up a lot of space
and can overlap in standard fonts, the selection rectangle surrounding the
number is red, green, blue or gray, and the text is shorter.

This will allow the labels for the skin colors to be longer for translations
as well, given that their values are shown less wide.
2014-08-13 03:53:22 +02:00
Nebuleon Fumika
ab27096f10 Remove unnecessary file existence check in GMenu2X -> InputManager
Instead of checking which input configuration file exists among 2
choices, then asking InputManager to load that file, InputManager
itself now performs the resolution based on whether ifstream::is_open
returns true for each choice.
2014-08-13 03:29:42 +02:00
Nebuleon Fumika
d6b2643610 Remove unnecessary file existence check in GMenu2X::setSkin(2)
The existence of modifications to the skin configuration in the home
directory is now checked with ifstream::is_open, and the system's skin
configuration is used if that returns false.
2014-08-13 03:26:26 +02:00
Nebuleon Fumika
ebb34f3e00 Remove unnecessary file existence check in main
mkdir is able to return an error code in errno to indicate that the
directory requested to be created already exists (EEXIST).
2014-08-13 03:16:38 +02:00
Nebuleon Fumika
457fb0a085 Remove unnecessary file existence check in GMenu2X::readConfig(string)
A file existence check is already performed, atomically with respect to
the filesystem, by ifstream's constructor. The result of this check is
available using ifstream::is_open().
2014-08-13 03:15:38 +02:00
Maarten ter Huurne
a741653a13 Don't pre-strip file name extensions in Selector
This operation is not so slow that it really needs caching. Also
reducing the delay before showing a directory will have more impact
on the user experience than a slightly faster paint.
2014-08-12 09:17:38 +02:00
Maarten ter Huurne
1e50dff746 Moved code to remove a file name extension into utilities module 2014-08-12 09:07:37 +02:00
Maarten ter Huurne
aa5d8faeb6 Removed SurfaceCollection::defaultAlpha
The Selector was the only user and that code was removed.
2014-08-12 08:50:52 +02:00
Maarten ter Huurne
1229ef32e5 Removed screenshot caching from Selector
The way the caching was implemented was rather problematic. Also I'm
not convinced caching is useful at all. So I removed it. If at some
point we decide that caching is a good idea, it would be best to
re-implement it from scratch, so nothing of value is lost by removing
the existing caching code.

One problem was that the prepare method would check the existence of
a screenshot file for every file in the directory, which adds to the
noticable delay before showing a directory which holds many files.

Another problem is there was no upper limit to the number of
screenshots that would be cached. On directories with many screenshots
the memory use could rise to several hundred megabytes, which can be
problematic on some of the systems we want to support.

Also there was a rather nasty hack present to ensure screenshots were
loaded without an alpha channel.

My main doubt about the usefulness of screenshot caching is that
caching will only speed up the showing of an image from the second
time onwards. In typical use, the average screenshot is displayed at
most once. If the image load time is long enough to annoy the user,
any real solution would have to work also for the first showing.
For example, background (asynchronous) loading could be implemented.
2014-08-12 08:50:04 +02:00
Maarten ter Huurne
3305cf289b Minor cleanups in Selector::exec
Declare variables where they are needed instead of way in advance.
2014-08-12 08:38:05 +02:00
Maarten ter Huurne
b15175b05b Require valid section index passed to Menu::addActionLink
All calls to this method are in GMenu2X::initMenu() and they will only
pass valid indices, so the range check was redundant. Also the return
value was never used.

Added an assert to spot any invalid indices from future code.
2014-08-12 06:42:58 +02:00
Maarten ter Huurne
cc38c8ec00 Fixed misleading indentation in Menu::addActionLink
A reader might have concluded that the icon was always set.
2014-08-12 06:30:56 +02:00
Maarten ter Huurne
6492ab2fa2 Apply a minimum size for the scroll bar thumb
On long lists the computed size can become less than 1 pixel.
2014-08-12 00:01:40 +02:00
Maarten ter Huurne
60183e539d Removed most uses of naked Surface pointers
However, SurfaceCollection remains a very important user.
2014-08-10 14:21:14 +02:00
Maarten ter Huurne
4bd1c799bd Created separate subclasses for output and off-screen surfaces
There are a few exclusive operations for each type. Also we no longer
need the freeWhenDone flag since the class now determines whether the
surface should be freed or not.
2014-08-10 13:25:54 +02:00
Nebuleon Fumika
b3719d1331 Correct the viewport area in TextManualDialog
Hardcoded coordinates now follow gmenu2x's usual content area rules.

Copy-pasted from TextDialog.
2014-08-10 10:24:23 +02:00
Maarten ter Huurne
b833f59bb5 Show at least one row per page
In theory a font could be so large that no full row would fit on the
allotted space; in that case showing a partial row is better than
nothing and will avoid bugs where -1 wraps around on unsigned exprs.
2014-08-10 10:22:13 +02:00
Maarten ter Huurne
0535f8273b Rewrote the manual paging code
Nebuleon spotted a bug in TextManualDialog where the unsigned value
'pages[page].text.size() - rowsPerPage' could wrap around at 0 for
short chapters. I decided to change a bit more than just fixing the
bug though.
2014-08-10 10:09:42 +02:00
Maarten ter Huurne
799ebb9a29 Let SurfaceCollection::add make a copy of an existing surface
This allows the SurfaceCollection to claim ownership of the surface,
while ownership was undefined before.
2014-08-10 05:42:41 +02:00
Maarten ter Huurne
aff5f53f7d Don't pass around naked Surface pointers when drawing
Use references instead.
2014-08-10 04:26:59 +02:00
Maarten ter Huurne
20c5ec4eb6 Put Surface argument first in Dialog paint methods
This is the convention that most classes stick to. The likely reason
why Dialog didn't stick to the convention was to be able to provide
a default value for this argument, but that feature wasn't very useful
since every caller already had access to the default surface.
2014-08-10 04:02:10 +02:00
Maarten ter Huurne
5a281cf661 Implement the standard set of copy and move operations for Surface 2014-08-10 03:18:32 +02:00
Maarten ter Huurne
614f74a63d Removed halfW/H caching in Surface
This is a very cheap computation, no need to cache it.
2014-08-10 02:55:52 +02:00
Maarten ter Huurne
7c4fa5d77a Launch application after destructing menu
This allows all destructors to do their job before we pass control to
a new process.
2014-08-10 02:09:34 +02:00
Maarten ter Huurne
303ecf298a Moved console bind+activate code into Launcher
This way, we can launch console applications from the Explorer.
2014-08-08 02:04:05 +02:00
Maarten ter Huurne
dc23718f7f Enable "Display Console" flag for all platforms
Applications with this flag will not have their stdout/stderr
redirected to a log file when logging is enabled. That is a useful
feature also on platforms where we don't micromanage the console.
2014-08-08 01:35:51 +02:00
Maarten ter Huurne
3e34124e68 Added Launcher class
Currently the launched application is exec-ed from deep within the menu
code. This means a lot of destructors are never run and as a result
for example file descriptors from the menu remain open in the launched
process.

This is a first step to move the launch invocation from a deep call
stack to the top level.
2014-08-07 16:48:30 +02:00
Maarten ter Huurne
e32964bb50 Made Font ownership explicit using unique_ptr 2014-07-31 23:20:31 +02:00
Maarten ter Huurne
902145b698 Removed Surface::write method
All it did was redirect to Font::write, so it's better to call that
method directly.
2014-07-31 23:16:51 +02:00
Maarten ter Huurne
e44db20f31 Changed word wrapping to avoid trailing empty line
If a text file ends in a newline, the previous line splitting code
would append an empty line at the end, which looked odd. So now we
explicitly check that a newline is only inserted if more characters
follow.
2014-07-24 12:34:19 +02:00
Nebuleon Fumika
bac622fc39 Cap the width of setting names in SettingDialog to the width of the longest
Setting values are now displayed 10 pixels to the right of setting names, as
passed to MenuSetting::draw.

This commit also contains the following cleanups:

* The height of a row is passed to MenuSetting's draw and touchscreen methods.
* MenuSettingRGBA's magic constant (36) to separate the text for a color's
  four components is now a named constant.
* MenuSettingRGBA's color preview squares are now rowHeight - 2 pixels tall,
  and have a white border surrounded by a black border to help view the color
  it contains in both light and dark themes.
* The rectangle behind the selected setting's name is now drawn by that
  setting's drawSelected method.
2014-07-24 11:07:30 +02:00
Nebuleon Fumika
15472a073e Wrap long subtitles to multiple lines in Dialog::writeSubTitle
Setting descriptions and help prompts now appear fully even if they are longer
than the screen allows. Translations do not need to worry about allowed text
being wider than the screen in some fonts anymore.
2014-07-24 10:54:16 +02:00
Maarten ter Huurne
485bab3b48 Made text file reading more efficient and robust
Instead of reading the file line by line and then concatenating those
lines, just load the entire thing in one go. And pay more attention to
error conditions.
2014-07-24 10:41:20 +02:00
Nebuleon Fumika
d0de870180 Use Font::wordWrap in TextDialog and TextManualDialog
The constructors of those classes now accept a string to be wrapped, instead
of a vector to be modified with split lines inserted into its middle.

Along with this conversion, manuals for applications stored in OPK packages
are now transferred into a string without garbage at the end.
2014-07-24 09:00:22 +02:00
Nebuleon Fumika
0c860e8b90 Implement word wrapping as a method of Font
This implementation is based on the implementation in TextDialog::preProcess,
with one major difference: it works on the entire input string, copies it much
less as part of its function, and tries to quickly establish a small search
space for the length of the beginning split of each line.

With most standard fonts and sizes, this means up to 9 computations of metrics
per output line.
2014-07-24 09:00:22 +02:00
Nebuleon Fumika
b08a285b37 Fix the bounding box of message boxes
Multi-line message boxes had the incorrect height.

I also took the opportunity to make named constants out of magic numbers
making up the various message box dimensions.
2014-07-24 09:00:22 +02:00
Nebuleon Fumika
a468b33d1e When computing the width of multi-line text, split lines and return the longest
Along with the newline support in Font::write(), Font::getTextWidth() now
splits text along '\n' and returns the width of the longest split.
2014-07-24 08:59:48 +02:00
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