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

707 Commits

Author SHA1 Message Date
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
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
Zear
826d4bbac4 Added the Polish gmenu2x translation 2014-07-23 01:57:16 +02:00
Maarten ter Huurne
c311a7f16d Add imgv (image viewer) icon to 320x240 Scanlines* skins 2014-07-19 22:36:51 +02:00
Maarten ter Huurne
4744b5ec32 Add icons that were missing in 320x240 Default skin 2014-07-19 22:36:46 +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
Maarten ter Huurne
5e31df9e0f Use horizontal ruler in About texts
The special case of a line containing four dashes is rendered as a
pretty horizontal ruler, but the About texts contained five...
2014-07-19 01:33:28 +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
9d0a49524f Optimized PNG encoding
This reduces the installed size.
2014-07-19 00:43:06 +02:00
Maarten ter Huurne
de2fdfca87 Remove SDL_gfx as a dependency
The Surface class was changed to not use routines from SDL_gfx anymore.
2014-07-19 00:43:06 +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