1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 20:48:54 +03:00
Commit Graph

254 Commits

Author SHA1 Message Date
Maarten ter Huurne
fe0db484ec Removed "delegate.h"
The abstraction it provided was so thin that I think it is simpler to
just have the code use std::bind directly.
2014-08-16 07:07:41 +02:00
Maarten ter Huurne
3df841c150 Handle labelless icon positioning in GMenu2X::drawButton(Right)
Instead of correcting the returned coordinate with "- 10" externally,
omit the white space inside the methods.

Note that Font::getTextWidth, which was used until recently, considers
an empty string to have width 1, so 3 + getTextWidth("") + 6 == 10.

There is a difference in how buttons that have neither a label nor an
icon are positioned in the new code, but that is a situation that
should not occur in practice. Plus I'd argue that the new behavior is
actually better in that case.
2014-08-15 18:49:58 +02:00
Maarten ter Huurne
45304052cd Changed icon lookup in GMenu2X::drawButton(Right)
Look up the icon with the "skin:" prefix to be consistent with how
other lookups of the same icons are performed. Also don't perform
repeated lookups.
2014-08-15 17:59:55 +02:00
Maarten ter Huurne
8e885bc2c1 Removed GMenu2X::drawButton variant
This was only called form ButtonBox, so I moved the code there.

I still think a paint method shouldn't be repositioning widgets, but
that's something for a later cleanup.
2014-08-15 17:27:09 +02:00
Maarten ter Huurne
c1d57b62de In GMenu2X::drawButton, don't build a rectangle if we only need width 2014-08-15 16:35:24 +02:00
Maarten ter Huurne
6e8491abee Don't use (void) for empty argument list
This is necessary in C, but unusual in C++.
2014-08-15 14:01:11 +02:00
Maarten ter Huurne
7134eb3778 Store "bgmain" in the GMenu2X object instead of in SurfaceCollection
Since this surface is created by initBG instead of loaded from skin
search paths, it didn't really fit in SurfaceCollection. After removing
it, one of SurfaceCollection's methods could be removed as well.
2014-08-15 04:03:00 +02:00
Maarten ter Huurne
ab7a4c1cf7 Have Font::write return the width of the drawn text
This avoids having to do separate getTextWidth calls in several places.

More getTextWidth calls could be saved by splitting the rendering of
the font to an off-screen buffer from the final composition onto the
destination surface: the routines that draw text inside a box have to
compute the width before they can draw the box and currently the box
has to be drawn before the text.
2014-08-15 03:32:32 +02:00
Maarten ter Huurne
c8ea974f51 Fixed compile error on platforms where ENABLE_CPUFREQ is defined 2014-08-15 01:41:20 +02:00
Maarten ter Huurne
02384c8e72 Removed skin lookup feature from OffscreenSurface::loadImage
Instead, make the caller perform the lookup. This simplifies the
interface of loadImage and it removes the dependency from
OffscreenSurface on SurfaceCollection.
2014-08-15 01:34:35 +02:00
Maarten ter Huurne
c1689e41fb Dismantled Singleton pattern of PowerSaver
The instance-on-demand didn't really work, since we needed explicit
control over this object's destruction to ensure the timer is stopped
when launching an application. And trying to combine getInstance() with
explicit external delete was just ugly.
2014-08-14 09:47:05 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
7777b9edde Added key repeat on analog sticks and hats 2014-02-23 17:00:12 +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