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

720 Commits

Author SHA1 Message Date
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
3a57912dca Removed ChangeLog again
Setting the Automake strictness to 'foreign' disables enforcement
of GNU project rules. Thanks to Paul Wise for the tip.
2014-07-25 06:34:34 +02:00
Maarten ter Huurne
98413bac90 Make a pro-forma ChangeLog file
Automake considers an absent ChangeLog to be fatal.
2014-07-24 20:36:44 +02:00
Maarten ter Huurne
5af64ef29f Update translation credit for Norwegian 2014-07-24 14:15:40 +02:00
Maarten ter Huurne
8722b355ac Use a single "about.txt" for all platforms
The content of this file is not actually platform specific, so having
it in multiple locations is just an extra maintenance burden.
2014-07-24 14:13:55 +02:00
Maarten ter Huurne
48dcfc95c5 Removed ChangeLog
It is not maintained. Please read the Git log instead.
2014-07-24 14:09:35 +02:00
KouenHasuki
c1b988980e Update Norwegian
Complete rewrite of the Norwegian GMenu2X for GCW0.

Done by: Lithium Flower
2014-07-24 12:44:12 +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