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.
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.
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.
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.
This is the opposite of the old situation, when the structs were
unraveled.
The definitions for the alternative styles were moved to the header,
so the compiler has more opportunities for optimizing the conversions.
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.
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.
When trying to test the previous commit, I couldn't find any place in
the application where strings containing newlines are drawn. So I'm
assuming this is an unnecessary feature, until someone comes up with
a test case proving otherwise.
Yeah, I'm too lazy to review all the code that draws text...
Instead of splitting everything at once, split off one line at a time.
The code could be more compact but I want to avoid using substr on the
very common special case when a string contains no newlines.
Asking FreeType for metrics before asking it for a render, when rendering
would compute the metrics anyway, is wasteful. Now the width of text, for
horizontal alignment purposes, is simply the width of the render.
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.
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.
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.
These issues are fixed:
* loadPNG gave RGBA surfaces unconditionally. Now it gives RGB surfaces if
its second parameter, defaulting to true, is false. This fixes adding per-
surface alpha values, because an RGBA surface ignores its per-surface value.
* Surface::loadImage is updated to receive a third parameter, defaulting to
true, to determine whether alpha is loaded.
* SurfaceCollection::defaultAlpha was never used.
* SurfaceCollection::defaultAlpha defaulted to false, so even if it were used,
it would have loaded images without alpha.
This commit ensures that a fully constructed Font object will not crash
gmenu2x when it is used, even if loading the font or initialising SDL_ttf
altogether has failed. Instead, it will render no text, but icons and
images are still drawn.
The proper way to signal an error would be to throw an exception and fail
to construct the Font object. However, gmenu2x does not use exceptions.
Since 2002-09-03, SDL_ttf performs reference counting on TTF_Init and
TTF_Quit. If two fonts were loaded concurrently via the Font class and
one was destructed, the destructor of the first object would call TTF_Quit,
making the second object unusable. The constructor now calls TTF_Init
unconditionally to prevent this situation.
The reference counting behavior was introduced in this SDL_ttf commit:
http://hg.libsdl.org/SDL_ttf/rev/fc0371908009