Survex 1.2.18 released
Olly Betts
olly at survex.com
Thu Jun 11 02:32:12 BST 2015
On Tue, Jun 09, 2015 at 05:40:34AM +0000, Robert Jones wrote:
> I've built wx trunk and tried to build again with your patch applied. The
> build succeeds, however an assert fails when loading bitmap images:
> ../src/osx/core/bitmap.cpp(1302): assert ""image.IsOk()"" failed in
> wxBitmap(): invalid image
>
> I think the problem might be in the stringification macro:
> #define TOOL(x) wxBitmap(wxImage(#x "_xpm"), -1, content_scale_factor) -->
> doesn't work
> #define TOOL(x) wxBitmap(wxImage(x##_xpm), -1, content_scale_factor) -->
> does work
>
> If I'm reading the docs right, # doesn't concatenate the tokens.
The second version is right - here's what the two mean:
In the first version, #x expands to a literal string containing the
macro's argument, so TOOL(open) becomes:
wxBitmap(wxImage("open" "_xpm"), -1, content_scale_factor)
And in C and C++, two adjacent literal strings are treated as one, so
that's the same as:
wxBitmap(wxImage("open_xpm"), -1, content_scale_factor)
However, that tries to load a file called "open_xpm", which isn't what
we want to do.
In the second version, ## does token pasting, so TOOL(open) becomes:
wxBitmap(wxImage(open_xpm), -1, content_scale_factor)
That loads the image from the variable open_xpm, which is defined in
lib/icons/open.xpm (XPM is a slightly odd image format which you can
just #include into C or C++ code - it's not very compact, but that
doesn't matter for images this small, and it avoids us having to open a
file for each toolbar image which means aven starts up more quickly).
> With that change, icons are still rendered at the same resolution. Instead
> the icon bitmap gets resampled by content_scale_factor prior to being
> rendered. As you might expect, this makes no discernable difference (but
> produces debug warnings) for values of content_scale_factor > 1, and fuzzy
> down-sampled images for values <1. The rendered icon size on-screen remains
> constantly large as before.
OK, so we can just scrap this code then, as it doesn't even work, and
forcing a native toolbar achieves what it is trying to do but also works
with current wx releases.
> I'm happy to produce some .icns images at the appropriate resolutions given
> a little time. Would that be helpful?
That would be useful.
The list that needs doing should be all the .xpm files in lib/icons
apart from "aven.xpm" (which is the application icon), and perhaps
"survey_tree.xpm" and "pres_tree.xpm" (which are used in the notebook in
the left pane).
Cheers,
Olly
More information about the Survex
mailing list