1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 21:02:21 +03:00
Commit Graph

61 Commits

Author SHA1 Message Date
Maarten ter Huurne
7b2c26cc3c Don't apply realpath() to entered subdirs in Selector
This way, symlinks stay in the path, so when we go up a level we end
up in the previous directory instead of in the linked directory's
parent.
2014-08-20 14:57:17 +02:00
Maarten ter Huurne
fe0c7c2e8d When going up a level in the selector, put cursor on old dir
This adds a sense of continuity to the navigation.
2014-08-17 11:15:21 +02:00
Maarten ter Huurne
bb30dedd09 When selector goes up from the root directory, stay in the root
Previously the selector would exit, but I don't see the logic in that.
2014-08-17 10:25:28 +02:00
Maarten ter Huurne
0b0e278459 Deal gracefully with the selector being started on a non-existent dir
If directory browsing is enabled, fall back to the closest existing
parent directory. If directory browsing is disabled, show empty list.
2014-08-17 10:05:21 +02:00
Maarten ter Huurne
9e22b0328f Made new "no items" text in Selector translatable 2014-08-17 08:41:09 +02:00
Maarten ter Huurne
dc39fcc01f Make Selector robust against an empty file list
This can happen on a directory with 0 file matches when directories are
not being shown (otherwise there is either ".." or a subdir).

Since there is nothing to be selected, the Accept button is disabled
and no cursor is shown.
2014-08-16 15:50:16 +02:00
Maarten ter Huurne
3cce71284a Redistribute any leftover vertical space in Selector 2014-08-16 15:42:33 +02:00
Maarten ter Huurne
d16cb902b3 Improved Selector's handling of the folder icon
Renamed fontHeight to lineHeight, since it is computed using both the
font's line spacing and the height of the folder icon. For the latter,
use the actual icon height plus two pixels spacing instead of the
hardcoded value of 20 (16 height + 4 pixels spacing).

Fixed recently introduced bug where "top" is added to the folder icon
y-coordinate twice. Also center the icon vertically when a large font
is used.

Don't crash if the folder icon is missing. This could only happen on
broken installations though. Also don't search for the icon twice:
SurfaceCollection::skinRes already calls addSkinRes internally when
there is no cached surface for the key.
2014-08-16 15:41:06 +02:00
Maarten ter Huurne
88a4d1d911 Minor cleanups in Selector
Removed unused data member selRow.
Keep reference to LinkApp instead of pointer.
Call LinkApp::getSelectorBrowser once and store result.
Renamed fontheight to fontHeight.
Use iY consistently: store the item's y-coordinate in it.
2014-08-16 07:31:33 +02:00
Maarten ter Huurne
004c41e2ef Simplify bottom bar button drawing in Selector
Put the drawButton calls left-to-right.
Avoid duplicate code.

The order was changed: "Select" is now always first, to be consistent
with other dialogs.
2014-08-15 18:53:08 +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
739a9463be Don't use string::compare if there are better alternatives
When comparing full strings, operator== will do nicely.
When comparing the first char, "s[0] == c" is more efficient if we know
the string cannot be empty.
2014-08-15 14:19:17 +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
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
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
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
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
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
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
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
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
Paul Cercueil
917cbf7208 Various changes related to translations 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
e63ad99ba9 Set row size to 20px minimum in file list if browsing directories 2014-01-16 16:02:29 +01:00
Paul Cercueil
ca3df65daa Remove hardcoded sizes and positions in Selector 2014-01-16 01:19:30 +01: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
ba5ef51269 Make the Selector return the canonicalised absolute pathname 2013-09-05 19:23:27 -04:00
Paul Cercueil
20339c8849 Allow exiting the selector with B when not in explorer mode 2013-08-30 07:02:56 -04: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
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
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
fb8f4e6e72 The "tr1" namespace is no longer needed now that we're on C++11 2013-08-01 14:37:56 +02:00
Maarten ter Huurne
f28e4f6d89 Minimized gmenu2x.h.
Everything that does not need to be shared was moved to gmenu2x.cpp.
2011-10-23 17:27:29 +02:00
Maarten ter Huurne
aea1c44020 utilities: Replace min/max functions by the versions from STL. 2011-10-23 17:00:23 +02:00
Maarten ter Huurne
a01d892eb6 More header cleanups.
This time the focus was on removing namespace imports from headers.
2011-10-23 16:43:56 +02:00
Maarten ter Huurne
e0e7e87ebc Massive header cleanup.
The main goal is to avoid including "gmenu2x.h" from headers.
But I did various other cleanups as well while I was at it.
2011-10-23 16:13:02 +02:00
Maarten ter Huurne
315bf0a180 InputManager: C++-style type definitions.
There is no need to typedef enums and structs in C++.
Put types defined by InputManager inside the class namespace.
Changed type names to CamelCase.
2011-10-23 09:04:12 +02:00
Ayla
759eefd676 The files "a.png" and "b.png" have been renamed to "cancel.png" and "accept.png". 2011-09-18 03:40:33 +02:00
Ayla
826d622285 Modified the key shortcuts for the generic file/dir selector class. 2011-09-18 03:23:47 +02:00
Maarten ter Huurne
8a81837c04 Surface: Make pixel format conversion explicit.
Instead of having the copy constructor convert to display format, the new
copy constructor preserves the pixel format and a separate method was
introduced to convert surfaces to display format.

The code was made more robust as well: it should no longer crash if the
wallpaper cannot be loaded.
2011-06-03 11:46:36 +02:00
Maarten ter Huurne
a35a7e2c35 Introduced enums for text alignment in the ASFont class. 2011-05-09 05:17:25 +02:00
Ayla
563cb34a89 Rewrote the whole input system.
Gmenu2X will no longer eat 100% CPU ;)
2010-09-17 22:34:26 +02:00
Ayla
7c9364780b Replaced every message output by calls to the log macros. 2010-09-17 22:31:09 +02:00