1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-10-02 17:16:23 +03:00
Commit Graph

536 Commits

Author SHA1 Message Date
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
Paul Cercueil
bec8d8756f Don't prepend the mounpoint to the binary path if not inside the OPK 2013-07-19 15:25:54 -04:00
Paul Cercueil
5255bf6de3 Destroy all registered Monitor objects when the Menu is destroyed 2013-07-19 14:50:46 -04:00